|
| 1 | +import { TSDocConfiguration, DocNode, DocNodeKind } from '@microsoft/tsdoc'; |
| 2 | +import { DocEmphasisSpan } from './DocEmphasisSpan'; |
| 3 | +import { DocHeading } from './DocHeading'; |
| 4 | +import { DocNoteBox } from './DocNoteBox'; |
| 5 | +import { DocTable } from './DocTable'; |
| 6 | +import { DocTableCell } from './DocTableCell'; |
| 7 | +import { DocTableRow } from './DocTableRow'; |
| 8 | + |
1 | 9 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. |
2 | 10 | // See LICENSE in the project root for license information. |
3 | 11 |
|
4 | 12 | /** |
5 | 13 | * Identifies custom subclasses of {@link DocNode}. |
6 | 14 | */ |
7 | 15 | export const enum CustomDocNodeKind { |
8 | | - Heading = '@microsoft/api-documenter#Heading', |
9 | | - NoteBox = '@microsoft/api-documenter#NoteBox', |
10 | | - Table = '@microsoft/api-documenter#Table', |
11 | | - TableCell = '@microsoft/api-documenter#TableCell', |
12 | | - TableRow = '@microsoft/api-documenter#TableRow' |
| 16 | + EmphasisSpan = 'EmphasisSpan', |
| 17 | + Heading = 'Heading', |
| 18 | + NoteBox = 'NoteBox', |
| 19 | + Table = 'Table', |
| 20 | + TableCell = 'TableCell', |
| 21 | + TableRow = 'TableRow' |
| 22 | +} |
| 23 | + |
| 24 | +export class CustomDocNodes { |
| 25 | + private static _configuration: TSDocConfiguration | undefined; |
| 26 | + |
| 27 | + public static get configuration(): TSDocConfiguration { |
| 28 | + if (CustomDocNodes._configuration === undefined) { |
| 29 | + const configuration: TSDocConfiguration = new TSDocConfiguration(); |
| 30 | + |
| 31 | + configuration.docNodeManager.registerDocNodes('@micrososft/api-documenter', [ |
| 32 | + { docNodeKind: CustomDocNodeKind.EmphasisSpan, constructor: DocEmphasisSpan }, |
| 33 | + { docNodeKind: CustomDocNodeKind.Heading, constructor: DocHeading }, |
| 34 | + { docNodeKind: CustomDocNodeKind.NoteBox, constructor: DocNoteBox }, |
| 35 | + { docNodeKind: CustomDocNodeKind.Table, constructor: DocTable }, |
| 36 | + { docNodeKind: CustomDocNodeKind.TableCell, constructor: DocTableCell }, |
| 37 | + { docNodeKind: CustomDocNodeKind.TableRow, constructor: DocTableRow } |
| 38 | + ]); |
| 39 | + |
| 40 | + configuration.docNodeManager.registerAllowableChildren(CustomDocNodeKind.EmphasisSpan, [ |
| 41 | + DocNodeKind.PlainText, |
| 42 | + DocNodeKind.SoftBreak |
| 43 | + ]); |
| 44 | + |
| 45 | + configuration.docNodeManager.registerAllowableChildren(DocNodeKind.Section, [ |
| 46 | + CustomDocNodeKind.Heading, |
| 47 | + CustomDocNodeKind.NoteBox, |
| 48 | + CustomDocNodeKind.Table |
| 49 | + ]); |
| 50 | + |
| 51 | + configuration.docNodeManager.registerAllowableChildren(DocNodeKind.Paragraph, [ |
| 52 | + CustomDocNodeKind.EmphasisSpan |
| 53 | + ]); |
| 54 | + |
| 55 | + CustomDocNodes._configuration = configuration; |
| 56 | + } |
| 57 | + return CustomDocNodes._configuration; |
| 58 | + } |
13 | 59 | } |
0 commit comments