Created
March 23, 2018 10:04
-
-
Save anthony-wang/a947bfbb26be87988291617db5ec611b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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