Skip to content

Commit

Permalink
Load bootstrapped docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly committed Aug 5, 2015
1 parent 002cea8 commit 8bba4b7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
33 changes: 19 additions & 14 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ 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))
doc!($f, $m, $(mdify(meta)), $(esc(quot(def))))
doc!($f, $m, $(mdify(meta)), $(esc(quot(def))))
$f
end
end
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -334,6 +337,8 @@ Base.DocBootstrap.setexpand!(docm)

eval(Base.DocBootstrap, :(import ..Docs: @init, doc!, doc, @doc_str))

Base.DocBootstrap.loaddocs()

# Metametadata

"""
Expand Down
13 changes: 9 additions & 4 deletions base/docs/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 4 additions & 6 deletions base/markdown/Julia/Julia.jl
Original file line number Diff line number Diff line change
@@ -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")

Expand Down

0 comments on commit 8bba4b7

Please sign in to comment.