-
Notifications
You must be signed in to change notification settings - Fork 547
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
fix: cairo-doc parser extraction of comment from doc line #7026
fix: cairo-doc parser extraction of comment from doc line #7026
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 4 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @cairoIover, @orizi, and @wawel37)
crates/cairo-lang-doc/src/db.rs
line 404 at r2 (raw file):
// block, instead of assuming just one space. // Require a space after the marker (e.g. "/// " or "//! ") if let Some(content) = dedent.strip_prefix(&format!("{} ", comment_marker)) {
I just thought about this and I realised my suggestion how to solve this in the issue was actually wrong. This code forbids the following, which although looks bad is not wrong thing to be honest:
///A thing.
///
///Notice no space.
fn foo() {}
I've verified and this is picked up by rustdoc. So the logic must probably be more sophisticated. Maybe strip the marker and strip whitespace as we did, but reject lines that start with /
? @wawel37 wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mkaput and @orizi)
crates/cairo-lang-doc/src/db.rs
line 404 at r2 (raw file):
Previously, mkaput (Marek Kaput) wrote…
I just thought about this and I realised my suggestion how to solve this in the issue was actually wrong. This code forbids the following, which although looks bad is not wrong thing to be honest:
///A thing. /// ///Notice no space. fn foo() {}
I've verified and this is picked up by rustdoc. So the logic must probably be more sophisticated. Maybe strip the marker and strip whitespace as we did, but reject lines that start with
/
? @wawel37 wdyt?
That's right, this one should be working as it would be working with a whitespace:
///Example doc comment that works as comment below
/// A comment with assumption that there's always a whitespace between a prefix and the actual comment.
When it comes to the solution that excludes just the lines that start with /
after the prefix is not that perfect imho. Correct me if I am wrong, but I've seen also comment line separators like
///==============
/// Actual comment
///==============
///############
/// Another example
///############
and so on.
I've also checked how it's handled by cargo doc
, and it works exactly as @mkaput mentioned. Only lines that start with /
after the marker are being ignored. Like like:
///==============
///--------------
///##############
are still being extracted.
In conclusion:
Imo @mkaput is right and we should just ignore lines with /
right after the marker and let the user write such docs:
///No space comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mkaput and @orizi)
crates/cairo-lang-doc/src/db.rs
line 404 at r2 (raw file):
Previously, wawel37 (Mateusz Kowalski) wrote…
That's right, this one should be working as it would be working with a whitespace:
///Example doc comment that works as comment below /// A comment with assumption that there's always a whitespace between a prefix and the actual comment.
When it comes to the solution that excludes just the lines that start with
/
after the prefix is not that perfect imho. Correct me if I am wrong, but I've seen also comment line separators like///============== /// Actual comment ///============== ///############ /// Another example ///############
and so on.
I've also checked how it's handled by
cargo doc
, and it works exactly as @mkaput mentioned. Only lines that start with/
after the marker are being ignored. Like like:///============== ///-------------- ///##############
are still being extracted.
In conclusion:
Imo @mkaput is right and we should just ignore lines with/
right after the marker and let the user write such docs:///No space comment
also FYI:
//!#############################
This kind of comment results in an error when using cargo doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi and @wawel37)
crates/cairo-lang-doc/src/db.rs
line 404 at r2 (raw file):
Previously, wawel37 (Mateusz Kowalski) wrote…
also FYI:
//!#############################
This kind of comment results in an error when using
cargo doc
hmm, important case to also consider. no idea what should happen here (feel free to copy rustdoc):
/// This is a documentation block.
///
/// This is some summary, wait for this:
/////////////////////////////////////////////////
/// BANG!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 4 files reviewed, 1 unresolved discussion (waiting on @mkaput and @orizi)
crates/cairo-lang-doc/src/db.rs
line 404 at r2 (raw file):
Previously, mkaput (Marek Kaput) wrote…
hmm, important case to also consider. no idea what should happen here (feel free to copy rustdoc):
/// This is a documentation block. /// /// This is some summary, wait for this: ///////////////////////////////////////////////// /// BANG!
Done.
New logic is: don't count a comment line that starts with a /
as a valid comment line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @orizi)
crates/cairo-lang-doc/src/db.rs
line 404 at r2 (raw file):
Previously, cairoIover wrote…
Done.
New logic is: don't count a comment line that starts with a
/
as a valid comment line.
Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @orizi)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @cairoIover)
Closes #7014
cc @mkaput for review