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

added filter function to @autodocs #885

Merged
merged 14 commits into from
Dec 5, 2018
10 changes: 8 additions & 2 deletions src/Expanders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,11 @@ function Selectors.runner(::Type{AutoDocsBlocks}, x, page, doc)
for (ex, str) in Utilities.parseblock(x.code, doc, page)
if Utilities.isassign(ex)
try
fields[ex.args[1]] = Core.eval(curmod, ex.args[2])
if ex.args[1] == :Filter
fields[ex.args[1]] = Core.eval(Main, ex.args[2])
else
fields[ex.args[1]] = Core.eval(curmod, ex.args[2])
end
catch err
push!(doc.internal.errors, :autodocs_block)
@warn "failed to evaluate `$(strip(str))` in `@autodocs` block in $(Utilities.locrepr(page.source))" exception = err
Expand All @@ -346,15 +350,17 @@ function Selectors.runner(::Type{AutoDocsBlocks}, x, page, doc)
pages = map(normpath, get(fields, :Pages, []))
public = get(fields, :Public, true)
private = get(fields, :Private, true)
filterfunc = get(fields, :Filter, x -> true)
results = []
for mod in modules
for (binding, multidoc) in Documenter.DocSystem.getmeta(mod)
# Which bindings should be included?
isexported = Base.isexported(mod, binding.var)
included = (isexported && public) || (!isexported && private)
filtered = filterfunc(Core.eval(binding.mod, binding.var))
timziebart marked this conversation as resolved.
Show resolved Hide resolved
# What category does the binding belong to?
category = Documenter.DocSystem.category(binding)
if category in order && included
if category in order && included && filtered
for (typesig, docstr) in multidoc.docs
path = normpath(docstr.data[:path])
object = Utilities.Object(binding, typesig)
Expand Down