-
Notifications
You must be signed in to change notification settings - Fork 162
Emit language variants for articles #81
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
Emit language variants for articles #81
Conversation
8cb3303 to
c10c1d8
Compare
|
@swift-ci please test |
Tests/SwiftDocCTests/Infrastructure/DocumentationContextTests.swift
Outdated
Show resolved
Hide resolved
c10c1d8 to
a3de982
Compare
Tests/SwiftDocCTests/Infrastructure/DocumentationContextTests.swift
Outdated
Show resolved
Hide resolved
Tests/SwiftDocCTests/Infrastructure/DocumentationContextTests.swift
Outdated
Show resolved
Hide resolved
|
Also I suggest changing the "name" and "id" definitions in SourceLanguage.swift from "var" to "let" by the way. |
a3de982 to
c1ce32f
Compare
|
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for putting this together.
I remember when initially implementing #47 that there was some remaining work to support auto-curated symbol collections (for protocol inherited symbols and the like) in multi-language scenarios since those rely on articles. Is that something we can resolve in this PR? (Or are we already and I missed it?)
|
|
||
| // If available source languages are provided and it contains Swift, use Swift as the default language of | ||
| // the article. | ||
| let sourceLanguage = availableSourceLanguages.map { availableSourceLanguages in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
| let sourceLanguage = availableSourceLanguages.map { availableSourceLanguages in | |
| let defaultSourceLanguage = availableSourceLanguages.map { availableSourceLanguages in |
| // curate articles. | ||
| rootModules = topicGraph.nodes.values.compactMap { node in | ||
| guard node.kind == .module, | ||
| !onlyHasSnippetRelatedChildren(for: node.reference) else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This snippet check is a little confusing to me. Maybe we should consider a node.isSnippetModule property at some point?
It almost seems like we should have a separate kind .snippetModule if we're going to need to special-case these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. This logic was just moved in this PR, but we should consider revisiting this in the future.
Articles that document a module available in multiple languages now inherit that module's languages. This ensures that we generate multiple language variants for article pages. rdar://88464797
Makes DocumentationContext.rootModules a stored property instead of a computed property for performance reasons.
5694c1f to
70b1352
Compare
I don't think that would be affected by these changes. This PR should only affect user-authored articles. Do we have a bug to track the issue you're referring to? |
|
@swift-ci please test |
Bug/issue #, if applicable: rdar://88464797
Summary
Articles that document a module available in multiple languages now inherit that module's languages. This ensures that we generate multiple language variants for article pages.
While investigating the performance impact of this change, I found that the repeated accesses to the
DocumentationContext.rootModules(a computed property that iterates over all topic graph nodes) was causing a large performance regression. To resolve this, in the second commit I made the property a stored property instead that's initialised once during bundle registration, right after symbols have been loaded in the symbol graph.Performance impact
No statistically significant impact.
Dependencies
None.
Testing
When documenting a framework that supports Swift and Objective-C, verify that articles, whether they're automatically or manually curated, get the language switcher in the sidebar. The syntax used in symbol references should reflect the currently selected language.
TODO
Checklist
./bin/testscript and it succeeded