9
9
10
10
## Available types of comments
11
11
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).
13
25
14
26
## mdBook
15
27
@@ -25,7 +37,11 @@ Requirements:
25
37
Let's take, for example, a simple Cairo project initalized using ` scarb new ` . Let's change the code inside ` lib.cairo ` to:
26
38
27
39
```` 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]
29
45
enum ExampleEnum {
30
46
/// First enum variant.
31
47
VARIANT_A,
@@ -38,7 +54,9 @@ struct ExampleStruct {
38
54
/// Private field.
39
55
field_a: felt252,
40
56
/// Public field.
41
- pub field_b: felt252
57
+ pub field_b: felt252,
58
+ /// [`ExampleEnum`] field
59
+ field_c: ExampleEnum
42
60
}
43
61
44
62
/// Function that prints "test" to stdout with endline.
@@ -53,8 +71,11 @@ fn test() {
53
71
}
54
72
55
73
/// Main function that Cairo runs as a binary entrypoint.
74
+ /// This function uses [test] function.
56
75
fn main() {
76
+ //! This is an inner comment. It refers to it's parent which is the main function.
57
77
println!("hello_world");
78
+ test();
58
79
}
59
80
````
60
81
0 commit comments