|
| 1 | +declare module "dox" { |
| 2 | + export interface ParseCommentOptions { |
| 3 | + skipSingleStar?: boolean; |
| 4 | + skipPrefixes?: string[]; |
| 5 | + raw?: boolean; |
| 6 | + }; |
| 7 | + |
| 8 | + export interface CommentDescription { |
| 9 | + full: string; |
| 10 | + summary: string; |
| 11 | + body: string; |
| 12 | + } |
| 13 | + |
| 14 | + export interface Comment { |
| 15 | + /** array of tag objects */ |
| 16 | + tags: Tag[]; |
| 17 | + /** the first line of the comment */ |
| 18 | + description: CommentDescription; |
| 19 | + /** true when "@api private" is used */ |
| 20 | + isPrivate: boolean; |
| 21 | + isConstructor: boolean; |
| 22 | + line: number; |
| 23 | + /** lines following the description */ |
| 24 | + body: any; |
| 25 | + /** both the description and the body */ |
| 26 | + content: any; |
| 27 | + codeStart: number; |
| 28 | + code: string; |
| 29 | + ctx: ContextPatternMatchersCtx; |
| 30 | + ignore: boolean; |
| 31 | + line: number; |
| 32 | + } |
| 33 | + |
| 34 | + export interface Tag { |
| 35 | + string: string; |
| 36 | + /** from "@param"/"@property"/"@template", name of parameter/property */ |
| 37 | + name?: string; |
| 38 | + /** text after various tags */ |
| 39 | + description?: string; |
| 40 | + /** from "@see", everything before "http" */ |
| 41 | + title?: string; |
| 42 | + /** from "@see" */ |
| 43 | + url?: string; |
| 44 | + /** from "@see" */ |
| 45 | + local?: string; |
| 46 | + /** when "@api private" this field will be "private" (what is after "@api") and in case of "@protected"/"@public"/"@private" will be the tag itself */ |
| 47 | + visibility?: string; |
| 48 | + /** the string after "@memberOf"/"@lends" */ |
| 49 | + parent?: string; |
| 50 | + /** the string after "@extends"/"@implements"/"@augments" */ |
| 51 | + otherClass?: string; |
| 52 | + /** from "@borrows" */ |
| 53 | + otherMemberName?: string; |
| 54 | + /** from "@borrows" */ |
| 55 | + thisMemberName?: string; |
| 56 | + /** all parsed types from tags that support it, like "@param" */ |
| 57 | + types?: string[]; |
| 58 | + /** from "@description" */ |
| 59 | + full?: string; |
| 60 | + /** from "@description" */ |
| 61 | + summary?: string; |
| 62 | + /** from "@description" */ |
| 63 | + body?: string; |
| 64 | + typesDescription?: string; |
| 65 | + /** |
| 66 | + * "true" when the property is marked optional |
| 67 | + * @example |
| 68 | + * @param {string} [optionalProperty] |
| 69 | + * @param {string} nonOptionalProperty |
| 70 | + */ |
| 71 | + optional?: boolean; |
| 72 | + /** |
| 73 | + * "true" when the property is marked nullable |
| 74 | + * @example |
| 75 | + * @param {?string} nullable |
| 76 | + * @param {string} normal |
| 77 | + * @param {!string} nonNullable |
| 78 | + */ |
| 79 | + nullable?: boolean; |
| 80 | + /** |
| 81 | + * "true" when the property is marked non-nullable |
| 82 | + * @example |
| 83 | + * @param {?string} nullable |
| 84 | + * @param {string} normal |
| 85 | + * @param {!string} nonNullable |
| 86 | + */ |
| 87 | + nonNullable?: boolean; |
| 88 | + /** |
| 89 | + * "true" when using the spread type |
| 90 | + * @example |
| 91 | + * @param {...string} spread |
| 92 | + * @param {string} nonSpread |
| 93 | + */ |
| 94 | + variable?: boolean; |
| 95 | + } |
| 96 | + |
| 97 | + export function api(comments: Comment[]): string; |
| 98 | + /** Parse comments in the given string of `js`. */ |
| 99 | + export function parseComments(js: string, options: ParseCommentOptions): Comment[]; |
| 100 | + /** Removes excess indentation from string of code. */ |
| 101 | + export function trimIndentation(str: string): string; |
| 102 | + /** |
| 103 | + * Parse the given comment `str`. |
| 104 | + * |
| 105 | + * The comment object returned contains the following |
| 106 | + */ |
| 107 | + export function parseComment(str: string, options: ParseCommentOptions): any; |
| 108 | + /** |
| 109 | + * Extracts different parts of a tag by splitting string into pieces separated by whitespace. If the white spaces are |
| 110 | + * somewhere between curly braces (which is used to indicate param/return type in JSDoc) they will not be used to split |
| 111 | + * the string. This allows to specify jsdoc tags without the need to eliminate all white spaces i.e. {number | string} |
| 112 | + */ |
| 113 | + export function extractTagParts(str: any): string[]; |
| 114 | + /** Parse tag string "@param {Array} name description" etc. */ |
| 115 | + export function parseTag(str: any): Tag; |
| 116 | + /** |
| 117 | + * Parse tag type string "{Array|Object}" etc. |
| 118 | + * This function also supports complex type descriptors like in jsDoc or even the enhanced syntax used by the |
| 119 | + * [google closure compiler](https://developers.google.com/closure/compiler/docs/js-for-compiler#types) |
| 120 | + * |
| 121 | + * The resulting array from the type descriptor `{number|string|{name:string,age:number|date}}` would look like this: |
| 122 | + */ |
| 123 | + export function parseTagTypes(str: string, tag: Tag): string[]; |
| 124 | + /** |
| 125 | + * Determine if a parameter is optional. |
| 126 | + * |
| 127 | + * Examples: |
| 128 | + * JSDoc: {Type} [name] |
| 129 | + * Google: {Type=} name |
| 130 | + * TypeScript: {Type?} name |
| 131 | + */ |
| 132 | + export function parseParamOptional(tag: Tag): boolean; |
| 133 | + /** |
| 134 | + * Parse the context from the given `str` of js. |
| 135 | + * |
| 136 | + * This method attempts to discover the context |
| 137 | + * for the comment based on it's code. Currently |
| 138 | + * supports: |
| 139 | + * |
| 140 | + * - classes |
| 141 | + * - class constructors |
| 142 | + * - class methods |
| 143 | + * - function statements |
| 144 | + * - function expressions |
| 145 | + * - prototype methods |
| 146 | + * - prototype properties |
| 147 | + * - methods |
| 148 | + * - properties |
| 149 | + * - declarations |
| 150 | + */ |
| 151 | + export function parseCodeContext(str: string, parentContext?: any | undefined): any; |
| 152 | + |
| 153 | + export interface ContextPatternMatchersCtx { |
| 154 | + type: 'class' | 'constructor' | 'method' | 'function' | 'property' | 'prototype' | 'declaration'; |
| 155 | + constructor?: string; |
| 156 | + cons?: string; |
| 157 | + name: string; |
| 158 | + string: string; |
| 159 | + extends?: string; |
| 160 | + value?: string; |
| 161 | + } |
| 162 | + |
| 163 | + export type ContextPatternMatchersFn = (str: string, parentContext?: ContextPatternMatchersCtx) => ContextPatternMatchersCtx; |
| 164 | + |
| 165 | + export let contextPatternMatchers: ContextPatternMatchersFn[]; |
| 166 | +} |
0 commit comments