From f57c81293ae36fbf4e45923da856f201e8eaabbe Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Sat, 4 Jun 2022 09:46:20 -0600 Subject: [PATCH] Do not attach module comments to non-modules --- src/lib/converter/comments/index.ts | 10 ++++ src/test/converter/exports/specs.json | 23 --------- src/test/converter/exports/specs.nodoc.json | 55 --------------------- 3 files changed, 10 insertions(+), 78 deletions(-) diff --git a/src/lib/converter/comments/index.ts b/src/lib/converter/comments/index.ts index 15be4732c..d476eea64 100644 --- a/src/lib/converter/comments/index.ts +++ b/src/lib/converter/comments/index.ts @@ -77,6 +77,16 @@ export function getComment( } } + if (!symbol.declarations?.some(ts.isSourceFile) && comment) { + // Ensure module comments are not attached to non-module reflections. + if ( + comment.hasModifier("@packageDocumentation") || + comment.getTag("@module") + ) { + return; + } + } + return comment; } diff --git a/src/test/converter/exports/specs.json b/src/test/converter/exports/specs.json index 52bc3e298..1ab1fdc2f 100644 --- a/src/test/converter/exports/specs.json +++ b/src/test/converter/exports/specs.json @@ -888,29 +888,6 @@ "flags": { "isConst": true }, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This module has documentation, but no exported members do." - } - ], - "blockTags": [ - { - "tag": "@see", - "content": [ - { - "kind": "text", - "text": "https://github.com/TypeStrong/typedoc/issues/1948" - } - ] - }, - { - "tag": "@module", - "content": [] - } - ] - }, "sources": [ { "fileName": "no-doc-members.ts", diff --git a/src/test/converter/exports/specs.nodoc.json b/src/test/converter/exports/specs.nodoc.json index 02ffd820a..3698dffe5 100644 --- a/src/test/converter/exports/specs.nodoc.json +++ b/src/test/converter/exports/specs.nodoc.json @@ -255,61 +255,6 @@ } ] }, - "children": [ - { - "id": 39, - "name": "abc", - "kind": 32, - "kindString": "Variable", - "flags": { - "isConst": true - }, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This module has documentation, but no exported members do." - } - ], - "blockTags": [ - { - "tag": "@see", - "content": [ - { - "kind": "text", - "text": "https://github.com/TypeStrong/typedoc/issues/1948" - } - ] - }, - { - "tag": "@module", - "content": [] - } - ] - }, - "sources": [ - { - "fileName": "no-doc-members.ts", - "line": 6, - "character": 13, - "url": "https://github.com/TypeStrong/typedoc/blob/fake/src/test/converter/exports/no-doc-members.ts#L6" - } - ], - "type": { - "type": "literal", - "value": 123 - }, - "defaultValue": "123" - } - ], - "groups": [ - { - "title": "Variables", - "children": [ - 39 - ] - } - ], "sources": [ { "fileName": "no-doc-members.ts",