Skip to content

all: add starred-block comment style, improve comment parsing #12

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

joshuasing
Copy link
Owner

Improve comment parsing and remove unnecessary scan to detect comment
style prior to parsing. This also adds a "starred-block" comment style,
as it is used by some projects.

Additionally, add functionality to detect and entirely ignore directive
comments when detecting an existing header comment, to prevent build
directive comments from being overridden/replaced.

@joshuasing joshuasing added type: refactor This improves existing functionality type: feature This is a new feature labels Apr 20, 2025
@joshuasing joshuasing changed the title all: add starred-block comment style, improve parsing all: add starred-block comment style, improve comment parsing Apr 20, 2025
Improve comment parsing and remove unnecessary scan to detect comment
style prior to parsing. This also adds a "starred-block" comment style,
as it is used by some projects.

Additionally, add functionality to detect and entirely ignore directive
comments when detecting an existing header comment, to prevent build
directive comments from being overriden/replaced.
header = cs.Parse(header)
header, cs, err := parseComment(header)
if err != nil {
return "", false, fmt.Errorf("parse header comment: %w", err)
Copy link
Owner Author

@joshuasing joshuasing Apr 20, 2025

Choose a reason for hiding this comment

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

We should ideally never fail to lint ever, so instead of failing here, if we can't parse the comment I think it makes sense to either ignore the file or generate a new header instead.

The only reason to fail should be bad user input or an error from a template, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature This is a new feature type: refactor This improves existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant