Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

Commit

Permalink
Add support for 'function <name> end' syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly committed May 26, 2015
1 parent 4a8a182 commit 185a9c5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Collector/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ getcategory(x) =
isalias(x) ? :typealias :
isglobal(x) ? :global :
issymbol(x) ? :symbol :
isfunc(x) ? :symbol :
istuple(x) ? :tuple :
isvcat(x) ? :vcat :
isvect(x) ? :vect :
Expand All @@ -135,6 +136,7 @@ skipexpr(x) =

ismethod(x) = isexpr(x, [:function, :(=)]) && isexpr(x.args[1], :call)
isglobal(x) = isexpr(x, [:global, :const, :(=)]) && !isexpr(x.args[1], :call)
isfunc(x) = isexpr(x, :function) && isa(x.args[1], Symbol)
istype(x) = isexpr(x, [:type, :abstract])
isconcretetype(x) = isexpr(x, :type)
isalias(x) = isexpr(x, :typealias)
Expand Down Expand Up @@ -192,6 +194,7 @@ isdocumentable(ex) =
isalias(ex) ||
isglobal(ex) ||
issymbol(ex) ||
isfunc(ex) ||
isquote(ex) ||
ismacrocall(ex) ||
istuple(ex) ||
Expand Down
11 changes: 11 additions & 0 deletions test/Collector/FunctionSyntax/FunctionSyntax.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module FunctionSyntax

"f_1"
function f_1 end

"""
f_2
"""
function f_2 end

end
28 changes: 28 additions & 0 deletions test/Collector/facts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,31 @@ facts("Base") do
end

end

## 'function <name> end' syntax tests. ##

if VERSION >= v"0.4-dev+4989"
require(joinpath(dirname(@__FILE__), "FunctionSyntax", "FunctionSyntax.jl"))
import FunctionSyntax

facts("Function Syntax.") do
metadata = Docile.Interface.metadata(FunctionSyntax)
entries = Docile.Interface.entries(metadata)

@fact length(entries) => 2

@fact Docile.Interface.metadata(metadata) => @compat(
Dict{Symbol, Any}(
:format => :md,
:exports => Set([:FunctionSyntax]),
:manual => UTF8String[]
)
)

@fact rawdocs(entries, FunctionSyntax.f_1) => "f_1"
@fact rawdocs(entries, FunctionSyntax.f_2) => "f_2\n"

@fact docsmeta(entries, :category, FunctionSyntax.f_1) => :function
@fact docsmeta(entries, :category, FunctionSyntax.f_2) => :function
end
end

0 comments on commit 185a9c5

Please sign in to comment.