Skip to content

Instantly share code, notes, and snippets.

@hayd
Created January 20, 2015 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hayd/bdddb51dc7df89b9a24e to your computer and use it in GitHub Desktop.
Save hayd/bdddb51dc7df89b9a24e to your computer and use it in GitHub Desktop.
MetaDoc type
type MetaDoc
docstring::Base.Markdown.MD
sections::Vector{Pair}
MetaDoc(docstring, sections) = new(docstring, [sections])
MetaDoc(docstring, sections...) = new(docstring, [sections...])
end
m = MetaDoc(doc"....docs.... for `m`", :author=>"Me", :section=>"Foo functions")
function Base.display(d::Base.REPL.REPLDisplay, m::MetaDoc)
display(d, m.docstring)
for (section, md) in m.sections
display(d, Base.Markdown.MD([Base.Markdown.Header([string(section)]),
Base.Markdown.Paragraph([md]),
]))
end
end
# so far so good
# m prints as you might hope
@doc m -> function foo() end
##### but help doesn't work...
julia> @doc foo
2-element Array{Any,1}:
Base.Markdown.MD(Any[foo()],Dict{Any,Any}())
MetaDoc(Base.Markdown.MD(Any[Base.Markdown.Paragraph(Any["....docs.... for ",Base.Markdown.Code("","m")])],Dict{Any,Any}(:path=>nothing,:module=>Main)),Pair{K,V}[:author=>"Me",:section=>"Foo functions"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment