docgen: fix markdown links
This commit is contained in:
@@ -44,11 +44,13 @@ export default class ApiDocPrinter {
|
||||
);
|
||||
|
||||
for (const api of apiDocs) {
|
||||
printer.header(3, `${api.name.replace(/ApiRef$/, '')}`, api.id);
|
||||
printer.header(3, `${this.apiDisplayName(api)}`, api.id);
|
||||
|
||||
printer.paragraph(api.description);
|
||||
|
||||
const typeLinks = api.interfaceInfos.map(i => `[${i.name}](./${i.name})`);
|
||||
const typeLinks = api.interfaceInfos.map(
|
||||
i => `[${i.name}](${printer.pageLink(i.name)})`,
|
||||
);
|
||||
printer.paragraph(
|
||||
`Implemented type${typeLinks.length > 1 ? 's' : ''}: ${typeLinks.join(
|
||||
', ',
|
||||
@@ -76,7 +78,9 @@ export default class ApiDocPrinter {
|
||||
const apiLinks = apiDocs
|
||||
.filter(ad => ad.interfaceInfos.some(i => i.name === apiType.name))
|
||||
.map(ad => {
|
||||
const link = printer.indexLink() + printer.headerLink(ad.name, ad.id);
|
||||
const link =
|
||||
printer.indexLink() +
|
||||
printer.headerLink(this.apiDisplayName(ad), ad.id);
|
||||
return `[${ad.name}](${link})`;
|
||||
});
|
||||
|
||||
@@ -152,4 +156,8 @@ export default class ApiDocPrinter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private apiDisplayName(api: ApiDoc): string {
|
||||
return api.name.replace(/ApiRef$/, '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ export default class GithubMarkdownPrinter implements MarkdownPrinter {
|
||||
return './README.md';
|
||||
}
|
||||
|
||||
pageLink(name: string) {
|
||||
return `./${name}.md`;
|
||||
}
|
||||
|
||||
srcLink(
|
||||
{ file, lineInFile }: { file: string; lineInFile: number },
|
||||
text?: string,
|
||||
|
||||
@@ -66,6 +66,10 @@ export default class TechdocsMarkdownPrinter implements MarkdownPrinter {
|
||||
return '../';
|
||||
}
|
||||
|
||||
pageLink(name: string) {
|
||||
return `./${name}/`;
|
||||
}
|
||||
|
||||
srcLink(
|
||||
{ file, lineInFile }: { file: string; lineInFile: number },
|
||||
text?: string,
|
||||
|
||||
@@ -106,7 +106,10 @@ export type MarkdownPrinter = {
|
||||
code(options: { text: string; links?: TypeLink[] }): void;
|
||||
|
||||
headerLink(header: string, id?: string): string;
|
||||
/** Link from pages to index */
|
||||
indexLink(): string;
|
||||
/** Link from index to pages */
|
||||
pageLink(name: string): string;
|
||||
srcLink(
|
||||
{ file, lineInFile }: { file: string; lineInFile: number },
|
||||
text?: string,
|
||||
|
||||
Reference in New Issue
Block a user