private _visitDocumentation()

in src/assembler.ts [1595:1631]


  private _visitDocumentation(
    sym: ts.Symbol,
    context: EmitContext,
  ): { readonly docs?: spec.Docs; readonly hints: TypeSystemHints } {
    const result = parseSymbolDocumentation(sym, this._typeChecker);

    for (const diag of result.diagnostics ?? []) {
      this._diagnostics.push(
        JsiiDiagnostic.JSII_7999_DOCUMENTATION_ERROR.create(sym.valueDeclaration ?? sym.declarations?.[0], diag),
      );
    }

    const decl = sym.valueDeclaration ?? sym.declarations?.[0];
    // The @struct hint is only valid for interface declarations
    if (decl && !ts.isInterfaceDeclaration(decl) && result.hints.struct) {
      this._diagnostics.push(
        JsiiDiagnostic.JSII_7001_ILLEGAL_HINT.create(
          _findHint(decl, 'struct')!,
          'struct',
          'interfaces with only readonly properties',
        ).addRelatedInformationIf(ts.getNameOfDeclaration(decl) ?? decl, 'The annotated declaration is here'),
      );
      // Clean up the bad hint...
      delete (result.hints as any).struct;
    }

    // Apply the current context's stability if none was specified locally.
    if (result.docs.stability == null) {
      result.docs.stability = context.stability;
    }

    const allUndefined = Object.values(result.docs).every((v) => v === undefined);
    return {
      docs: !allUndefined ? result.docs : undefined,
      hints: result.hints,
    };
  }