[READ-ONLY] a fast, modern browser for the npm registry
at main 139 lines 2.9 kB view raw
1/** 2 * Types for deno doc JSON output. 3 * 4 * These types represent the structure of the JSON output from `deno doc --json`. 5 * In an ideal world, we'd generate these or implement our own AST / parser. 6 * That might be an endgame, but there's a lot of value in using deno's implementation, too. 7 * Well trodden ground and all that. 8 * 9 * @see: https://deno.land/x/deno_doc 10 */ 11 12/** JSDoc tag from deno doc output */ 13export interface JsDocTag { 14 kind: string 15 name?: string 16 doc?: string 17 optional?: boolean 18 type?: string 19} 20 21/** TypeScript type representation from deno doc */ 22export interface TsType { 23 repr: string 24 kind: string 25 keyword?: string 26 typeRef?: { 27 typeName: string 28 typeParams?: TsType[] | null 29 } 30 array?: TsType 31 union?: TsType[] 32 literal?: { 33 kind: string 34 string?: string 35 number?: number 36 boolean?: boolean 37 } 38} 39 40/** Function parameter from deno doc */ 41export interface FunctionParam { 42 kind: string 43 name: string 44 optional?: boolean 45 tsType?: TsType 46} 47 48/** A documentation node from deno doc output */ 49export interface DenoDocNode { 50 name: string 51 kind: string 52 isDefault?: boolean 53 location?: { 54 filename: string 55 line: number 56 col: number 57 } 58 declarationKind?: string 59 jsDoc?: { 60 doc?: string 61 tags?: JsDocTag[] 62 } 63 functionDef?: { 64 params?: FunctionParam[] 65 returnType?: TsType 66 isAsync?: boolean 67 isGenerator?: boolean 68 typeParams?: Array<{ name: string }> 69 } 70 classDef?: { 71 isAbstract?: boolean 72 properties?: Array<{ 73 name: string 74 tsType?: TsType 75 readonly?: boolean 76 optional?: boolean 77 isStatic?: boolean 78 jsDoc?: { doc?: string } 79 }> 80 methods?: Array<{ 81 name: string 82 isStatic?: boolean 83 functionDef?: { 84 params?: FunctionParam[] 85 returnType?: TsType 86 } 87 jsDoc?: { doc?: string } 88 }> 89 constructors?: Array<{ 90 params?: FunctionParam[] 91 }> 92 extends?: TsType 93 implements?: TsType[] 94 } 95 interfaceDef?: { 96 properties?: Array<{ 97 name: string 98 tsType?: TsType 99 readonly?: boolean 100 optional?: boolean 101 jsDoc?: { doc?: string } 102 }> 103 methods?: Array<{ 104 name: string 105 params?: FunctionParam[] 106 returnType?: TsType 107 jsDoc?: { doc?: string } 108 }> 109 extends?: TsType[] 110 typeParams?: Array<{ name: string }> 111 } 112 typeAliasDef?: { 113 tsType?: TsType 114 typeParams?: Array<{ name: string }> 115 } 116 variableDef?: { 117 tsType?: TsType 118 kind?: string 119 } 120 enumDef?: { 121 members?: Array<{ name: string; init?: TsType }> 122 } 123 namespaceDef?: { 124 elements?: DenoDocNode[] 125 } 126} 127 128/** Raw output from deno doc --json */ 129export interface DenoDocResult { 130 version: number 131 nodes: DenoDocNode[] 132} 133 134/** Result of documentation generation */ 135export interface DocsGenerationResult { 136 html: string 137 toc: string | null 138 nodes: DenoDocNode[] 139}