public render()

in src/docgen/render/markdown-doc.ts [160:192]


  public render(headerSize: number = 0): string {
    if (headerSize > 6) {
      // headers are mapped to `h1-h6` html elements.
      // passed that, markdown just renders `#` signs.
      // lets see if and when we'll hit this limit.
      throw new Error('Unable to render markdown. Header limit (6) reached.');
    }

    const content: string[] = [];
    if (this.header) {
      const heading = `${'#'.repeat(headerSize)} ${this.header}`;

      // temporary hack to avoid breaking Construct Hub
      const headerSpan = !!process.env.HEADER_SPAN;
      if (headerSpan) {
        content.push(
          `${heading} <span data-heading-title="${this.options.header?.title}" data-heading-id="${this.id}"></span>`,
        );
      } else {
        content.push(`${heading} <a name="${this.options.header?.title}" id="${this.id}"></a>`);
      }
      content.push('');
    }

    for (const line of this._lines) {
      content.push(`${line}`);
    }

    for (const section of this._sections) {
      content.push(section.render(headerSize + 1));
    }
    return content.join('\n');
  }