# Cannot document @everywhere function

**URL:** https://discourse.julialang.org/t/cannot-document-everywhere-function/54044
**Category:** General Usage
**Tags:** documentation, distributed
**Created:** [January 27, 2021, 9:24am UTC](https://discourse.julialang.org/t/cannot-document-everywhere-function/54044 "2021-01-27T09:24:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![matthiasbe](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@matthiasbe](https://discourse.julialang.org/u/matthiasbe)
#### Post date: [January 27, 2021, 9:24am UTC](https://discourse.julialang.org/t/cannot-document-everywhere-function/54044/1 "2021-01-27T09:24:14Z")

</div>

It seems I can not document and put the `@everywhere` annotation at the same time.

The following code

```julia
"""
Prints something
"""
@everywhere function my_func()
  println("hello")
end

```

throws the error

```julia
ERROR: LoadError: cannot document the following expression:

#= /path/test.jl:4 =# @everywhere function my_func()
        #= /path/test.jl:4 =#
        #= /path/test.jl:5 =#
        println("hello")
    end

'@everywhere' not documentable. See 'Base.@ __doc__' docs for details.

Stacktrace:
 [1] error(::String, ::String) at ./error.jl:42
 [2] top-level scope at /path/test.jl:1
 [3] include(::String) at ./client.jl:457
 [4] top-level scope at REPL[8]:1
in expression starting at /path/test.jl:1

```

Is there a workaround for this ?

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [January 27, 2021, 9:54am UTC](https://discourse.julialang.org/t/cannot-document-everywhere-function/54044/2 "2021-01-27T09:54:19Z")

</div>

I think you can do:

```julia
julia> f(x) = 1
f (generic function with 1 method)

julia> @everywhere f

```

But please report is as bug at [Issues · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues), if it hasn’t yet been reported.

---

<div class="post-metadata">

### Author: ![matthiasbe](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@matthiasbe](https://discourse.julialang.org/u/matthiasbe)
#### Post date: [January 27, 2021, 10:03am UTC](https://discourse.julialang.org/t/cannot-document-everywhere-function/54044/3 "2021-01-27T10:03:47Z")

</div>

@mauro3 I can’t get this to work. In this case the function is not defined on the remote worker.

I use this script

```julia
"""
Prints something
"""
function my_func()
  println("hello")
end

@everywhere my_func

@fetchfrom workers()[1] my_func()

```

And it gives

```julia
ERROR: LoadError: On worker 2:
UndefVarError: my_func not defined

```

I execute this with `julia -p 4` and `include("test.jl")`

I created the [issue](https://github.com/JuliaLang/julia/issues/39417) on github btw

---

<div class="post-metadata">

### Author: ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)
#### Post date: [January 27, 2021, 10:23am UTC](https://discourse.julialang.org/t/cannot-document-everywhere-function/54044/4 "2021-01-27T10:23:52Z")

</div>

you can try to separate docstring declaration from function definition like that:

```julia
"""
Prints something
"""
function my_func end

@everywhere my_func()
  println("hello")
end

```

---

<div class="post-metadata">

### Author: ![matthiasbe](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@matthiasbe](https://discourse.julialang.org/u/matthiasbe)
#### Post date: [January 27, 2021, 10:27am UTC](https://discourse.julialang.org/t/cannot-document-everywhere-function/54044/5 "2021-01-27T10:27:56Z")

</div>

@pbayer This works, thank you !

---

<div class="post-metadata">

### Author: ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)
#### Post date: [January 27, 2021, 1:43pm UTC](https://discourse.julialang.org/t/cannot-document-everywhere-function/54044/6 "2021-01-27T13:43:48Z")

</div>

You can simply write:

```julia
@everywhere """
DOCSTRING
"""
function foo()
    println("hello")
end

```

And it should work perfectly fine.

Also you can wrap your code in `begin...end` blocks like this:

```julia
@everywhere begin
"""
DOCSTRING
"""
function foo()
    println("hello")
end
end

```
