Skip to content

Conversation

@QuietMisdreavus
Copy link
Contributor

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

Summary

When @PageKind is used to set an article's kind, it doesn't actually set the kind for the DocumentationNode created from that article, only the RenderNode role. This PR sets the node kind for the DocumentationNode when the article is loaded, so that it can be used e.g. in the linkable-entities.json file emitted from the node.

Dependencies

None

Testing

To test, use a documentation catalog that includes an article that uses @PageKind(sampleCode). The bundle at Tests/SwiftDocCTests/Test Bundles/SampleBundle.docc has two such articles, MyExternalSample and MyLocalSample, and is used in the following instructions.

Steps:

  1. swift run docc convert --output-path .build/output.docarchive --emit-digest 'Tests/SwiftDocCTests/Test Bundles/SampleBundle.docc'
  2. Inspect .build/output.docarchive/linkable-entities.json and ensure that the pages for MyExternalSample and MyLocalSample have their kind set to org.swift.docc.kind.sampleCode.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

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

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus QuietMisdreavus merged commit 792b9e8 into swiftlang:main Jun 16, 2023
@QuietMisdreavus QuietMisdreavus deleted the samplecode-kind branch June 16, 2023 21:38
QuietMisdreavus added a commit to QuietMisdreavus/swift-docc that referenced this pull request Jun 16, 2023
ethan-kusters added a commit to ethan-kusters/swift-docc that referenced this pull request Jul 31, 2023
… the kind for the documentation node (swiftlang#626)"

This reverts the changes to 'DocumentationContext.swift' from
commit 792b9e8.

This change introduced a regression where sample code pages
we're always automatically curated even if they'd been manually
curated. This made it impossible to curate a sample code
page without ending up with duplicate entries for that page.

Only the changes to 'DocumentationContext.swift' are being reverted
so that the tests added for the other bug this change fixed remain.

rdar://112223641
ethan-kusters added a commit to ethan-kusters/swift-docc that referenced this pull request Jul 31, 2023
… the kind for the documentation node (swiftlang#626)"

This reverts the changes to 'DocumentationContext.swift' from
commit 792b9e8.

This change introduced a regression where sample code pages
we're always automatically curated even if they'd been manually
curated. This made it impossible to curate a sample code
page without ending up with duplicate entries for that page.

Only the changes to 'DocumentationContext.swift' are being reverted
so that the tests added for the other bug this change fixed remain.

rdar://112223641
ethan-kusters added a commit that referenced this pull request Jul 31, 2023
…tion (#674)

* Revert changes to 'DocumentationContext.swift' from "`@PageKind` sets the kind for the documentation node (#626)"

This reverts the changes to 'DocumentationContext.swift' from
commit 792b9e8.

This change introduced a regression where sample code pages
we're always automatically curated even if they'd been manually
curated. This made it impossible to curate a sample code
page without ending up with duplicate entries for that page.

Only the changes to 'DocumentationContext.swift' are being reverted
so that the tests added for the other bug this change fixed remain.

rdar://112223641

* Targeted fix for specifying sample code kind in link dest summary

Adds a targeted fix for specifying the correct "sample code"
kind when creating a link destination summary for an
article with `@PageKind(sampleCode)` specified.

This fixes the issue the previously reverted commit fixed
but while maintaining correct autocuration behavior for sample
code pages.

This likely isn't the right long-term solution and a FIXME comment
has been added to track investing a more robust way
of tracking article-like pages that require some special-handling.

* Add regression test for sample code autocuration
ethan-kusters added a commit to ethan-kusters/swift-docc that referenced this pull request Jul 31, 2023
…tion (swiftlang#674)

* Revert changes to 'DocumentationContext.swift' from "`@PageKind` sets the kind for the documentation node (swiftlang#626)"

This reverts the changes to 'DocumentationContext.swift' from
commit 792b9e8.

This change introduced a regression where sample code pages
we're always automatically curated even if they'd been manually
curated. This made it impossible to curate a sample code
page without ending up with duplicate entries for that page.

Only the changes to 'DocumentationContext.swift' are being reverted
so that the tests added for the other bug this change fixed remain.

rdar://112223641

* Targeted fix for specifying sample code kind in link dest summary

Adds a targeted fix for specifying the correct "sample code"
kind when creating a link destination summary for an
article with `@PageKind(sampleCode)` specified.

This fixes the issue the previously reverted commit fixed
but while maintaining correct autocuration behavior for sample
code pages.

This likely isn't the right long-term solution and a FIXME comment
has been added to track investing a more robust way
of tracking article-like pages that require some special-handling.

* Add regression test for sample code autocuration
ethan-kusters added a commit that referenced this pull request Aug 1, 2023
…tion (#674)

* Revert changes to 'DocumentationContext.swift' from "`@PageKind` sets the kind for the documentation node (#626)"

This reverts the changes to 'DocumentationContext.swift' from
commit 792b9e8.

This change introduced a regression where sample code pages
we're always automatically curated even if they'd been manually
curated. This made it impossible to curate a sample code
page without ending up with duplicate entries for that page.

Only the changes to 'DocumentationContext.swift' are being reverted
so that the tests added for the other bug this change fixed remain.

rdar://112223641

* Targeted fix for specifying sample code kind in link dest summary

Adds a targeted fix for specifying the correct "sample code"
kind when creating a link destination summary for an
article with `@PageKind(sampleCode)` specified.

This fixes the issue the previously reverted commit fixed
but while maintaining correct autocuration behavior for sample
code pages.

This likely isn't the right long-term solution and a FIXME comment
has been added to track investing a more robust way
of tracking article-like pages that require some special-handling.

* Add regression test for sample code autocuration
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