UNPKG

@protobuf-ts/plugin

Version:

The protocol buffer compiler plugin "protobuf-ts" generates TypeScript, gRPC-web, Twirp, and more.

51 lines (50 loc) 1.93 kB
import * as ts from "typescript"; import { AnyDesc } from "@bufbuild/protobuf"; export declare class CommentGenerator { constructor(); /** * Adds comments from the .proto as a JSDoc block. * * Looks up comments for the given descriptor in * the source code info. * * Adds `@deprecated` tag if the element is * marked deprecated. Also adds @deprecated if * the descriptor is a type (enum, message) and * the entire .proto file is marked deprecated. * * Adds `@generated` tag with source code * information. * * Leading detached comments are added as line * comments in front of the JSDoc block. * * Trailing comments are a bit weird. For .proto * enums and messages, they sit between open * bracket and first member. A message seems to * only ever have a trailing comment if it is * empty. For a simple solution, trailing * comments on enums and messages should simply * be appended to the leading block so that the * information is not discarded. */ addCommentsForDescriptor(node: ts.Node, descriptor: AnyDesc, trailingCommentsMode: 'appendToLeadingBlock' | 'trailingLines'): void; private getComments; private stripTrailingNewlines; /** * Returns a block of source comments (no leading detached!), * with @generated tags and @deprecated tag (if applicable). */ getCommentBlock(descriptor: AnyDesc, appendTrailingComments?: boolean): string; /** * Creates string like "@generated from protobuf field: string foo = 1;" */ makeGeneratedTag(desc: AnyDesc): string; /** * Returns "@deprecated\n" if explicitly deprecated. * For top level types, also returns "@deprecated\n" if entire file is deprecated. * Otherwise, returns "". */ makeDeprecatedTag(desc: AnyDesc): "" | "@deprecated\n"; private static isDeprecated; }