Skip to content

Conversation

mayaepps
Copy link
Contributor

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

Summary

Currently, if any two articles have the same filename, DocC will warn for one of the files that it is a redeclaration and the file will be skipped. Article filenames need to be unique because those base names are used for the article's URL which need to be unique. However, documentation extensions' filenames have no impact on the URLs of any pages, so there's no need to enforce unique filenames for them.

This change skips the enforcement of unique filenames for documentation extensions to allow doc extensions to have the same filenames and for a doc extension to have the same filename as an article.

Testing

Steps:

  1. Create two documentation extensions with the same filename (in different directories in the catalog). Optionally, also add a regular article with the same filename.
  2. Build documentation.
  3. Ensure that a warning does not appear in either of the doc extension files and the documentation for each symbol contains the content from its respective doc extension.

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
  • Updated documentation if necessary - N/A

Since documentation extensions' filenames have no impact on the URL of any pages, there's no need to enforce unique filenames for them.

DocC currently uses only the filename / last path component of articles to determine if there is a duplicate article. This change excludes doc extensions from that check to allow documentation extensions to have the same filename.

rdar://117174884
Checks that doc extensions with the same filename do not produce a warning and DocC no longer drops the content from one of the files.
@mayaepps mayaepps requested a review from d-ronnqvist March 22, 2024 15:55
Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

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

LGTM

// Separate articles that look like documentation extension files from other articles, so that the documentation extension files can be matched up with a symbol.
// At this point we consider all articles with an H1 containing link "documentation extension" - some links might not resolve in the final documentation hierarchy
// and we will emit warnings for those later on when we finalize the bundle discovery phase.
if result.value.title?.child(at: 0) is AnyLink {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I can tell, isDocumentationExtension ((analyzed as? Article)?.title?.child(at: 0) is AnyLink) should be equivalent to result.value.title?.child(at: 0) is AnyLink, so this change hopefully improves readability, but I'd appreciate an extra pair of eyes to be sure I'm not missing something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep - we check a few lines above that if let article = analyzed as? Article, so we know that the analyzed node is an Article, and also therefore a Semantic. SemanticResult is just a simple struct holding the article as value and a couple other values. So we know that result.value is just article which is just analyzed as? Article.

The rest of the expression is the same, so yea your simplification is good I think 👍

@mayaepps
Copy link
Contributor Author

@swift-ci Please test

@mayaepps mayaepps merged commit 135a55e into swiftlang:main Mar 25, 2024
mayaepps added a commit to mayaepps/swift-docc that referenced this pull request Mar 25, 2024
…g#863)

* Allow documentation extensions to have the same name

Since documentation extensions' filenames have no impact on the URL of any pages, there's no need to enforce unique filenames for them.

DocC currently uses only the filename / last path component of articles to determine if there is a duplicate article. This change excludes doc extensions from that check to allow documentation extensions to have the same filename.

rdar://117174884

* Add test to ensure doc extensions can have the same filename

Checks that doc extensions with the same filename do not produce a warning and DocC no longer drops the content from one of the files.
mayaepps added a commit that referenced this pull request Mar 26, 2024
)

* Allow documentation extensions to have the same name

Since documentation extensions' filenames have no impact on the URL of any pages, there's no need to enforce unique filenames for them.

DocC currently uses only the filename / last path component of articles to determine if there is a duplicate article. This change excludes doc extensions from that check to allow documentation extensions to have the same filename.

rdar://117174884

* Add test to ensure doc extensions can have the same filename

Checks that doc extensions with the same filename do not produce a warning and DocC no longer drops the content from one of the files.
emilyychenn added a commit to emilyychenn/swift-docc that referenced this pull request Mar 27, 2024
Fix typo in RenderContentCompilerTests

resolve some PR feedback

Update Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift

Co-authored-by: David Rönnqvist <[email protected]>

add tests with multiple variants of thematic breaks

Don't enforce unique filenames for documentation extensions (swiftlang#863)

* Allow documentation extensions to have the same name

Since documentation extensions' filenames have no impact on the URL of any pages, there's no need to enforce unique filenames for them.

DocC currently uses only the filename / last path component of articles to determine if there is a duplicate article. This change excludes doc extensions from that check to allow documentation extensions to have the same filename.

rdar://117174884

* Add test to ensure doc extensions can have the same filename

Checks that doc extensions with the same filename do not produce a warning and DocC no longer drops the content from one of the files.

Update the year in license headers

Bump patch version
emilyychenn added a commit to emilyychenn/swift-docc that referenced this pull request Mar 27, 2024
Fix typo in RenderContentCompilerTests

resolve some PR feedback

Update Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift

Co-authored-by: David Rönnqvist <[email protected]>

add tests with multiple variants of thematic breaks

Don't enforce unique filenames for documentation extensions (swiftlang#863)

* Allow documentation extensions to have the same name

Since documentation extensions' filenames have no impact on the URL of any pages, there's no need to enforce unique filenames for them.

DocC currently uses only the filename / last path component of articles to determine if there is a duplicate article. This change excludes doc extensions from that check to allow documentation extensions to have the same filename.

rdar://117174884

* Add test to ensure doc extensions can have the same filename

Checks that doc extensions with the same filename do not produce a warning and DocC no longer drops the content from one of the files.

Update the year in license headers

Bump patch version
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