Skip to content

Commit

Permalink
Don't show snippet symbol graph modules as top-level preview sites (#108
Browse files Browse the repository at this point in the history
)

Move the check for a symbol being "snippet-only" to later in the
bundle loading process so that symbol edges are established fully.

rdar://90506525
  • Loading branch information
bitjammer authored Mar 30, 2022
1 parent d027bbb commit 5258679
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/SwiftDocC/Infrastructure/DocumentationContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1936,8 +1936,7 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
// Keep track of the root modules registered from symbol graph files, we'll need them to automatically
// curate articles.
rootModules = topicGraph.nodes.values.compactMap { node in
guard node.kind == .module,
!onlyHasSnippetRelatedChildren(for: node.reference) else {
guard node.kind == .module else {
return nil
}
return node.reference
Expand Down Expand Up @@ -2009,6 +2008,15 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
topicGraphGlobalAnalysis()

preResolveModuleNames()

// Symbol Graph modules whose children are all snippets should not
// be presented as a top-level preview page.
// First, a package might have a similar but different name to its
// primary library. Second, snippets are not automatically curated as
// other symbols might be.
rootModules.removeAll {
onlyHasSnippetRelatedChildren(for: $0)
}
}

/// Given a list of topics that have been automatically curated, checks if a topic has been additionally manually curated
Expand Down
6 changes: 6 additions & 0 deletions Tests/SwiftDocCTests/Semantics/SnippetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ class SnippetTests: XCTestCase {
XCTAssertNotNil(snippet)
XCTAssertTrue(problems.isEmpty)
}

func testNoTopLevelPageForSnippetModule() throws {
let (_, context) = try testBundleAndContext(named: "TestBundle")
XCTAssertEqual(3, context.rootModules.count)
XCTAssertFalse(context.rootModules.contains { $0.path == "/documentation/Test" })
}
}

0 comments on commit 5258679

Please sign in to comment.