Skip to content

Commit

Permalink
Add linkage docs to scarb doc (#1802)
Browse files Browse the repository at this point in the history
# Important!

Don't deploy it yet
  • Loading branch information
wawel37 authored Dec 3, 2024
1 parent c3c8e7f commit e49c94c
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions website/docs/extensions/documentation-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@

## Available types of comments

As for now, only the `///` comment prefix is supported.
As for now, we support those types of comments:

- `///` documentation for following item.
- `//!` documentation for enclosing item (also works with file modules).

the `///` and `//!` comment prefixes are supported.

## Item linkage

You can also link to another item's page by just refering the item within the documentation comment.
Currenctly we support only those types of links:

- `[ItemName]` and ``[`ItemName`]`` (where `ItemName` is a valid path to an item).

## mdBook

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

````cairo
/// Example Enum.
//! This module is an example one.
//! It tries to show how documentation comments work.
/// Example Enum. It's really similar to [ExampleStruct]
enum ExampleEnum {
/// First enum variant.
VARIANT_A,
Expand All @@ -38,7 +54,9 @@ struct ExampleStruct {
/// Private field.
field_a: felt252,
/// Public field.
pub field_b: felt252
pub field_b: felt252,
/// [`ExampleEnum`] field
field_c: ExampleEnum
}
/// Function that prints "test" to stdout with endline.
Expand All @@ -53,8 +71,11 @@ fn test() {
}
/// Main function that Cairo runs as a binary entrypoint.
/// This function uses [test] function.
fn main() {
//! This is an inner comment. It refers to it's parent which is the main function.
println!("hello_world");
test();
}
````

Expand Down

0 comments on commit e49c94c

Please sign in to comment.