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

Differentiate documentation from triple slashes and doc attribute #3196

Open
MajoraSans opened this issue Oct 14, 2024 · 1 comment · May be fixed by #3209
Open

Differentiate documentation from triple slashes and doc attribute #3196

MajoraSans opened this issue Oct 14, 2024 · 1 comment · May be fixed by #3209
Assignees

Comments

@MajoraSans
Copy link

The goal is to keep track of where a line of documentation is coming from, for various purposes.
For now, we lose whether the doc is from slashes or an attribute, and I will try to make gccrs do a better job a that,
whether it's for pretty-printing or other matter.

MajoraSans added a commit to MajoraSans/gccrs that referenced this issue Oct 17, 2024
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit):
	* ast/rust-ast.h:
	* lex/rust-token.cc (Token::as_string):
	* lex/rust-token.h (enum PrimitiveCoreType):
	* parse/rust-parse-impl.h (Parser::parse_inner_attribute):
	(Parser::parse_outer_attribute):

Signed-off-by: lucas.plantrose <[email protected]>
MajoraSans added a commit to MajoraSans/gccrs that referenced this issue Oct 17, 2024
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit):
	* ast/rust-ast.h:
	* lex/rust-token.cc (Token::as_string):
	* lex/rust-token.h (enum PrimitiveCoreType):
	* parse/rust-parse-impl.h (Parser::parse_inner_attribute):
	(Parser::parse_outer_attribute):

Signed-off-by: lucas.plantrose <[email protected]>
MajoraSans added a commit to MajoraSans/gccrs that referenced this issue Oct 18, 2024
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Add behaviour.
	In Attribute visitor, recognize doc from comment and handle it.

	* ast/rust-ast.h: Changes Attribute constructor and add a boolean
	in the class for doc comments.

	* lex/rust-token.cc (Token::as_string): Return the correct string
	for the new DOC_STRING_LITERAL token.

	* lex/rust-token.h (enum PrimitiveCoreType): Add two tokens :
	DOC_STRING_LITERAL and DOC_END, for pretty-printing purposes.
	Also modify the string of two previous tokens.

	* parse/rust-parse-impl.h (Parser::parse_inner_attribute):
	Updates the Attribute constructor call.

	(Parser::parse_outer_attribute): Same as above.

Signed-off-by: lucas.plantrose <[email protected]>
@CohenArthur
Copy link
Member

@MajoraSans is this also done in rustc? could you point to some source code that does this or needs this? I think this would be a fine change, I'm simply curious as to how it's used

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 a pull request may close this issue.

2 participants