Skip to content

Instantly share code, notes, and snippets.

@anthony-wang
Created March 23, 2018 10:04
Show Gist options
  • Save anthony-wang/a947bfbb26be87988291617db5ec611b to your computer and use it in GitHub Desktop.
Save anthony-wang/a947bfbb26be87988291617db5ec611b to your computer and use it in GitHub Desktop.
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