-
Notifications
You must be signed in to change notification settings - Fork 15
separate Method/Function docstrings #30
Comments
Actually, re-reading the docile manual, it seems to imply that this is already possible, but I can't see what the syntax is. What am I missing? |
Yes, it is currently possible to do this though perhaps better documentation on my part is in order. For methods it's @doc "specific implementation of sum" ->
sum(x::MyArrayType) = # ... Function specific documentation has to appear after the first definition # some definitions of sum above
@doc "sums the elements of `x`" ->
sum I've found it slightly inconvenient to have to have the generic documentation appear |
Ah, I see. Couldn't you use |
That seems quite reasonable to me. I'll have a look at doing that later today. |
Having a look at the dumps from these, it looks like it'll be simple enough to add: julia> dump(quote
@doc* """
Markdown formatted text goes here...
""" ->
function myfunc(x, y)
x + y
end
end)
Expr
head: Symbol block
args: Array(Any,(2,))
1: Expr
head: Symbol line
args: Array(Any,(2,))
1: Int64 3
2: Symbol none
typ: Any
2: Expr
head: Symbol macrocall
args: Array(Any,(3,))
1: Symbol @doc
2: Symbol *
3: Expr
head: Symbol ->
args: Array(Any,(2,))
typ: Any
typ: Any
typ: Any
julia> dump(quote
@doc """
Markdown formatted text goes here...
""" ->
function myfunc(x, y)
x + y
end
end)
Expr
head: Symbol block
args: Array(Any,(2,))
1: Expr
head: Symbol line
args: Array(Any,(2,))
1: Int64 3
2: Symbol none
typ: Any
2: Expr
head: Symbol macrocall
args: Array(Any,(2,))
1: Symbol @doc
2: Expr
head: Symbol ->
args: Array(Any,(2,))
typ: Any
typ: Any
typ: Any The only difference being the |
One of the unique features of Julia is the existence of multiple implementations of a given method. Because of that, we really need two types of function documentation:
sum(x)
might have generic documentation for the fact that it sums the elements ofx
, although there are many more specialized methods for this. My suggestion would be to attach this to theFunction
object.Method
object (you get a list of these frommethods(foo)
)Possible syntax:
or other possibilities could be devised, of course.
The text was updated successfully, but these errors were encountered: