Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions doc/src/manual/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,35 @@ As in the example above, we recommend following some simple conventions when wri
accepts many keyword arguments, only include a `<keyword arguments>` placeholder in the signature
(i.e. `f(x; <keyword arguments>)`), and give the complete list under an `# Arguments` section
(see point 4 below).

Use this style to document the return type or give the return value a name:

```julia
# Naming the return value or its type is not necessary (this is the most common case)
"""
sum(itr; [init])

...
"""

# The return type is easily documented and critical to the semantics of this function
"""
vec(x::AbstractArray)::AbstractVector

...
"""

# Naming and/or destructuring the return value clarifies the semantics of this function
"""
splitdir(path::AbstractString) -> (dir::AbstractString, file::AbstractString)
...
"""
```
When included, a return type should be written after the signature, separated by `::`,
while a named return value should be separated by ` -> `, with a space on both sides.
Return types and return values should be valid Julia expressions when possible.
Macro docstring signatures that annotate return types or return values should use
parentheses to clarify where the macro arguments end and return type or return value begins.
2. Include a single one-line sentence describing what the function does or what the object represents
after the simplified signature block. If needed, provide more details in a second paragraph, after
a blank line.
Expand Down