Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callable Types causing UndefVarError #290

Closed
joshbode opened this issue Sep 27, 2016 · 3 comments
Closed

Callable Types causing UndefVarError #290

joshbode opened this issue Sep 27, 2016 · 3 comments

Comments

@joshbode
Copy link

Types with with a documented call method (e.g. (x::DataType)) are giving an error when building docs in Julia 0.5 using the current version of Documenter.jl.

For example, the simple type Wrapper:

"""
    Wrapper(f)

Wrap a function.
"""
type Wrapper
    f::Function
end

"""
    (wrapper::Wrapper)(args...; kwargs...)

Call wrapped function.
"""
(w::Wrapper)(args...; kwargs...) = w.f(args...; kwargs...)

gives the following error when documentation is built:

$ julia make.jl
Documenter: setting up build directory.
Documenter: expanding markdown templates.
ERROR: LoadError: UndefVarError: w not defined
 in category(::Base.Docs.Binding) at /Users/josh/.julia/v0.5/Documenter/src/DocSystem.jl:380
 in runner(::Type{Documenter.Expanders.AutoDocsBlocks}, ::Base.Markdown.Code, ::Documenter.Documents.Page, ::Documenter.Documents.Document) at /Users/josh/.julia/v0.5/Documenter/src/Expanders.jl:335
 in dispatch(::Type{Documenter.Expanders.ExpanderPipeline}, ::Base.Markdown.Code, ::Documenter.Documents.Page, ::Documenter.Documents.Document) at /Users/josh/.julia/v0.5/Documenter/src/Selectors.jl:164
 in expand(::Documenter.Documents.Document) at /Users/josh/.julia/v0.5/Documenter/src/Expanders.jl:29
 in dispatch(::Type{Documenter.Builder.DocumentPipeline}, ::Documenter.Documents.Document) at /Users/josh/.julia/v0.5/Documenter/src/Selectors.jl:164
 in cd(::Documenter.##2#3{Documenter.Documents.Document}, ::String) at ./file.jl:59
 in #makedocs#1(::Bool, ::Array{Any,1}, ::Function) at /Users/josh/.julia/v0.5/Documenter/src/Documenter.jl:159
 in (::Documenter.#kw##makedocs)(::Array{Any,1}, ::Documenter.#makedocs) at ./<missing>:0
 in include_from_node1(::String) at ./loading.jl:488
 in include_from_node1(::String) at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
 in process_options(::Base.JLOptions) at ./client.jl:262
 in _start() at ./client.jl:318
 in _start() at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
while loading /Users/josh/doctest/make.jl, in expression starting on line 29

See this gist for a complete example.

@MichaelHatherly
Copy link
Member

Documenting call overloads is not supported by Julia's docsystem, since there isn't a named object that the docstring can actually be bound to (you'd want to bind the doc to an instance of Wrapper). The recommended approach is to document within the type's docstring that objects of type Wrapper are callable and provide a usage example there.

@vchuravy
Copy link
Contributor

dup of #228

@joshbode
Copy link
Author

Thanks for that @MichaelHatherly - clearly an issue upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants