Skip to content

Add Children section to SyntaxCollection nodes #1902

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

Merged
merged 3 commits into from
Jul 17, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jul 13, 2023

This simplifies the navigation of the syntax tree hierarchy in the generated documentation.

Also remove a bunch of empty lines from the generated files.

@ahoppen ahoppen requested a review from bnbarham July 13, 2023 06:00
Comment on lines 20 to 24
try! StructDeclSyntax(
"""
\(raw: node.documentation)
public struct \(raw: node.kind.syntaxType): SyntaxCollection, SyntaxHashable
\(raw: node.documentation.isEmpty ? "" : "///")
\(raw: node.grammar)
Copy link
Contributor

@Matejkob Matejkob Jul 13, 2023

Choose a reason for hiding this comment

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

Really cool changes! 💙
Maybe it would be beneficial to use removedEmptyLines(string:) to prevent adding empty lines? It could look this:

    let docComment = removedEmptyLines(
        string: """
        \(node.documentation)
        \(node.documentation.isEmpty ? "" : "///")
        \(node.grammar)
        """
    )

    try! StructDeclSyntax(
      """
      \(raw: docComment)
      public struct \(node.kind.syntaxType): SyntaxCollection, SyntaxHashable
      """
    ) {
(...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Very good idea 👍🏽

Comment on lines 277 to 279
grammar = "``\(onlyElement.syntaxType)``*"
} else {
grammar = "(\(elementChoices.map { "``\($0.syntaxType)``" }.joined(separator: " | "))) `*`"
Copy link
Contributor

@bnbarham bnbarham Jul 14, 2023

Choose a reason for hiding this comment

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

Could make them a little more consistent here, ie. either

"``foo``*" and "(``foo`` | ``bar``)*"

or

"``foo`` `*`" and "(``foo`` | ``bar``) `*`"

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching this.

@ahoppen ahoppen force-pushed the ahoppen/children-of-collections branch from 0857b48 to 070b908 Compare July 14, 2023 11:20
@ahoppen ahoppen force-pushed the ahoppen/children-of-collections branch from 070b908 to 9a5ff8d Compare July 14, 2023 11:23
@ahoppen
Copy link
Member Author

ahoppen commented Jul 14, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit efb05b0 into swiftlang:main Jul 17, 2023
@ahoppen ahoppen deleted the ahoppen/children-of-collections branch July 17, 2023 14:32
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.

3 participants