Skip to content

Commit

Permalink
Always link to the first line of a file if it creates a module declar…
Browse files Browse the repository at this point in the history
…ation

Closes #2207
  • Loading branch information
Gerrit0 committed Mar 25, 2023
1 parent a41ac2d commit 6a7323f
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 72 deletions.
2 changes: 2 additions & 0 deletions src/lib/converter/plugins/SourcePlugin.ts
Expand Up @@ -93,6 +93,8 @@ export class SourcePlugin extends ConverterComponent {
sourceFile,
node.name.getStart()
);
} else if (ts.isSourceFile(node)) {
position = { character: 0, line: 0 };
} else {
position = ts.getLineAndCharacterOfPosition(
sourceFile,
Expand Down
32 changes: 16 additions & 16 deletions src/test/converter/class/specs-with-lump-categories.json
Expand Up @@ -475,9 +475,9 @@
"sources": [
{
"fileName": "access.ts",
"line": 5,
"line": 1,
"character": 0,
"url": "typedoc://access.ts#L5"
"url": "typedoc://access.ts#L1"
}
]
},
Expand Down Expand Up @@ -2354,9 +2354,9 @@
"sources": [
{
"fileName": "class.ts",
"line": 8,
"line": 1,
"character": 0,
"url": "typedoc://class.ts#L8"
"url": "typedoc://class.ts#L1"
}
]
},
Expand Down Expand Up @@ -2919,9 +2919,9 @@
"sources": [
{
"fileName": "constructor-properties.ts",
"line": 4,
"line": 1,
"character": 0,
"url": "typedoc://constructor-properties.ts#L4"
"url": "typedoc://constructor-properties.ts#L1"
}
]
},
Expand Down Expand Up @@ -3352,9 +3352,9 @@
"sources": [
{
"fileName": "decorators.ts",
"line": 4,
"line": 1,
"character": 0,
"url": "typedoc://decorators.ts#L4"
"url": "typedoc://decorators.ts#L1"
}
]
},
Expand Down Expand Up @@ -4024,9 +4024,9 @@
"sources": [
{
"fileName": "events-overloads.ts",
"line": 6,
"line": 1,
"character": 0,
"url": "typedoc://events-overloads.ts#L6"
"url": "typedoc://events-overloads.ts#L1"
}
]
},
Expand Down Expand Up @@ -4596,9 +4596,9 @@
"sources": [
{
"fileName": "generic-class.ts",
"line": 5,
"line": 1,
"character": 0,
"url": "typedoc://generic-class.ts#L5"
"url": "typedoc://generic-class.ts#L1"
}
]
},
Expand Down Expand Up @@ -5014,9 +5014,9 @@
"sources": [
{
"fileName": "this.ts",
"line": 6,
"line": 1,
"character": 0,
"url": "typedoc://this.ts#L6"
"url": "typedoc://this.ts#L1"
}
]
},
Expand Down Expand Up @@ -5275,9 +5275,9 @@
"sources": [
{
"fileName": "type-operator.ts",
"line": 8,
"line": 1,
"character": 0,
"url": "typedoc://type-operator.ts#L8"
"url": "typedoc://type-operator.ts#L1"
}
]
}
Expand Down
32 changes: 16 additions & 16 deletions src/test/converter/class/specs.json
Expand Up @@ -475,9 +475,9 @@
"sources": [
{
"fileName": "access.ts",
"line": 5,
"line": 1,
"character": 0,
"url": "typedoc://access.ts#L5"
"url": "typedoc://access.ts#L1"
}
]
},
Expand Down Expand Up @@ -2350,9 +2350,9 @@
"sources": [
{
"fileName": "class.ts",
"line": 8,
"line": 1,
"character": 0,
"url": "typedoc://class.ts#L8"
"url": "typedoc://class.ts#L1"
}
]
},
Expand Down Expand Up @@ -2915,9 +2915,9 @@
"sources": [
{
"fileName": "constructor-properties.ts",
"line": 4,
"line": 1,
"character": 0,
"url": "typedoc://constructor-properties.ts#L4"
"url": "typedoc://constructor-properties.ts#L1"
}
]
},
Expand Down Expand Up @@ -3348,9 +3348,9 @@
"sources": [
{
"fileName": "decorators.ts",
"line": 4,
"line": 1,
"character": 0,
"url": "typedoc://decorators.ts#L4"
"url": "typedoc://decorators.ts#L1"
}
]
},
Expand Down Expand Up @@ -4020,9 +4020,9 @@
"sources": [
{
"fileName": "events-overloads.ts",
"line": 6,
"line": 1,
"character": 0,
"url": "typedoc://events-overloads.ts#L6"
"url": "typedoc://events-overloads.ts#L1"
}
]
},
Expand Down Expand Up @@ -4592,9 +4592,9 @@
"sources": [
{
"fileName": "generic-class.ts",
"line": 5,
"line": 1,
"character": 0,
"url": "typedoc://generic-class.ts#L5"
"url": "typedoc://generic-class.ts#L1"
}
]
},
Expand Down Expand Up @@ -5010,9 +5010,9 @@
"sources": [
{
"fileName": "this.ts",
"line": 6,
"line": 1,
"character": 0,
"url": "typedoc://this.ts#L6"
"url": "typedoc://this.ts#L1"
}
]
},
Expand Down Expand Up @@ -5271,9 +5271,9 @@
"sources": [
{
"fileName": "type-operator.ts",
"line": 8,
"line": 1,
"character": 0,
"url": "typedoc://type-operator.ts#L8"
"url": "typedoc://type-operator.ts#L1"
}
]
}
Expand Down
16 changes: 8 additions & 8 deletions src/test/converter/comment/specs.json
Expand Up @@ -205,9 +205,9 @@
"sources": [
{
"fileName": "comment.ts",
"line": 5,
"line": 1,
"character": 0,
"url": "typedoc://comment.ts#L5"
"url": "typedoc://comment.ts#L1"
}
]
},
Expand Down Expand Up @@ -306,9 +306,9 @@
"sources": [
{
"fileName": "comment2.ts",
"line": 8,
"line": 1,
"character": 0,
"url": "typedoc://comment2.ts#L8"
"url": "typedoc://comment2.ts#L1"
}
]
},
Expand Down Expand Up @@ -407,9 +407,9 @@
"sources": [
{
"fileName": "comment3.ts",
"line": 8,
"line": 1,
"character": 0,
"url": "typedoc://comment3.ts#L8"
"url": "typedoc://comment3.ts#L1"
}
]
},
Expand Down Expand Up @@ -504,9 +504,9 @@
"sources": [
{
"fileName": "comment4.ts",
"line": 11,
"line": 1,
"character": 0,
"url": "typedoc://comment4.ts#L11"
"url": "typedoc://comment4.ts#L1"
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/converter/exports/specs.json
Expand Up @@ -893,9 +893,9 @@
"sources": [
{
"fileName": "mod.ts",
"line": 8,
"line": 1,
"character": 0,
"url": "typedoc://mod.ts#L8"
"url": "typedoc://mod.ts#L1"
}
]
},
Expand Down Expand Up @@ -959,9 +959,9 @@
"sources": [
{
"fileName": "no-doc-members.ts",
"line": 6,
"line": 1,
"character": 0,
"url": "typedoc://no-doc-members.ts#L6"
"url": "typedoc://no-doc-members.ts#L1"
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/converter/exports/specs.nodoc.json
Expand Up @@ -233,9 +233,9 @@
"sources": [
{
"fileName": "mod.ts",
"line": 8,
"line": 1,
"character": 0,
"url": "typedoc://mod.ts#L8"
"url": "typedoc://mod.ts#L1"
}
]
},
Expand Down Expand Up @@ -267,9 +267,9 @@
"sources": [
{
"fileName": "no-doc-members.ts",
"line": 6,
"line": 1,
"character": 0,
"url": "typedoc://no-doc-members.ts#L6"
"url": "typedoc://no-doc-members.ts#L1"
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/converter/function/specs.json
Expand Up @@ -2577,9 +2577,9 @@
"sources": [
{
"fileName": "function.ts",
"line": 4,
"line": 1,
"character": 0,
"url": "typedoc://function.ts#L4"
"url": "typedoc://function.ts#L1"
}
]
},
Expand Down Expand Up @@ -2897,9 +2897,9 @@
"sources": [
{
"fileName": "generic-function.ts",
"line": 7,
"line": 1,
"character": 0,
"url": "typedoc://generic-function.ts#L7"
"url": "typedoc://generic-function.ts#L1"
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions src/test/converter/inheritance/specs.json
Expand Up @@ -656,9 +656,9 @@
"sources": [
{
"fileName": "inherit-doc.ts",
"line": 6,
"line": 1,
"character": 0,
"url": "typedoc://inherit-doc.ts#L6"
"url": "typedoc://inherit-doc.ts#L1"
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions src/test/converter/interface/specs.json
Expand Up @@ -649,9 +649,9 @@
"sources": [
{
"fileName": "interface-empty.ts",
"line": 4,
"line": 1,
"character": 0,
"url": "typedoc://interface-empty.ts#L4"
"url": "typedoc://interface-empty.ts#L1"
}
]
},
Expand Down
8 changes: 4 additions & 4 deletions src/test/converter/js/specs.json
Expand Up @@ -98,9 +98,9 @@
"sources": [
{
"fileName": "export-eq-type.js",
"line": 4,
"line": 1,
"character": 0,
"url": "typedoc://export-eq-type.js#L4"
"url": "typedoc://export-eq-type.js#L1"
}
]
},
Expand Down Expand Up @@ -960,9 +960,9 @@
"sources": [
{
"fileName": "index.js",
"line": 55,
"line": 1,
"character": 0,
"url": "typedoc://index.js#L55"
"url": "typedoc://index.js#L1"
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/converter/types/specs.json
Expand Up @@ -936,9 +936,9 @@
"sources": [
{
"fileName": "parens.ts",
"line": 3,
"line": 1,
"character": 0,
"url": "typedoc://parens.ts#L3"
"url": "typedoc://parens.ts#L1"
}
]
},
Expand Down Expand Up @@ -1949,9 +1949,9 @@
"sources": [
{
"fileName": "union-or-intersection.ts",
"line": 4,
"line": 1,
"character": 0,
"url": "typedoc://union-or-intersection.ts#L4"
"url": "typedoc://union-or-intersection.ts#L1"
}
]
}
Expand Down

0 comments on commit 6a7323f

Please sign in to comment.