Skip to content

Commit e49c94c

Browse files
authored
Add linkage docs to scarb doc (#1802)
# Important! Don't deploy it yet
1 parent c3c8e7f commit e49c94c

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

website/docs/extensions/documentation-generation.md

+24-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@
99

1010
## Available types of comments
1111

12-
As for now, only the `///` comment prefix is supported.
12+
As for now, we support those types of comments:
13+
14+
- `///` documentation for following item.
15+
- `//!` documentation for enclosing item (also works with file modules).
16+
17+
the `///` and `//!` comment prefixes are supported.
18+
19+
## Item linkage
20+
21+
You can also link to another item's page by just refering the item within the documentation comment.
22+
Currenctly we support only those types of links:
23+
24+
- `[ItemName]` and ``[`ItemName`]`` (where `ItemName` is a valid path to an item).
1325

1426
## mdBook
1527

@@ -25,7 +37,11 @@ Requirements:
2537
Let's take, for example, a simple Cairo project initalized using `scarb new`. Let's change the code inside `lib.cairo` to:
2638

2739
````cairo
28-
/// Example Enum.
40+
//! This module is an example one.
41+
//! It tries to show how documentation comments work.
42+
43+
44+
/// Example Enum. It's really similar to [ExampleStruct]
2945
enum ExampleEnum {
3046
/// First enum variant.
3147
VARIANT_A,
@@ -38,7 +54,9 @@ struct ExampleStruct {
3854
/// Private field.
3955
field_a: felt252,
4056
/// Public field.
41-
pub field_b: felt252
57+
pub field_b: felt252,
58+
/// [`ExampleEnum`] field
59+
field_c: ExampleEnum
4260
}
4361
4462
/// Function that prints "test" to stdout with endline.
@@ -53,8 +71,11 @@ fn test() {
5371
}
5472
5573
/// Main function that Cairo runs as a binary entrypoint.
74+
/// This function uses [test] function.
5675
fn main() {
76+
//! This is an inner comment. It refers to it's parent which is the main function.
5777
println!("hello_world");
78+
test();
5879
}
5980
````
6081

0 commit comments

Comments
 (0)