-
Notifications
You must be signed in to change notification settings - Fork 163
Filter out topics that aren't available in the page's language #96
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
Filter out topics that aren't available in the page's language #96
Conversation
663153b to
f9b5518
Compare
|
@swift-ci please test |
f9b5518 to
4cd124c
Compare
|
@swift-ci please test |
4cd124c to
a2eb297
Compare
|
@swift-ci please test |
| } | ||
|
|
||
| /// Creates an empty grouped sequence. | ||
| init(deriveKey: @escaping (Element) -> Key) { |
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: typo derivedKey
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.
I think deriveKey as it is currently works better because its type is a function, so it should be named like an action.
| /// // Prints "a" | ||
| /// // Prints "aaa" | ||
| /// ``` | ||
| struct GroupedSequence<Key: Hashable, Element>: Sequence, CustomStringConvertible { |
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.
Not needed for this PR but this already fulfills the requirements for Collection might be nice since we are making this a standalone data structure.
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.
hm, yes, looks like we're close! But we need to implement a few more requirements, which I think we should implement when we get a use for them. This isn't intended to be a general-purpose API—it's just for DocC's purposes.
|
|
||
| /// Returns whether the topic with the given identifier is available in one of the traits in `allowedTraits`. | ||
| func isAvailableInAllowedTrait(identifier: String) -> Bool { | ||
| guard let reference = contentCompiler.collectedTopicReferences[identifier] 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.
Not sure I understand this logic. Could you explain why you return true if you couldn't find a topic reference for this identifier?
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.
Is this because you are conservatively not filtering out content you don't have a definition for in this framework?
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.
Ah yes, I should clarify that in a comment, thanks for pointing that out. It's expected for reference to never be nil as it is a precondition for contentCompiler to have populated collectionTopicReference with the reference at this point. Otherwise, it is a bug in contentCompiler.
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.
In fact, we can actually add an assertionFailure so that we get a crash in debug builds, but not release.
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.
Actually, after taking a closer look, I'm wrong on this. It's possible for the content compiler to generate a reference identifier without registering it in collectedTopicReferences, for example when the reference is a non-doc URL, e.g., https:// in which case it gets registered in linkReferences instead. I'll add a comment to clarify that.
| groupedSequence.append("aa") | ||
|
|
||
| XCTAssertEqual(groupedSequence[1], "a") | ||
| XCTAssertEqual(groupedSequence[2], "aa") |
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.
you probably want to add the following to this:
groupedSequence.append("b")
XCTAssertEqual(groupedSequence[1], "b")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.
Yes, that's a great idea!
a2eb297 to
906ac34
Compare
|
@swift-ci please test |
ethan-kusters
left a comment
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 looks good to me! Just a few small things for your consideration.
Was tutorials the last thing we needed to support here or do we still need support for articles?
| semantic: technology | ||
| ) | ||
| documentationCache[reference] = node | ||
| topicGraph.nodes[reference]?.reference = reference |
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.
Is this a change from before? We weren't including technology references in the topic graph?
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.
We are at an earlier stage, in registerDocuments. What we're doing here is updating the reference now that we have enough information to know in which languages the page is available in. I'll add a comment to clarify that.
| } | ||
|
|
||
| /// Returns whether the topic with the given identifier is available in one of the traits in `allowedTraits`. | ||
| func isAvailableInAllowedTrait(identifier: String) -> Bool { |
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.
| func isAvailableInAllowedTrait(identifier: String) -> Bool { | |
| func topicIsAvailableInAllowedTraits(identifier topicIdentifier: String) -> Bool { |
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.
Fair. I can meet in the middle with isTopicAvailableInAllowedTraits. 🤝?
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.
Deal. 🤝😃
906ac34 to
64e6daf
Compare
I believe tutorials was the last thing we needed to make multi-language. Article support was added by #81. |
Filter out topics that are not available in the language of the symbol that curates them. rdar://89124291
In the same way articles do, infer the available languages of tutorials from the module's available language.
64e6daf to
a7857b3
Compare
|
@swift-ci please test |
|
@swift-ci please test macOS platform |
|
@swift-ci please test Linux platform |
| documentationCache[technologyReference] = technologyNode | ||
|
|
||
| // Update the reference in the topic graph with the technology's available languages. | ||
| topicGraph.updateReference( |
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.
Nice! This looks great- much easier for me to follow.
Bug/issue #, if applicable: rdar://89124291
Summary
Filters out topics that aren't available in the language of the symbol that curates them. Note that this was already working for automatically curated topics, but not manually curated topics.
This PR also includes making tutorial content available on all the languages in which the framework is available (last commit),
Also, since the original fix of this PR filters out topics that aren't available in the parent page's language, it was also causing DocC to filter out tutorial content from Objective-C pages. As such, the last commit of this PR resolves this issue by making tutorials multi-language as well, if the framework it's documenting is multi-language.
Dependencies
None.
Testing
Checklist
./bin/testscript and it succeededTODO