Skip to content

Check the module name to know when to skip inherited doc comments. #314

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 5 commits into from
Jun 21, 2022
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
2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,7 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
edge: relationship,
context: self,
symbolIndex: &symbolIndex,
moduleName: moduleName,
engine: diagnosticEngine
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,14 @@ struct SymbolGraphRelationshipsBuilder {
/// - selector: The symbol graph selector in which the relationship is relevant.
/// - context: A documentation context.
/// - symbolIndex: A symbol lookup map by precise identifier.
/// - moduleName: The symbol name of the current module.
/// - engine: A diagnostic collecting engine.
static func addInheritedDefaultImplementation(
edge: SymbolGraph.Relationship,
context: DocumentationContext, symbolIndex:
inout [String: DocumentationNode], engine:
DiagnosticEngine
context: DocumentationContext,
symbolIndex: inout [String: DocumentationNode],
moduleName: String,
engine: DiagnosticEngine
) {
func setAsInheritedSymbol(origin: SymbolGraph.Relationship.SourceOrigin, for node: inout DocumentationNode, originNode: DocumentationNode?) {
(node.semantic as! Symbol).origin = origin
Expand All @@ -358,7 +360,7 @@ struct SymbolGraphRelationshipsBuilder {
// Remove any inherited docs from the original symbol if the feature is disabled.
// However, when the docs are inherited from within the same module, its content can be resolved in
// the local context, so keeping those inherited docs provide a better user experience.
if !context.externalMetadata.inheritDocs && node.unifiedSymbol?.documentedSymbol?.isDocCommentFromSameModule == false {
if !context.externalMetadata.inheritDocs && node.unifiedSymbol?.documentedSymbol?.isDocCommentFromSameModule(symbolModuleName: moduleName) == false {
node.unifiedSymbol?.docComment.removeAll()
}
}
Expand Down
34 changes: 34 additions & 0 deletions Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,40 @@ Document @1:1-11:19
let expectedRenderedAbstract: [RenderInlineContent]
}
let testData = [
// With the new module information
TestData(
docCommentJSON: """
{
"lines": [{
"text": "Authored abstract",
"range": {
"start": {"line": 1, "character": 4},
"end": {"line": 1, "character": 21}
}
}],
"module": "SideKit",
"uri": "file://path/to/file.swift"
}
""",
expectedRenderedAbstract: [.text("Authored abstract")]
),
TestData(
docCommentJSON: """
{
"lines": [{
"text": "Authored abstract",
"range": {
"start": {"line": 1, "character": 4},
"end": {"line": 1, "character": 21}
}
}],
"module": "OtherModule",
"uri": "file://path/to/file.swift"
}
""",
expectedRenderedAbstract: [.text("Inherited from "), .codeVoice(code: "Module.Protocol.inherited()"), .text(".")]
),
// Without the new module information
TestData(
docCommentJSON: """
{
Expand Down