UNPKG

5.17 kBTypeScriptView Raw
1export type StyleListFormat = "none" | "grouped" | "table" | "dl";
2export type RenderListFormat = "list" | "table";
3export type MemberIndexFormat = "grouped" | "list";
4
5export interface RenderOptions {
6 /**
7 * Raw template data to use. Useful when you already have template data, obtained from .getTemplateData.
8 * Either files, source or data must be supplied.
9 */
10 data?: object[] | undefined;
11 /**
12 * The template the supplied documentation will be rendered into.
13 * Use the default or supply your own template for full control over the output.
14 */
15 template?: string | undefined;
16 /**
17 * The initial heading depth.
18 * For example, with a value of 2 the top-level markdown headings look like "## The heading".
19 */
20 "heading-depth"?: number | undefined;
21 /**
22 * Specifies the default language used in '@example' blocks (for syntax-highlighting purposes).
23 * In gfm mode, each '@example' is wrapped in a fenced-code block. Example usage: --example-lang js.
24 * Use the special value none for no specific language.
25 * While using this option, you can override the supplied language
26 * for any '@example' by specifying the @lang subtag,
27 * e.g @example @lang hbs. Specifying @example @lang off will disable code blocks for that example.
28 */
29 "example-lang"?: string | undefined;
30 /**
31 * Use an installed package containing helper and/or partial overrides.
32 */
33 plugin?: string | string[] | undefined;
34 /**
35 * handlebars helper files to override or extend the default set.
36 */
37 helper?: string | string[] | undefined;
38 /**
39 * handlebars partial files to override or extend the default set.
40 */
41 partial?: string | string[] | undefined;
42 /**
43 * Format identifier names in the code style,
44 * (i.e. format using backticks or <code></code>).
45 */
46 "name-format"?: string | undefined;
47 /**
48 * By default, dmd generates github-flavoured markdown.
49 * Not all markdown parsers render gfm correctly.
50 * If your generated docs look incorrect on sites other than Github
51 * (e.g. npmjs.org) try enabling this option to disable Github-specific syntax.
52 */
53 "no-gfm"?: boolean | undefined;
54 /**
55 * Put <hr> breaks between identifiers. Improves readability on bulky docs.
56 */
57 separators?: boolean | undefined;
58 "module-index-format"?: StyleListFormat | undefined;
59 "global-index-format"?: StyleListFormat | undefined;
60 /**
61 * Two options to render parameter lists: 'list' or 'table' (default).
62 * Table format works well in most cases but switch to list if things begin to look crowded / squashed.
63 */
64 "param-list-format"?: RenderListFormat | undefined;
65 "property-list-format"?: RenderListFormat | undefined;
66 "member-index-format"?: MemberIndexFormat | undefined;
67}
68
69export interface JsdocOptions {
70 /**
71 * By default results are cached to speed up repeat invocations.
72 * Set to true to disable this.
73 */
74 "no-cache"?: boolean | undefined;
75 /**
76 * One or more filenames to process.
77 * Accepts globs (e.g. *.js). Either files, source or data must be supplied.
78 */
79 files: string | string[];
80 /**
81 * A string containing source code to process.
82 * Either files, source or data must be supplied.
83 */
84 source?: string | undefined;
85 /**
86 * The path to the jsdoc configuration file.
87 * Default: path/to/jsdoc/conf.json.
88 */
89 configure?: string | undefined;
90}
91
92/**
93 * Returns markdown documentation from jsdoc-annotated source code.
94 */
95export function render(options: RenderOptions | JsdocOptions): Promise<string>;
96
97/**
98 * Sync version of render.
99 */
100export function renderSync(options: RenderOptions | JsdocOptions): string;
101
102/**
103 * Returns the template data (jsdoc-parse output) which is fed into the output template (dmd).
104 */
105export function getTemplateData(options: JsdocOptions): Promise<object[]>;
106
107/**
108 * Sync version of getTemplateData.
109 */
110export function getTemplateDataSync(options: JsdocOptions): object[];
111
112/**
113 * Returns raw data direct from the underlying jsdoc3.
114 */
115export function getJsdocData(options: JsdocOptions): Promise<object[]>;
116
117/**
118 * Sync version of getJsdocData.
119 */
120export function getJsdocDataSync(options: JsdocOptions): object[];
121
122/**
123 * By default, the output of each invocation of the main generation methods (render, getTemplateData etc)
124 * is stored in the cache (your system's temporary directory).
125 * Future jsdoc2md invocations with the same input options and source code will return the output immediately from cache,
126 * making the tool much faster/cheaper. If the input options or source code changes,
127 * fresh output will be generated. This method clears the cache,
128 * which you should never need to do unless the cache is failing for some reason.
129 * On Mac OSX, the system tmpdir clears itself every few days meaning your jsdoc2md cache will also be routinely cleared.
130 */
131export function clear(): Promise<void>;
132
133/**
134 * Returns all jsdoc namepaths found in the supplied source code.
135 */
136export function getNamepaths(options: JsdocOptions): Promise<object>;