stencil-public-docs.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. interface ComponentCompilerPropertyComplexType {
  2. /**
  3. * The string of the original type annotation in the Stencil source code
  4. */
  5. original: string;
  6. /**
  7. * A 'resolved' type, where e.g. imported types have been resolved and inlined
  8. *
  9. * For instance, an annotation like `(foo: Foo) => string;` will be
  10. * converted to `(foo: { foo: string }) => string;`.
  11. */
  12. resolved: string;
  13. /**
  14. * A record of the types which were referenced in the assorted type
  15. * annotation in the original source file.
  16. */
  17. references: ComponentCompilerTypeReferences;
  18. }
  19. type ComponentCompilerTypeReferences = Record<string, ComponentCompilerTypeReference>;
  20. interface ComponentCompilerTypeReference {
  21. /**
  22. * A type may be defined:
  23. * - locally (in the same file as the component that uses it)
  24. * - globally
  25. * - by importing it into a file (and is defined elsewhere)
  26. */
  27. location: "local" | "global" | "import";
  28. /**
  29. * The path to the type reference, if applicable (global types should not need a path associated with them)
  30. */
  31. path?: string;
  32. /**
  33. * An ID for this type which is unique within a Stencil project.
  34. */
  35. id: string;
  36. }
  37. interface ComponentCompilerReferencedType {
  38. /**
  39. * The path to the module where the type is declared.
  40. */
  41. path: string;
  42. /**
  43. * The string of the original type annotation in the Stencil source code
  44. */
  45. declaration: string;
  46. /**
  47. * An extracted docstring
  48. */
  49. docstring: string;
  50. }
  51. interface ComponentCompilerEventComplexType {
  52. original: string;
  53. resolved: string;
  54. references: ComponentCompilerTypeReferences;
  55. }
  56. interface ComponentCompilerMethodComplexType {
  57. signature: string;
  58. parameters: JsonDocMethodParameter[];
  59. references: ComponentCompilerTypeReferences;
  60. return: string;
  61. }
  62. /**
  63. * The Type Library holds information about the types which are used in a
  64. * Stencil project. During compilation, Stencil gathers information about the
  65. * types which form part of a component's public API, such as properties
  66. * decorated with `@Prop`, `@Event`, `@Watch`, etc. This type information is
  67. * then added to the Type Library, where it can be accessed later on for
  68. * generating documentation.
  69. *
  70. * This information is included in the file written by the `docs-json` output
  71. * target (see {@link JsonDocs.typeLibrary}).
  72. */
  73. export type JsonDocsTypeLibrary = Record<string, ComponentCompilerReferencedType>;
  74. /**
  75. * A container for JSDoc metadata for a project
  76. */
  77. export interface JsonDocs {
  78. /**
  79. * The metadata for the JSDocs for each component in a Stencil project
  80. */
  81. components: JsonDocsComponent[];
  82. /**
  83. * The timestamp at which the metadata was generated, in the format YYYY-MM-DDThh:mm:ss
  84. */
  85. timestamp: string;
  86. compiler: {
  87. /**
  88. * The name of the compiler that generated the metadata
  89. */
  90. name: string;
  91. /**
  92. * The version of the Stencil compiler that generated the metadata
  93. */
  94. version: string;
  95. /**
  96. * The version of TypeScript that was used to generate the metadata
  97. */
  98. typescriptVersion: string;
  99. };
  100. typeLibrary: JsonDocsTypeLibrary;
  101. }
  102. /**
  103. * Container for JSDoc metadata for a single Stencil component
  104. */
  105. export interface JsonDocsComponent {
  106. /**
  107. * The directory containing the Stencil component, minus the file name.
  108. *
  109. * @example /workspaces/stencil-project/src/components/my-component
  110. */
  111. dirPath?: string;
  112. /**
  113. * The name of the file containing the Stencil component, with no path
  114. *
  115. * @example my-component.tsx
  116. */
  117. fileName?: string;
  118. /**
  119. * The full path of the file containing the Stencil component
  120. *
  121. * @example /workspaces/stencil-project/src/components/my-component/my-component.tsx
  122. */
  123. filePath?: string;
  124. /**
  125. * The path to the component's `readme.md` file, including the filename
  126. *
  127. * @example /workspaces/stencil-project/src/components/my-component/readme.md
  128. */
  129. readmePath?: string;
  130. /**
  131. * The path to the component's `usage` directory
  132. *
  133. * @example /workspaces/stencil-project/src/components/my-component/usage/
  134. */
  135. usagesDir?: string;
  136. /**
  137. * The encapsulation strategy for a component
  138. */
  139. encapsulation: "shadow" | "scoped" | "none";
  140. /**
  141. * The tag name for the component, for use in HTML
  142. */
  143. tag: string;
  144. /**
  145. * The contents of a component's `readme.md` that are user generated.
  146. *
  147. * Auto-generated contents are not stored in this reference.
  148. */
  149. readme: string;
  150. /**
  151. * The description of a Stencil component, found in the JSDoc that sits above the component's declaration
  152. */
  153. docs: string;
  154. /**
  155. * JSDoc tags found in the JSDoc comment written atop a component's declaration
  156. */
  157. docsTags: JsonDocsTag[];
  158. /**
  159. * The text from the class-level JSDoc for a Stencil component, if present.
  160. */
  161. overview?: string;
  162. /**
  163. * A mapping of usage example file names to their contents for the component.
  164. */
  165. usage: JsonDocsUsage;
  166. /**
  167. * Array of metadata for a component's `@Prop`s
  168. */
  169. props: JsonDocsProp[];
  170. /**
  171. * Array of metadata for a component's `@Method`s
  172. */
  173. methods: JsonDocsMethod[];
  174. /**
  175. * Array of metadata for a component's `@Event`s
  176. */
  177. events: JsonDocsEvent[];
  178. /**
  179. * Array of metadata for a component's `@Listen` handlers
  180. */
  181. listeners: JsonDocsListener[];
  182. /**
  183. * Array of metadata for a component's CSS styling information
  184. */
  185. styles: JsonDocsStyle[];
  186. /**
  187. * Array of component Slot information, generated from `@slot` tags
  188. */
  189. slots: JsonDocsSlot[];
  190. /**
  191. * Array of component Parts information, generate from `@part` tags
  192. */
  193. parts: JsonDocsPart[];
  194. /**
  195. * Array of metadata describing where the current component is used
  196. */
  197. dependents: string[];
  198. /**
  199. * Array of metadata listing the components which are used in current component
  200. */
  201. dependencies: string[];
  202. /**
  203. * Describes a tree of components coupling
  204. */
  205. dependencyGraph: JsonDocsDependencyGraph;
  206. /**
  207. * A deprecation reason/description found following a `@deprecated` tag
  208. */
  209. deprecation?: string;
  210. }
  211. export interface JsonDocsDependencyGraph {
  212. [tagName: string]: string[];
  213. }
  214. /**
  215. * A descriptor for a single JSDoc tag found in a block comment
  216. */
  217. export interface JsonDocsTag {
  218. /**
  219. * The tag name (immediately following the '@')
  220. */
  221. name: string;
  222. /**
  223. * The description that immediately follows the tag name
  224. */
  225. text?: string;
  226. }
  227. export interface JsonDocsValue {
  228. value?: string;
  229. type: string;
  230. }
  231. /**
  232. * A mapping of file names to their contents.
  233. *
  234. * This type is meant to be used when reading one or more usage markdown files associated with a component. For the
  235. * given directory structure:
  236. * ```
  237. * src/components/my-component
  238. * ├── my-component.tsx
  239. * └── usage
  240. * ├── bar.md
  241. * └── foo.md
  242. * ```
  243. * an instance of this type would include the name of the markdown file, mapped to its contents:
  244. * ```ts
  245. * {
  246. * 'bar': STRING_CONTENTS_OF_BAR.MD
  247. * 'foo': STRING_CONTENTS_OF_FOO.MD
  248. * }
  249. * ```
  250. */
  251. export interface JsonDocsUsage {
  252. [key: string]: string;
  253. }
  254. /**
  255. * An intermediate representation of a `@Prop` decorated member's JSDoc
  256. */
  257. export interface JsonDocsProp {
  258. /**
  259. * the name of the prop
  260. */
  261. name: string;
  262. complexType?: ComponentCompilerPropertyComplexType;
  263. /**
  264. * the type of the prop, in terms of the TypeScript type system (as opposed to JavaScript's or HTML's)
  265. */
  266. type: string;
  267. /**
  268. * `true` if the prop was configured as "mutable" where it was declared, `false` otherwise
  269. */
  270. mutable: boolean;
  271. /**
  272. * The name of the attribute that is exposed to configure a compiled web component
  273. */
  274. attr?: string;
  275. /**
  276. * `true` if the prop was configured to "reflect" back to HTML where it (the prop) was declared, `false` otherwise
  277. */
  278. reflectToAttr: boolean;
  279. /**
  280. * the JSDoc description text associated with the prop
  281. */
  282. docs: string;
  283. /**
  284. * JSDoc tags associated with the prop
  285. */
  286. docsTags: JsonDocsTag[];
  287. /**
  288. * The default value of the prop
  289. */
  290. default?: string;
  291. /**
  292. * Deprecation text associated with the prop. This is the text that immediately follows a `@deprecated` tag
  293. */
  294. deprecation?: string;
  295. values: JsonDocsValue[];
  296. /**
  297. * `true` if a component is declared with a '?', `false` otherwise
  298. *
  299. * @example
  300. * ```tsx
  301. * @Prop() componentProps?: any;
  302. * ```
  303. */
  304. optional: boolean;
  305. /**
  306. * `true` if a component is declared with a '!', `false` otherwise
  307. *
  308. * @example
  309. * ```tsx
  310. * @Prop() componentProps!: any;
  311. * ```
  312. */
  313. required: boolean;
  314. }
  315. export interface JsonDocsMethod {
  316. name: string;
  317. docs: string;
  318. docsTags: JsonDocsTag[];
  319. deprecation?: string;
  320. signature: string;
  321. returns: JsonDocsMethodReturn;
  322. parameters: JsonDocMethodParameter[];
  323. complexType: ComponentCompilerMethodComplexType;
  324. }
  325. export interface JsonDocsMethodReturn {
  326. type: string;
  327. docs: string;
  328. }
  329. export interface JsonDocMethodParameter {
  330. name: string;
  331. type: string;
  332. docs: string;
  333. }
  334. export interface JsonDocsEvent {
  335. event: string;
  336. bubbles: boolean;
  337. cancelable: boolean;
  338. composed: boolean;
  339. complexType: ComponentCompilerEventComplexType;
  340. docs: string;
  341. docsTags: JsonDocsTag[];
  342. deprecation?: string;
  343. detail: string;
  344. }
  345. /**
  346. * Type describing a CSS Style, as described by a JSDoc-style comment
  347. */
  348. export interface JsonDocsStyle {
  349. /**
  350. * The name of the style
  351. */
  352. name: string;
  353. /**
  354. * The type/description associated with the style
  355. */
  356. docs: string;
  357. /**
  358. * The annotation used in the JSDoc of the style (e.g. `@prop`)
  359. */
  360. annotation: string;
  361. /**
  362. * The mode associated with the style
  363. */
  364. mode: string | undefined;
  365. }
  366. export interface JsonDocsListener {
  367. event: string;
  368. target?: string;
  369. capture: boolean;
  370. passive: boolean;
  371. }
  372. /**
  373. * A descriptor for a slot
  374. *
  375. * Objects of this type are translated from the JSDoc tag, `@slot`
  376. */
  377. export interface JsonDocsSlot {
  378. /**
  379. * The name of the slot. Defaults to an empty string for an unnamed slot.
  380. */
  381. name: string;
  382. /**
  383. * A textual description of the slot.
  384. */
  385. docs: string;
  386. }
  387. /**
  388. * A descriptor of a CSS Shadow Part
  389. *
  390. * Objects of this type are translated from the JSDoc tag, `@part`, or the 'part'
  391. * attribute on a component in TSX
  392. */
  393. export interface JsonDocsPart {
  394. /**
  395. * The name of the Shadow part
  396. */
  397. name: string;
  398. /**
  399. * A textual description of the Shadow part.
  400. */
  401. docs: string;
  402. }
  403. /**
  404. * Represents a parsed block comment in a CSS, Sass, etc. file for a custom property.
  405. */
  406. export interface StyleDoc {
  407. /**
  408. * The name of the CSS property
  409. */
  410. name: string;
  411. /**
  412. * The user-defined description of the CSS property
  413. */
  414. docs: string;
  415. /**
  416. * The JSDoc-style annotation (e.g. `@prop`) that was used in the block comment to detect the comment.
  417. * Used to inform Stencil where the start of a new property's description starts (and where the previous description
  418. * ends).
  419. */
  420. annotation: "prop";
  421. /**
  422. * The Stencil style-mode that is associated with this property.
  423. */
  424. mode: string | undefined;
  425. }
  426. export {};