Skip to content

Conversation

@d-ronnqvist
Copy link
Contributor

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

Summary

This is another slice of #1366

It adds a helper function to the DocCHTML/MarkdownRenderer to 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.

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

@d-ronnqvist
Copy link
Contributor Author

@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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// 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.

Copy link
Contributor

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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// 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: [
Copy link
Member

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] {
Copy link
Contributor

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)):
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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.

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