Skip to content

Conversation

@franklinsch
Copy link
Contributor

@franklinsch franklinsch commented Nov 2, 2021

Bug/issue #, if applicable: rdar://83665056

Summary

Update the Symbol API to support variants. Each property has a variants counterpart property and the original properties have been updated to forward to the variants counterpart.

The first commit just hardcodes accesses to use the Swift variant so that there are no user-facing changes.

Then, the second commit adds support for emitting multi-language symbol data:

  1. The VariantCollection+Symbol.swift file contains initializers that create render node variant models
    (VariantCollection) from symbol data (DocumentationDataVariants).
  2. The RenderNodeTranslator has been updated to consume all the symbols' variants and populate
    render node VariantCollection properties.
  3. The logic to create render node sections for the RenderNode.primaryContentSections array has been
    refactored to subtypes of the new RenderSectionTranslator protocol, for clarity.
  4. The JSONPatch infrastructure now supports the add operation, which was needed for values
    that are not present in the default render node's fields, but for which we have overrides for.
  5. In the second commit, SymbolDataVariants was renamed to DocumentationDataVariants since the type
    is now used beyond symbol data, e.g., as the return value of LinkTitleResolver.title(for:).

Dependencies

None.

Testing

There should be no user-facing changes yet, since this doesn't bring support for ingesting Objective-C symbol graph files yet.

Checklist

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@franklinsch
Copy link
Contributor Author

@swift-ci please test

Adds APIs for specifying different variants for fields of the Symbol
API in support of documenting symbols that are available in multiple
languages, for example Swift and Objective-C.

rdar://83665056
Emits multi-language symbol data to render JSON.

rdar://82967644
Since the SymbolDataVariants is now used beyond symbol APIs, this
renames the type to something more generic.

rdar://82967644
@franklinsch
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

/// about the symbol. For example, if a symbol is available in multiple programming languages, the ``titleVariants`` property represents the title of the symbol
/// for each programming language it's available in. Use a ``SymbolDataVariantsTrait`` to access a specific variant.
///
/// ## Topics
Copy link
Contributor

Choose a reason for hiding this comment

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

Really thankful that you added documentation links for all the new fields!

@franklinsch franklinsch merged commit 05abeb7 into swiftlang:main Nov 4, 2021
ethan-kusters added a commit to ethan-kusters/swift-docc that referenced this pull request Jan 11, 2023
Includes the following changes:

    commit b1622a0a0b747740839511b1387289bcf1c64b19
    Author: Ethan Kusters <[email protected]>
    Date:   Mon Jan 9 17:42:46 2023 -0800

        Adds the `seeAlso` aside

        “See Also” is a common kind of aside that folks parsing markdown
        may wish to consider.

        For Swift-DocC specifically, there is a lot of pre-DocC Swift
        documentation content that uses this style of callout:

        ```
        - SeeAlso:
        ```

        In order to gracefully transition this content over to Swift-DocC
        style asides, we should add support for them.

    commit 87ae1a8fa9180b85630c7b41ddd5aa40ffc87ce3
    Author: Ashley Garland <[email protected]>
    Date:   Tue Dec 6 20:23:49 2022 -0800

        Adopt more snippets

        Add snippets for the following areas:

        - Parsing
        - Querying
        - Walkers, Rewriters, and Visitors
        - Formatting

        Add a link to the top-level page.

        Add an article which inlines all of the snippets in one place for quick reference.

        rdar://103054461

    commit 3a631f4d4b0e9c80004b8555bcb629c898e8089f
    Author: Tim Triemstra <[email protected]>
    Date:   Fri Dec 2 13:15:36 2022 -0800

        Fixed the snippets support to use the new standard comment structure, and the @snippet references use the full path to the snippet file

    commit 0d04722bafe7c6c29c485e4bdaa2235b879cc7e7
    Author: Ashley Garland <[email protected]>
    Date:   Tue Mar 29 23:18:49 2022 -0700

        Example usage of snippets for Swift Evolution

    commit 7dd6c526c9184fd7fabdda592167f305727b515e
    Author: Christian Selig <[email protected]>
    Date:   Tue Nov 29 12:42:21 2022 -0400

        Add support for custom attributes (swiftlang#25)

        rdar://96536586
ethan-kusters added a commit that referenced this pull request Jan 28, 2023
Includes the following changes:

    commit b1622a0a0b747740839511b1387289bcf1c64b19
    Author: Ethan Kusters <[email protected]>
    Date:   Mon Jan 9 17:42:46 2023 -0800

        Adds the `seeAlso` aside

        “See Also” is a common kind of aside that folks parsing markdown
        may wish to consider.

        For Swift-DocC specifically, there is a lot of pre-DocC Swift
        documentation content that uses this style of callout:

        ```
        - SeeAlso:
        ```

        In order to gracefully transition this content over to Swift-DocC
        style asides, we should add support for them.

    commit 87ae1a8fa9180b85630c7b41ddd5aa40ffc87ce3
    Author: Ashley Garland <[email protected]>
    Date:   Tue Dec 6 20:23:49 2022 -0800

        Adopt more snippets

        Add snippets for the following areas:

        - Parsing
        - Querying
        - Walkers, Rewriters, and Visitors
        - Formatting

        Add a link to the top-level page.

        Add an article which inlines all of the snippets in one place for quick reference.

        rdar://103054461

    commit 3a631f4d4b0e9c80004b8555bcb629c898e8089f
    Author: Tim Triemstra <[email protected]>
    Date:   Fri Dec 2 13:15:36 2022 -0800

        Fixed the snippets support to use the new standard comment structure, and the @snippet references use the full path to the snippet file

    commit 0d04722bafe7c6c29c485e4bdaa2235b879cc7e7
    Author: Ashley Garland <[email protected]>
    Date:   Tue Mar 29 23:18:49 2022 -0700

        Example usage of snippets for Swift Evolution

    commit 7dd6c526c9184fd7fabdda592167f305727b515e
    Author: Christian Selig <[email protected]>
    Date:   Tue Nov 29 12:42:21 2022 -0400

        Add support for custom attributes (#25)

        rdar://96536586
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.

2 participants