Skip to content

Conversation

@CreeptoGengar
Copy link

Fix incorrect indentation handling in documentation comment extraction.
The previous implementation only removed a single space after comment markers, which caused issues with multi-line comments having varying indentation levels.
Now the code finds the minimum common indentation across all lines in a comment block and removes it uniformly, preserving
relative alignment within the block.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @CreeptoGengar)


a discussion (no related file):
would suggest adding a test to show the improvement.

@CreeptoGengar
Copy link
Author

Added a test case for the indentation fix.
It covers multi-line doc comments with varying indentation levels and verifies that the minimum common indentation is correctly removed while preserving relative alignment between lines.

@CreeptoGengar CreeptoGengar requested a review from orizi December 7, 2025 11:01
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed all commit messages.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @CreeptoGengar and @FroyaTheHen)


a discussion (no related file):
@FroyaTheHen

Copy link
Collaborator

@FroyaTheHen FroyaTheHen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @CreeptoGengar and @orizi)


crates/cairo-lang-doc/src/tests/test-data/indentation.txt line 1 at r2 (raw file):

//! > Documentation

Can you please add a test case that would have failed before but now passes?


crates/cairo-lang-doc/src/tests/test-data/indentation.txt line 43 at r2 (raw file):

This line has extra indentation.
This line has less indentation.
Another indented line.

I understand that the behaviour expected from those changes would be to preserve the indentation in a way that would remove the number of leading whitespaces common to all the comment lines. (Please argue otherwise if you do not agree.) Although the test shows all of the leading whitespaces are removed. Isn't the expected 👇 ??

Suggestion:

//! > Item documentation #2
Function with multi-line doc comment.
    This line has extra indentation.
  This line has less indentation.
    Another indented line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants