-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* doc(refactor): moving view as topic of operator * doc(refactor): split huge document into different parts * doc(refactor): move topics around
- Loading branch information
1 parent
a69cdb7
commit 39bffd1
Showing
9 changed files
with
1,065 additions
and
1,053 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Documentation | ||
|
||
## Doc Comments | ||
|
||
Doc comments are comments prefix with `///` in each line in the leading of toplevel structure like `fn`,`let`,`enum`,`struct`,`type`. The doc comments contains a markdown text and several pragmas. | ||
|
||
```{literalinclude} /sources/language/src/misc/top.mbt | ||
:language: moonbit | ||
:start-after: start doc string 1 | ||
:end-before: end doc string 1 | ||
``` | ||
|
||
### Pragmas | ||
|
||
Pragmas are annotations inside doc comments. They all take the form `/// @word ...`. The _word_ indicates the type of pragma and is followed optionally by several _word_ or string literals. Pragmas do not normally affect the meaning of programs. Unrecognized pragmas will be reported as warnings. | ||
|
||
- Alert Pragmas | ||
|
||
Alert pragmas in doc comments of functions will be reported when those functions are referenced. This mechanism is a generalized way to mark functions as `deprecated` or `unsafe`. | ||
|
||
It takes the form `@alert category "alert message..."`. | ||
|
||
The category can be an arbitrary identifier. It allows configuration to decide which alerts are enabled or turned into errors. | ||
|
||
<!-- MANUAL CHECK --> | ||
```moonbit | ||
/// @alert deprecated "Use foo2 instead" | ||
pub fn foo() -> Unit { | ||
... | ||
} | ||
/// @alert unsafe "Div will cause an error when y is zero" | ||
pub fn div(x : Int, y : Int) -> Int { | ||
... | ||
} | ||
test { | ||
// Warning (Alert deprecated): Use foo2 instead | ||
foo() | ||
// Warning (Alert unsafe): Div will cause an error when y is zero | ||
div(1, 2) |> ignore | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.