Skip to content

Commit 668850a

Browse files
author
Anthony Eid
committed
Stop warnings from modules under technology root
Change check during documentation curating that triggers a warning if a module is not a top-level page. To not trigger if the module has a technology root. In order, to give users more flexibility in creating their documentation hirerarchy Issue: 735
1 parent ca120e1 commit 668850a

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,27 @@ struct DocumentationCurator {
229229
(childDocumentationNode.kind == .article || childDocumentationNode.kind.isSymbol || childDocumentationNode.kind == .tutorial || childDocumentationNode.kind == .tutorialArticle) else {
230230
continue
231231
}
232-
233-
guard childDocumentationNode.kind != .module else {
232+
233+
234+
// If a module has a path with a manual technology root there shouldn't
235+
// be an error messsage. Using an if statement allows fallthrough behavior
236+
// in that specific case
237+
if childDocumentationNode.kind == .module {
238+
239+
let hasTechnologyRoot = context.pathsTo(nodeReference).contains { path in
240+
if path.count == 0 {
241+
return false
242+
}
243+
244+
let node = context.topicGraph.nodeWithReference(path[0])
245+
return node?.kind == .module && node?.kind.isSymbol == false
246+
}
247+
248+
if !hasTechnologyRoot {
234249
problems.append(Problem(diagnostic: Diagnostic(source: source(), severity: .warning, range: range(), identifier: "org.swift.docc.ModuleCuration", summary: "Linking to \((link.destination ?? "").singleQuoted) from a Topics group in \(nodeReference.absoluteString.singleQuoted) isn't allowed", explanation: "The former is a module, and modules only exist at the root"), possibleSolutions: []))
235250
continue
251+
}
252+
236253
}
237254

238255
// Verify we are not creating a graph cyclic relationship.

0 commit comments

Comments
 (0)