Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using Documenter
using Documenter: Selectors, Expanders, Markdown
using Documenter.Markdown: Link, Paragraph
struct DatabaseLookup <: Expanders.ExpanderPipeline end
Selectors.order(::Type{DatabaseLookup}) = 0.5
Selectors.matcher(::Type{DatabaseLookup}, node, page, doc) = false
match_kw(x::String) = ismatch(r"\@library\[example\] \"(.*)\"", x)
match_kw(x::Paragraph) = any(match_kw, x.content)
match_kw(x::Any) = false
Selectors.matcher(::Type{DatabaseLookup}, node, page, doc) = match_kw(node)
function Selectors.runner(::Type{DatabaseLookup}, x, page, doc)
matched = nothing
for elem in x.content
if isa(elem, AbstractString)
matched = match(r"\@library\[example\] \"(.*)\"", elem)
matched != nothing && break
end
end
matched == nothing && error("No match: $x")
database_key = matched[1]
page.mapping[x] = Markdown.Code("julia", look_up_source(database_key))
end
makedocs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment