Skip to content

Support authoring a single anonymous topics section #421

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
MissingAbstract(sourceFile: source).any(),
NonOverviewHeadingChecker(sourceFile: source).any(),
SeeAlsoInTopicsHeadingChecker(sourceFile: source).any(),
TopicsSectionWithoutSubheading(sourceFile: source).any(),
])
checker.visit(document)
diagnosticEngine.emit(checker.problems)
Expand Down
8 changes: 8 additions & 0 deletions Sources/SwiftDocC/Model/DocumentationMarkup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ struct DocumentationMarkup {
topicsFirstTaskGroupIndex = index
}
}
// The first topic group in a topic section is allowed to be "anonymous", or without
// an H3 heading. We account for this by treating both UnorderedLists and Paragraphs as
// valid children indicating the start of a task group.
else if child is UnorderedList {
topicsFirstTaskGroupIndex = index
} else if child is Paragraph {
topicsFirstTaskGroupIndex = index
}

if topicsIndex == nil { topicsIndex = index }

Expand Down

This file was deleted.

41 changes: 41 additions & 0 deletions Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3174,4 +3174,45 @@ Document
]
)
}

func testTopicsSectionWithSingleAnonymousTopicGroup() throws {
let (_, bundle, context) = try testBundleAndContext(
copying: "TestBundle",
configureBundle: { url in
try """
# Article

Abstract.

## Topics

- ``MyKit/MyProtocol``
- ``MyKit/MyClass``

""".write(to: url.appendingPathComponent("article.md"), atomically: true, encoding: .utf8)
}
)

let articleReference = ResolvedTopicReference(
bundleIdentifier: bundle.identifier,
path: "/documentation/Test-Bundle/article",
sourceLanguage: .swift
)

let articleNode = try context.entity(with: articleReference)

var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: articleNode.reference, source: nil)
let articleRenderNode = try XCTUnwrap(translator.visit(articleNode.semantic) as? RenderNode)

XCTAssertEqual(
articleRenderNode.topicSections.flatMap { taskGroup in
[taskGroup.title] + taskGroup.identifiers
},
[
nil,
"doc://org.swift.docc.example/documentation/MyKit/MyProtocol",
"doc://org.swift.docc.example/documentation/MyKit/MyClass",
]
)
}
}