-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cairo-doc parser extraction of comment from doc line (#7026)
- Loading branch information
1 parent
74b6ec2
commit 9ac17df
Showing
3 changed files
with
103 additions
and
1 deletion.
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
97 changes: 97 additions & 0 deletions
97
crates/cairo-lang-doc/src/tests/test-data/comment_markers.txt
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,97 @@ | ||
//! > Test for proper handling of comment markers | ||
|
||
//! > test_runner_name | ||
documentation_test_runner | ||
|
||
//! > cairo_project.toml | ||
[crate_roots] | ||
hello = "src" | ||
|
||
//! > cairo_code | ||
trait T { | ||
///////////////////////////////////////////////////////////////////////// | ||
// Transforming contained values | ||
///////////////////////////////////////////////////////////////////////// | ||
|
||
/// Maps an `Option<T>` to `Option<U>` by applying a function to a contained value (if `Some`) | ||
/// or returns `Option::None` (if `None`). | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// let maybe_some_string: Option<ByteArray> = Option::Some("Hello, World!"); | ||
/// // `Option::map` takes self *by value*, consuming `maybe_some_string` | ||
/// let maybe_some_len = maybe_some_string.map(|s: ByteArray| s.len()); | ||
/// assert!(maybe_some_len == Option::Some(13)); | ||
/// | ||
/// let x: Option<ByteArray> = Option::None; | ||
/// assert!(x.map(|s: ByteArray| s.len()) == Option::None); | ||
/// ``` | ||
fn map<U, F, +Destruct<F>, +core::ops::FnOnce<F, (T,)>[Output: U]>( | ||
self: Option<T>, f: F, | ||
) -> Option<U>; | ||
} | ||
|
||
//! > expected_item_0 | ||
Maps an `Option<T>` to `Option<U>` by applying a function to a contained value (if `Some`) or returns `Option::None` (if `None`). | ||
|
||
# Examples | ||
|
||
``` | ||
let maybe_some_string: Option<ByteArray> = Option::Some("Hello, World!"); | ||
// `Option::map` takes self *by value*, consuming `maybe_some_string` | ||
let maybe_some_len = maybe_some_string.map(|s: ByteArray| s.len()); | ||
assert!(maybe_some_len == Option::Some(13)); | ||
|
||
let x: Option<ByteArray> = Option::None; | ||
assert!(x.map(|s: ByteArray| s.len()) == Option::None); | ||
``` | ||
|
||
//! > expected_signature_0 | ||
fn map<U, F, +Destruct<F>, +core::ops::FnOnce<F, (T,)>[Output: U]>(self: Option<T>, f: F) -> Option<U> | ||
|
||
//! > Item signature #1 | ||
|
||
//! > Item documentation #1 | ||
|
||
//! > Item documentation tokens #1 | ||
|
||
//! > Item signature #2 | ||
trait T | ||
|
||
//! > Item documentation #2 | ||
|
||
//! > Item documentation tokens #2 | ||
|
||
//! > Item signature #3 | ||
fn map<U, F, +Destruct<F>, +core::ops::FnOnce<F, (T,)>[Output: U]>( | ||
self: Option<T>, f: F, | ||
) -> Option<U> | ||
|
||
//! > Item documentation #3 | ||
Maps an `Option<T>` to `Option<U>` by applying a function to a contained value (if `Some`) or returns `Option::None` (if `None`). # Examples | ||
```cairo | ||
let maybe_some_string: Option<ByteArray> = Option::Some("Hello, World!"); | ||
// `Option::map` takes self *by value*, consuming `maybe_some_string` | ||
let maybe_some_len = maybe_some_string.map(|s: ByteArray| s.len()); | ||
assert!(maybe_some_len == Option::Some(13)); | ||
|
||
let x: Option<ByteArray> = Option::None; | ||
assert!(x.map(|s: ByteArray| s.len()) == Option::None); | ||
``` | ||
|
||
//! > Item documentation tokens #3 | ||
Content("Maps an ") | ||
Content("`Option<T>`") | ||
Content(" to ") | ||
Content("`Option<U>`") | ||
Content(" by applying a function to a contained value (if ") | ||
Content("`Some`") | ||
Content(") or returns ") | ||
Content("`Option::None`") | ||
Content(" (if ") | ||
Content("`None`") | ||
Content("). # Examples") | ||
Content("\n```cairo\n") | ||
Content("let maybe_some_string: Option<ByteArray> = Option::Some(\"Hello, World!\");\n// `Option::map` takes self *by value*, consuming `maybe_some_string`\nlet maybe_some_len = maybe_some_string.map(|s: ByteArray| s.len());\nassert!(maybe_some_len == Option::Some(13));\n\nlet x: Option<ByteArray> = Option::None;\nassert!(x.map(|s: ByteArray| s.len()) == Option::None);\n") | ||
Content("```") |
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