private renderRemarks()

in packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts [111:160]


  private renderRemarks(docs: spec.Docs, apiLocation: ApiLocation): string[] {
    const ret: string[] = [];

    if (docs.remarks) {
      const translated = markDownToXmlDoc(
        this.convertSamplesInMarkdown(docs.remarks, apiLocation),
      );
      ret.push(...translated.split('\n'));
      ret.push('');
    }

    // All the "tags" need to be rendered with empyt lines between them or they'll be word wrapped.

    if (docs.default) {
      emitDocAttribute('default', docs.default);
    }
    if (docs.stability && shouldMentionStability(docs.stability)) {
      emitDocAttribute(
        'stability',
        this.nameutils.capitalizeWord(docs.stability),
      );
    }
    if (docs.see) {
      emitDocAttribute('see', docs.see);
    }
    if (docs.subclassable) {
      emitDocAttribute('subclassable', '');
    }
    for (const [k, v] of Object.entries(docs.custom ?? {})) {
      const extraSpace = k === 'link' ? ' ' : ''; // Extra space for '@link' to keep unit tests happy
      emitDocAttribute(k, v + extraSpace);
    }

    // Remove leading and trailing empty lines
    while (ret.length > 0 && ret[0] === '') {
      ret.shift();
    }
    while (ret.length > 0 && ret[ret.length - 1] === '') {
      ret.pop();
    }

    return ret;

    function emitDocAttribute(name: string, contents: string) {
      const ls = contents.split('\n');
      ret.push(`<strong>${ucFirst(name)}</strong>: ${ls[0]}`);
      ret.push(...ls.slice(1));
      ret.push('');
    }
  }