Can I make docstrings work with @everywhere?

It seems I can’t document my code with docstrings if I want to do parallel computing with the @everywhere macro:

test_docstring.jl:

"This is a doc string"
@everywhere function foo()
    nothing
end
julia> versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Prescott)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)

julia> include("test_docstring.jl")
ERROR: LoadError: cannot document the following expression:

@everywhere function foo() # ...somepath.../test_docstring.jl, line 3:
        nothing
    end

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

Stacktrace:
 [1] error(::String, ::String, ::Vararg{String,N} where N) at ./error.jl:30
 [2] include_from_node1(::String) at ./loading.jl:576
 [3] include(::String) at ./sysimg.jl:14
while loading /...some_path.../test_docstring.jl, in expression starting on line 1

1 Like

Try

@everywhere begin
    "This is a doc string"
    function foo()
        nothing
    end
end
4 Likes

Works for me. Thanks!