Skip to content

Commit

Permalink
Add signatures to docstring examples in the manual
Browse files Browse the repository at this point in the history
These examples did not follow the guidelines given in the rest
of the page. Also mark a few code blocks as being Julia code.
  • Loading branch information
nalimilan committed Dec 19, 2016
1 parent c604d05 commit f82d5b8
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions doc/src/manual/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ The basic syntax is very simple: any string appearing at the top-level right bef
(function, macro, type or instance) will be interpreted as documenting it (these are called *docstrings*).
Here is a very simple example:

```
"Tell whether there are too foo items in the array."
```julia
"""
foo(xs::Array)
Tell whether there are too foo items in the array `xs`.
"""
foo(xs::Array) = ...
```

Expand Down Expand Up @@ -138,7 +142,7 @@ As in the example above, we recommend following some simple conventions when wri

That is, write:

```
```julia
"""
...
Expand All @@ -149,7 +153,7 @@ As in the example above, we recommend following some simple conventions when wri

rather than:

```
```julia
"""...
..."""
Expand Down Expand Up @@ -185,25 +189,37 @@ itself (i.e. the object created without any methods by `function bar end`). Spec
only be documented if their behaviour differs from the more generic ones. In any case, they should
not repeat the information provided elsewhere. For example:

```
```julia
"""
*(x, y, z...)
Multiplication operator. `x*y*z*...` calls this function with multiple
arguments, i.e. `*(x,y,z...)`.
"""
function *(x, y)
# ... [implementation sold separately] ...
function *(x, y, z...)
# ... [implementation sold separately] ...
end

"When applied to strings, concatenates them."
function *(x::AbstractString, y::AbstractString)
# ... [insert secret sauce here] ...
"""
*(x::AbstractString, y::AbstractString, z::AbstractString...)
When applied to strings, concatenates them.
"""
function *(x::AbstractString, y::AbstractString, z::AbstractString...)
# ... [insert secret sauce here] ...
end

help?>*
Multiplication operator. `x*y*z*...` calls this function with multiple
arguments, i.e. `*(x,y,z...)`.
help?> *
search: * .*

When applied to strings, concatenates them.
*(x, y, z...)

Multiplication operator. x*y*z*... calls this function with multiple
arguments, i.e. *(x,y,z...).

*(x::AbstractString, y::AbstractString, z::AbstractString...)

When applied to strings, concatenates them.
```

When retrieving documentation for a generic function, the metadata for each method is concatenated
Expand Down

0 comments on commit f82d5b8

Please sign in to comment.