UNPKG

voluptasmollitia

Version:
60 lines (52 loc) 1.77 kB
/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. import { IDocNodeParameters, DocNode } from '@microsoft/tsdoc'; import { CustomDocNodeKind } from './CustomDocNodeKind'; /** * Constructor parameters for {@link DocHeading}. */ export interface IDocHeadingParameters extends IDocNodeParameters { title: string; level?: number; } /** * Represents a section header similar to an HTML `<h1>` or `<h2>` element. */ export class DocHeading extends DocNode { public readonly title: string; public readonly level: number; /** * Don't call this directly. Instead use {@link TSDocParser} * @internal */ public constructor(parameters: IDocHeadingParameters) { super(parameters); this.title = parameters.title; this.level = parameters.level !== undefined ? parameters.level : 1; if (this.level < 1 || this.level > 5) { throw new Error( 'IDocHeadingParameters.level must be a number between 1 and 5' ); } } /** @override */ public get kind(): string { return CustomDocNodeKind.Heading; } }