From 9db43753bfcbb65ec99e239f007e8130b02a9ef1 Mon Sep 17 00:00:00 2001 From: Michael Hatherly Date: Fri, 11 Sep 2015 15:13:30 +0200 Subject: [PATCH] Fix macro summary display Macros were being listed as anonymous functions in docs summary. --- base/docs/Docs.jl | 12 ++++++------ test/docs.jl | 10 +++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index f248acecdba44..c5610089d4033 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -148,18 +148,18 @@ function doc(b::Binding) v = getfield(b.mod,b.var) d = doc(v) if d === nothing - if isa(v,Function) + if startswith(string(b.var),'@') + # check to see if the binding var is a macro d = catdoc(Markdown.parse(""" No documentation found. - `$(b.mod === Main ? b.var : join((b.mod, b.var),'.'))` is $(isgeneric(v) ? "a generic" : "an anonymous") `Function`. - """), functionsummary(v)) - elseif startswith(string(b.var),'@') - # check to see if the binding var is a macro + """), macrosummary(b.var, v)) + elseif isa(v,Function) d = catdoc(Markdown.parse(""" No documentation found. - """), macrosummary(b.var, v)) + `$(b.mod === Main ? b.var : join((b.mod, b.var),'.'))` is $(isgeneric(v) ? "a generic" : "an anonymous") `Function`. + """), functionsummary(v)) else T = typeof(v) d = catdoc(Markdown.parse(""" diff --git a/test/docs.jl b/test/docs.jl index 8f6d15b189550..d6aa7a0f11a88 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -241,9 +241,13 @@ end @doc "This should document @m1... since its the result of expansion" @m2_11993 @test (@doc @m1_11993) !== nothing let d = (@doc @m2_11993) - io = IOBuffer() - writemime(io, MIME"text/markdown"(), d) - @test startswith(takebuf_string(io),"No documentation found") + @test docstrings_equal(d, doc""" + No documentation found. + + ```julia + @m2_11993() + ``` + """) end @doc "Now @m2... should be documented" :@m2_11993