diff --git a/doc/src/manual/documentation.md b/doc/src/manual/documentation.md index ce76c55bd013e..aa58e5b600f49 100644 --- a/doc/src/manual/documentation.md +++ b/doc/src/manual/documentation.md @@ -81,6 +81,35 @@ As in the example above, we recommend following some simple conventions when wri accepts many keyword arguments, only include a `` placeholder in the signature (i.e. `f(x; )`), 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.