diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index 970def9546fc01..db29950c87faad 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -252,9 +252,9 @@ function namedoc(meta, def, name) end end -function funcdoc(meta, def) - f = esc(namify(def)) - m = :(which($f, $(esc(signature(def))))) +function funcdoc(meta, def, def′, name) + f = esc(name) + m = :(which($f, $(esc(signature(def′))))) quote @init $(esc(def)) @@ -275,15 +275,13 @@ end function objdoc(meta, def) quote @init - f = $(esc(def)) - doc!(f, $(mdify(meta))) - f + doc!($(esc(def)), $(mdify(meta))) end end fexpr(ex) = isexpr(ex, :function, :(=)) && isexpr(ex.args[1], :call) -function docm(meta, def) +function docm(meta, def, define = true) # Quote, Unblock and Macroexpand # * Always do macro expansion unless it's a quote (for consistency) # * Unblock before checking for Expr(:quote) to support `->` syntax @@ -301,12 +299,17 @@ function docm(meta, def) # Allow more general macrocall for now unless it causes confusion. return objdoc(meta, namify(def′.args[1])) end - isexpr(def′, :macro) && return namedoc(meta, def, symbol("@", namify(def′))) - isexpr(def′, :type) && return typedoc(meta, def, namify(def′.args[2])) - isexpr(def′, :bitstype) && return namedoc(meta, def, def′.args[2]) - isexpr(def′, :abstract) && return namedoc(meta, def, namify(def′)) - isexpr(def′, :module) && return namedoc(meta, def, def′.args[2]) - fexpr(def′) && return funcdoc(meta, def′) + + define || (def = nothing) + + fexpr(def′) && return funcdoc(meta, def, def′, namify(def′)) + isexpr(def′, :type) && return typedoc(meta, def, namify(def′.args[2])) + isexpr(def′, :macro) && return namedoc(meta, def, symbol("@", namify(def′))) + isexpr(def′, :abstract) && return namedoc(meta, def, namify(def′)) + isexpr(def′, :bitstype) && return namedoc(meta, def, def′.args[2]) + isexpr(def′, :module) && return namedoc(meta, def, def′.args[2]) + isexpr(def′, :(=), :const) && return namedoc(meta, def, namify(def′)) + isexpr(def′, :macrocall) && (def = namify(def′)) return objdoc(meta, def) end @@ -334,6 +337,8 @@ Base.DocBootstrap.setexpand!(docm) eval(Base.DocBootstrap, :(import ..Docs: @init, doc!, doc, @doc_str)) +Base.DocBootstrap.loaddocs() + # Metametadata """ diff --git a/base/docs/bootstrap.jl b/base/docs/bootstrap.jl index 223b6cfed07a3a..c39e81210fca49 100644 --- a/base/docs/bootstrap.jl +++ b/base/docs/bootstrap.jl @@ -11,13 +11,18 @@ _expand_ = nothing setexpand!(f) = global _expand_ = f macro doc(args...) - _expand_(args...) + _expand_(args...) end setexpand!() do str, obj - # str, obj = ex.args[1], ex.args[2] - push!(docs, (current_module(), str, obj)) - return esc(obj) + push!(docs, (current_module(), str, obj)) + return esc(obj) +end + +function loaddocs() + for (mod, str, obj) in docs + eval(mod, :(Base.@doc($str, $obj, false))) + end end end diff --git a/base/markdown/Julia/Julia.jl b/base/markdown/Julia/Julia.jl index f6209296d92e96..feaa28db916fab 100644 --- a/base/markdown/Julia/Julia.jl +++ b/base/markdown/Julia/Julia.jl @@ -1,11 +1,9 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license -""" -This file contains markdown extensions designed to make documenting -Julia easy peasy. - -We start by borrowing GitHub's `fencedcode` extension – more to follow. -""" +# This file contains markdown extensions designed to make documenting +# Julia easy peasy. +# +# We start by borrowing GitHub's `fencedcode` extension – more to follow. include("interp.jl")