Skip to content

Commit c14857e

Browse files
committed
Merge branch 'master' into cary-hu/master
2 parents 3663469 + ec9efa0 commit c14857e

File tree

13 files changed

+122
-18
lines changed

13 files changed

+122
-18
lines changed

.config/typedoc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"MarkedPlugin"
1212
],
1313
"entryPoints": ["../src"],
14-
"entryPointStrategy": "Resolve",
14+
"entryPointStrategy": "resolve",
1515
"excludeExternals": true,
1616
"excludeInternal": false,
1717
"excludePrivate": true,

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Unreleased
22

3+
### Features
4+
5+
- Added support for `*.ghe.com` and `*.github.us` GitHub enterprise domains for source links, #2001.
6+
- Expose `Converter.parseRawComment` for plugins to parse additional markdown files, #2004.
7+
- Added defined in links for classes, enums #180.
8+
9+
### Bug Fixes
10+
11+
- Fixed missing `sources` property on signature reflections #1996.
12+
13+
### Thanks!
14+
15+
- @chadhietala
16+
317
## v0.23.7 (2022-07-09)
418

519
### Bug Fixes

src/lib/converter/converter.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export class Converter extends ChildableComponent<
9494

9595
/**
9696
* Triggered when the converter has created a signature reflection.
97-
* The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} and a `ts.Node?`
97+
* The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} and
98+
* `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`
9899
* @event
99100
*/
100101
static readonly EVENT_CREATE_SIGNATURE = ConverterEvents.CREATE_SIGNATURE;
@@ -183,6 +184,18 @@ export class Converter extends ChildableComponent<
183184
return convertType(context, node);
184185
}
185186

187+
/**
188+
* Parse the given file into a comment. Intended to be used with markdown files.
189+
*/
190+
parseRawComment(file: MinimalSourceFile) {
191+
return parseComment(
192+
lexCommentString(file.text),
193+
this.config,
194+
file,
195+
this.application.logger
196+
);
197+
}
198+
186199
/**
187200
* Compile the files within the given context and convert the compiler symbols to reflections.
188201
*
@@ -264,11 +277,8 @@ export class Converter extends ChildableComponent<
264277

265278
if (entryPoint.readmeFile) {
266279
const readme = readFile(entryPoint.readmeFile);
267-
const comment = parseComment(
268-
lexCommentString(readme),
269-
context.converter.config,
270-
new MinimalSourceFile(readme, entryPoint.readmeFile),
271-
context.logger
280+
const comment = this.parseRawComment(
281+
new MinimalSourceFile(readme, entryPoint.readmeFile)
272282
);
273283

274284
if (comment.blockTags.length || comment.modifierTags.size) {

src/lib/converter/factories/signature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function createSignature(
9898
break;
9999
}
100100

101-
context.trigger(ConverterEvents.CREATE_SIGNATURE, sigRef);
101+
context.trigger(ConverterEvents.CREATE_SIGNATURE, sigRef, declaration);
102102
}
103103

104104
function convertParameters(

src/lib/converter/plugins/PackagePlugin.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import type { Context } from "../context";
77
import { BindOption, EntryPointStrategy, readFile } from "../../utils";
88
import { getCommonDirectory } from "../../utils/fs";
99
import { nicePath } from "../../utils/paths";
10-
import { lexCommentString } from "../comments/rawLexer";
11-
import { parseComment } from "../comments/parser";
1210
import { MinimalSourceFile } from "../../utils/minimalSourceFile";
1311

1412
/**
@@ -105,11 +103,8 @@ export class PackagePlugin extends ConverterComponent {
105103
const project = context.project;
106104
if (this.readmeFile) {
107105
const readme = readFile(this.readmeFile);
108-
const comment = parseComment(
109-
lexCommentString(readme),
110-
context.converter.config,
111-
new MinimalSourceFile(readme, this.readmeFile),
112-
context.logger
106+
const comment = context.converter.parseRawComment(
107+
new MinimalSourceFile(readme, this.readmeFile)
113108
);
114109

115110
if (comment.blockTags.length || comment.modifierTags.size) {

src/lib/converter/plugins/SourcePlugin.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class SourcePlugin extends ConverterComponent {
5050
this.listenTo(this.owner, {
5151
[Converter.EVENT_END]: this.onEnd,
5252
[Converter.EVENT_CREATE_DECLARATION]: this.onDeclaration,
53-
[Converter.EVENT_CREATE_SIGNATURE]: this.onDeclaration,
53+
[Converter.EVENT_CREATE_SIGNATURE]: this.onSignature,
5454
[Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,
5555
});
5656
}
@@ -101,6 +101,31 @@ export class SourcePlugin extends ConverterComponent {
101101
}
102102
}
103103

104+
private onSignature(
105+
_context: Context,
106+
reflection: Reflection,
107+
sig?:
108+
| ts.SignatureDeclaration
109+
| ts.IndexSignatureDeclaration
110+
| ts.JSDocSignature
111+
) {
112+
if (this.disableSources || !sig) return;
113+
114+
const sourceFile = sig.getSourceFile();
115+
const fileName = sourceFile.fileName;
116+
this.fileNames.add(fileName);
117+
118+
const position = ts.getLineAndCharacterOfPosition(
119+
sourceFile,
120+
sig.getStart()
121+
);
122+
123+
reflection.sources ||= [];
124+
reflection.sources.push(
125+
new SourceReference(fileName, position.line + 1, position.character)
126+
);
127+
}
128+
104129
/**
105130
* Triggered when the converter begins resolving a project.
106131
*

src/lib/converter/utils/repository.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class Repository {
7171

7272
for (let i = 0, c = repoLinks.length; i < c; i++) {
7373
let match =
74-
/(github(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/.exec(
74+
/(github(?!.us)(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/.exec(
7575
repoLinks[i]
7676
);
7777

@@ -82,6 +82,16 @@ export class Repository {
8282
);
8383
}
8484

85+
// Github Enterprise
86+
if (!match) {
87+
match = /(\w+\.ghe.com)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
88+
}
89+
90+
// Github Enterprise
91+
if (!match) {
92+
match = /(\w+\.github.us)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
93+
}
94+
8595
if (!match) {
8696
match = /(bitbucket.org)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
8797
}

src/lib/output/themes/default/templates/reflection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export function reflectionTemplate(context: DefaultThemeRenderContext, props: Pa
7171
context.parameter(props.model.indexSignature.type.declaration)}
7272
</section>
7373
)}
74+
{!props.model.signatures && context.memberSources(props.model)}
7475
</>
7576
)}
7677
{!!props.model.children?.length && context.index(props.model)}

src/test/Repository.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,32 @@ describe("Repository", function () {
4646
equal(repository.type, RepositoryType.GitHub);
4747
});
4848

49+
it("handles a ghe.com URL", function () {
50+
const mockRemotes = [
51+
"ssh://org@bigcompany.ghe.com/joebloggs/foobar.git",
52+
];
53+
54+
const repository = new Repository("", "", mockRemotes);
55+
56+
equal(repository.hostname, "bigcompany.ghe.com");
57+
equal(repository.user, "joebloggs");
58+
equal(repository.project, "foobar");
59+
equal(repository.type, RepositoryType.GitHub);
60+
});
61+
62+
it("handles a github.us URL", function () {
63+
const mockRemotes = [
64+
"ssh://org@bigcompany.github.us/joebloggs/foobar.git",
65+
];
66+
67+
const repository = new Repository("", "", mockRemotes);
68+
69+
equal(repository.hostname, "bigcompany.github.us");
70+
equal(repository.user, "joebloggs");
71+
equal(repository.project, "foobar");
72+
equal(repository.type, RepositoryType.GitHub);
73+
});
74+
4975
it("handles a Bitbucket HTTPS URL", function () {
5076
const mockRemotes = [
5177
"https://joebloggs@bitbucket.org/joebloggs/foobar.git",

src/test/converter/comment/specs.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@
9999
"kind": 2048,
100100
"kindString": "Method",
101101
"flags": {},
102+
"sources": [
103+
{
104+
"fileName": "comment.ts",
105+
"line": 77,
106+
"character": 4,
107+
"url": "typedoc://comment.ts#L77"
108+
}
109+
],
102110
"signatures": [
103111
{
104112
"id": 22,

0 commit comments

Comments
 (0)