-
Notifications
You must be signed in to change notification settings - Fork 166
Add a helper function for rendering a Topics/SeeAlso section as HTML #1382
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
base: main
Are you sure you want to change the base?
Conversation
|
@swift-ci please test |
|
|
||
| /// Creates a grouped section with a given name, for example "topics" or "see also" that describes and organizes groups of related API. | ||
| /// | ||
| /// If each language representation of the API has their own language-specific parameters, pass each language representation's parameter information. |
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.
| /// If each language representation of the API has their own language-specific parameters, pass each language representation's parameter information. | |
| /// If each language representation of the API has their own language-specific set of parameters, pass the parameter information for each language representation. |
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.
And: has their -> has its
| /// If each language representation of the API has their own language-specific parameters, pass each language representation's parameter information. | ||
| /// | ||
| /// If the API has the _same_ parameters in all language representations, only pass the parameters for one language. | ||
| /// This produces a "parameters" section that doesn't hide any parameters for any of the languages (same as if the symbol only had one language representation) |
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 produces a "parameters" section that doesn't hide any parameters for any of the languages (same as if the symbol only had one language representation) | |
| /// This produces a "parameters" section that doesn't hide any parameters for any of the languages (the same as if the symbol only had one language representation). |
|
|
||
| let renderer = makeRenderer(goal: goal, elementsToReturn: elements) | ||
| let expectedSectionID = expectedGroupTitle.replacingOccurrences(of: " ", with: "-") | ||
| let groupedSection = renderer.groupedSection(named: expectedGroupTitle, groups: [ |
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.
Since you've included the OCC representation with alternate parameters above, could we also include (or make a second set of asserts) that show the expected output when the language is ObjC?
| /// | ||
| /// If the API has the _same_ parameters in all language representations, only pass the parameters for one language. | ||
| /// This produces a "parameters" section that doesn't hide any parameters for any of the languages (same as if the symbol only had one language representation) | ||
| func groupedSection(named sectionName: String, groups taskGroups: [SourceLanguage: [TaskGroupInfo]]) -> [XMLNode] { |
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.
The comments above are talking about a parameters section. Should we update the comments to describe the task group section this function returns?
| private func _taskGroupItem(for element: LinkedElement) -> XMLElement { | ||
| var items: [XMLNode] | ||
| switch element.subheadings { | ||
| case .single(.conceptual(let title)): |
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 more nested pattern matching :)
| let fragmentsByLanguage = RenderHelpers.sortedLanguageSpecificValues(fragmentsByLanguage) | ||
| items = if fragmentsByLanguage.count == 1 { | ||
| [ _symbolSubheading(fragmentsByLanguage.first!.value, languageFilter: nil) ] | ||
| } else if goal == .conciseness, let fragments = fragmentsByLanguage.first?.value { |
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.
Are we ignoring the second (and subsequent languages) here for concise mode? Please explain why with a comment.
| ]) | ||
| } | ||
|
|
||
| private func _symbolSubheading(_ fragments: [LinkedElement.SymbolNameFragment], languageFilter: SourceLanguage?) -> XMLElement { |
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.
An HTML example here or above might be nice; this is getting a bit complex.
Bug/issue #, if applicable: rdar://163326857
Summary
This is another slice of #1366
It adds a helper function to the
DocCHTML/MarkdownRendererto render "topics" and "see also" sections as HTML.Dependencies
None.
Testing
Nothing in particular for this PR. It only adds an internal helper function. See #1366 for how it eventually does get used.
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/testscript and it succeeded