-
Notifications
You must be signed in to change notification settings - Fork 6
Documentation guidelines #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,162 @@ | ||||||||||
| # Code Documentation | ||||||||||
|
|
||||||||||
| The standard library documentation is written in a "code-first" style. This | ||||||||||
| means all necessary comments and descriptions are embedded directly in the | ||||||||||
| code, and a specialized tool generates the appropriate documentation pages | ||||||||||
| from the code. | ||||||||||
|
|
||||||||||
| ## Documentation format | ||||||||||
|
|
||||||||||
| Documentation comments—also referred to as docstrings—can be either single-line | ||||||||||
| or multi-line. They always begin with a double `##` symbol and must start in | ||||||||||
| the first column of an empty line. | ||||||||||
|
|
||||||||||
| The body of the docstring supports Markdown formatting. Markdown headers are | ||||||||||
| usually written using single-line comments. The body of a block docstring is | ||||||||||
| either written inline or starts on the next line, indented with 2 spaces. The | ||||||||||
| closing marker of a multiline comment can appear either on a separate line or | ||||||||||
| immediately after the final line of the docstring body. | ||||||||||
|
|
||||||||||
| During the process of generting doc pages, all docstring are concatenated | ||||||||||
wojpok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| to a single, continuous markdown file. Even though it is possible, we advise | ||||||||||
| against splitting markdown constructs like tables across multiple docstring. | ||||||||||
wojpok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| For example: | ||||||||||
|
|
||||||||||
| ``` | ||||||||||
| ## # Main header | ||||||||||
|
|
||||||||||
| {## | ||||||||||
| This is an example docstring with markdown table: | ||||||||||
wojpok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| | Column 1 | Column 2 | | ||||||||||
| | -------- | -------- | | ||||||||||
| | 10 | abc | | ||||||||||
| | 20 | def | | ||||||||||
|
|
||||||||||
| End of docstring. | ||||||||||
| ##} | ||||||||||
|
|
||||||||||
| {## | ||||||||||
| Another docstring with inlined closing sign. ##} | ||||||||||
|
|
||||||||||
| {## This is valid too. ##} | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ### Definition documentation | ||||||||||
|
|
||||||||||
| When a docstring is immediately followed by a code definition, it is attached | ||||||||||
| to that definition. The first continuous block of text is treated as a brief | ||||||||||
| description. After an empty line, a more detailed explanation may be added. | ||||||||||
|
|
||||||||||
| Additionally `@param`, `@asserts` and `@return` labels are supported in | ||||||||||
wojpok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| functions' and methods' docstrings. These must be placed after the brief | ||||||||||
| description. | ||||||||||
|
|
||||||||||
| The `@param` label is followed by a parameter name and may include an optional | ||||||||||
| description. Optional and implicit parameters must be prefixed with `~` or `?`, | ||||||||||
| just as in code. Unnamed parameters cannot be documented. | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does unnamed mean positional here? We code be more precise.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. It refers to arguments in point-free style. For example function
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also wildcards may disqualify |
||||||||||
|
|
||||||||||
| The `@asserts` label indicates that the function may raise a runtime error and | ||||||||||
| terminate program execution. You may add a description explaining under what | ||||||||||
| conditions this occurs. | ||||||||||
|
|
||||||||||
| The `@returns` label describes the result produced by the function. | ||||||||||
|
|
||||||||||
| ### Scopes | ||||||||||
|
|
||||||||||
| Sometimes, the natural flow of documentation is disrupted—such as when type | ||||||||||
| definitions, methods, or helper functions are declared elsewhere for structural | ||||||||||
| or organizational reasons. In such cases, attaching a docstring directly above | ||||||||||
| the definition isn't possible or desirable. To address this, documentation can | ||||||||||
| be written separately and explicitly linked to the intended code element using | ||||||||||
| an identifier. | ||||||||||
|
|
||||||||||
| In such cases, docstrings are mandatorily multiline and apropriete identifiers | ||||||||||
wojpok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| are written in the same line as the comments' opening markers. | ||||||||||
|
|
||||||||||
| Supported identifiers include: | ||||||||||
| - `@data Name` - ADTs and records | ||||||||||
| - `@type Name`- Builtin types and type synonyms | ||||||||||
|
Comment on lines
+79
to
+80
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason to distinguish between them. The use the same namespace, so
|
||||||||||
| - `@type Name`- Builtin types and type synonyms | |
| - `@type Name` - Builtin types and type synonyms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it for parameter declarations? The documentation should be more specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a separate @handler opening marker? As effect capabilities are first class, we can use @val.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really recall logic behind this. I think you are right, it can be deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to see an example here.
wojpok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
wojpok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
wojpok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: "behavoiur" should be "behaviour" (or "behavior" in American English).
| - When optional parameters are involved, describe default behavoiur | |
| - When optional parameters are involved, describe default behaviour |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: "explicitely" should be "explicitly".
| explicitely. | |
| explicitly. |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: "can not" should be "cannot" (one word when expressing inability).
| - Doc lines, just as code, can not exceed width of 80 characters. | |
| - Doc lines, just as code, cannot exceed width of 80 characters. |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: "Remeber" should be "Remember".
| *Remeber, do not plagiariase!* | |
| *Remember, do not plagiariase!* |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: "plagiariase" should be "plagiarize" (or "plagiarise" in British English).
| *Remeber, do not plagiariase!* | |
| *Remember, do not plagiarize!* |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammatical issue: remove "the" before "there" - should be "which means that there is".
| `Int64` is a builtin type, which means that the there is no declaration | |
| `Int64` is a builtin type, which means that there is no declaration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This contradicts with what is said for constructor documentation. I think, the
##should be indented to the same column as the documented entity.Moreover, it should be clear that a docstring starts with
##or{##(from what is said, it is not clear how to start multiline docstring).