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 4, 2015
1 parent 002cea8 commit 9bf49b9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
42 changes: 25 additions & 17 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,47 +243,54 @@ function mdify(ex)
end
end

function namedoc(meta, def, name)
function namedoc(meta, def, name, define)
quote
@init
$(esc(def))
$(define ? esc(def) : nothing)
doc!($(esc(name)), $(mdify(meta)))
nothing
end
end

function funcdoc(meta, def)
f = esc(namify(def))
function funcdoc(meta, def, name, define)
f = esc(name)
m = :(which($f, $(esc(signature(def)))))
quote
@init
$(esc(def))
$(define ? esc(def) : nothing)
doc!($f, $m, $(mdify(meta)), $(esc(quot(def))))
$f
end
end

function typedoc(meta, def, name)
function typedoc(meta, def, name, define)
quote
@init
$(esc(def))
$(define ? esc(def) : nothing)
doc!($(esc(name)), $(mdify(meta)), $(field_meta(unblock(def))))
nothing
end
end

function vardoc(meta, def, name, define)
quote
@init
$(define ? esc(def) : nothing)
doc!($(esc(name)), $(mdify(meta)))
$(esc(name))
end
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 +308,13 @@ 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′)
isexpr(def′, :macro) && return namedoc(meta, def, symbol("@", namify(def′)), define)
isexpr(def′, :type) && return typedoc(meta, def, namify(def′.args[2]), define)
isexpr(def′, :bitstype) && return namedoc(meta, def, def′.args[2], define)
isexpr(def′, :abstract) && return namedoc(meta, def, namify(def′), define)
isexpr(def′, :module) && return namedoc(meta, def, def′.args[2], define)
fexpr(def′) && return funcdoc(meta, def′, namify(def′), define)
isexpr(def′, :(=), :const) && return vardoc(meta, def′, namify(def′), define)
isexpr(def′, :macrocall) && (def = namify(def′))
return objdoc(meta, def)
end
Expand Down
2 changes: 2 additions & 0 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

DocBootstrap.loaddocs()

import .Docs: keywords

keywords[:hello] = keywords[:hi] = doc"Hello, Human."
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 9bf49b9

Please sign in to comment.