UNPKG

@microsoft/api-documenter

Version:

Read JSON files from api-extractor, generate documentation pages

56 lines 1.82 kB
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. import { DocNode } from '@microsoft/tsdoc'; import { CustomDocNodeKind } from './CustomDocNodeKind'; import { DocTableRow } from './DocTableRow'; /** * Represents table, similar to an HTML `<table>` element. */ export class DocTable extends DocNode { constructor(parameters, rows) { super(parameters); this.header = new DocTableRow({ configuration: this.configuration }); this._rows = []; if (parameters) { if (parameters.headerTitles) { if (parameters.headerCells) { throw new Error('IDocTableParameters.headerCells and IDocTableParameters.headerTitles' + ' cannot both be specified'); } for (const cellText of parameters.headerTitles) { this.header.addPlainTextCell(cellText); } } else if (parameters.headerCells) { for (const cell of parameters.headerCells) { this.header.addCell(cell); } } } if (rows) { for (const row of rows) { this.addRow(row); } } } /** @override */ get kind() { return CustomDocNodeKind.Table; } get rows() { return this._rows; } addRow(row) { this._rows.push(row); } createAndAddRow() { const row = new DocTableRow({ configuration: this.configuration }); this.addRow(row); return row; } /** @override */ onGetChildNodes() { return [this.header, ...this._rows]; } } //# sourceMappingURL=DocTable.js.map