Skip to content
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

Add linkage docs to scarb doc #1802

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading