UNPKG

4.13 kBTypeScriptView Raw
1import WebpackDevServer from 'webpack-dev-server';
2import { Configuration, LoaderContext } from 'webpack';
3import { TransformOptions } from 'buble';
4import { Handler, DocumentationObject, PropDescriptor } from 'react-docgen';
5import { ASTNode } from 'ast-types';
6import { NodePath } from 'ast-types/lib/node-path';
7import { Styles } from 'jss';
8import { RecursivePartial } from './RecursivePartial';
9import { ExpandMode } from './RsgComponent';
10import { PropsObject } from './RsgPropsObject';
11import { CodeExample } from './RsgExample';
12import { ConfigSection, Section } from './RsgSection';
13import { Theme } from './RsgTheme';
14declare type OptionsType = {
15 displayName: string;
16 file: string;
17 shouldShowDefaultExample: string;
18 customLangs: string[];
19};
20export interface StyleguidistLoaderContext extends LoaderContext<OptionsType> {
21 _styleguidist: SanitizedStyleguidistConfig;
22}
23interface BaseStyleguidistConfig {
24 assetsDir: string | string[];
25 tocMode: ExpandMode;
26 compilerConfig: TransformOptions;
27 components: (() => string[]) | string | string[];
28 configDir: string;
29 context: Record<string, any>;
30 contextDependencies: string[];
31 configureServer(server: WebpackDevServer, env: string): string;
32 dangerouslyUpdateWebpackConfig: (server: Configuration, env: string) => Configuration;
33 defaultExample: string | false;
34 exampleMode: ExpandMode;
35 editorConfig: {
36 theme: string;
37 };
38 getComponentPathLine(componentPath: string): string;
39 getExampleFilename(componentPath: string): string;
40 handlers: (componentPath: string) => Handler[];
41 ignore: string[];
42 logger: {
43 info(message: string): void;
44 warn(message: string): void;
45 debug(message: string): void;
46 };
47 minimize: boolean;
48 mountPointId: string;
49 moduleAliases: Record<string, string>;
50 pagePerSection: boolean;
51 previewDelay: number;
52 printBuildInstructions(config: SanitizedStyleguidistConfig): void;
53 printServerInstructions(config: SanitizedStyleguidistConfig, options: {
54 isHttps: boolean;
55 }): void;
56 propsParser(filePath: string, code: string, resolver: (ast: ASTNode, parser: {
57 parse: (input: string) => ASTNode;
58 }) => NodePath<any, any> | NodePath[], handlers: Handler[]): DocumentationObject;
59 require: string[];
60 resolver(ast: ASTNode, parser: {
61 parse: (code: string) => ASTNode;
62 }): NodePath<any, any> | NodePath[];
63 ribbon?: {
64 text?: string;
65 url: string;
66 };
67 serverHost: string;
68 serverPort: number;
69 showCode: boolean;
70 showUsage: boolean;
71 showSidebar: boolean;
72 skipComponentsWithoutExample: boolean;
73 sortProps(props: PropDescriptor[]): PropDescriptor[];
74 styleguideComponents: Record<string, string>;
75 styleguideDir: string;
76 styles: Styles | string | ((theme: Theme) => Styles);
77 template: any;
78 theme: RecursivePartial<Theme> | string;
79 title: string;
80 updateDocs(doc: PropsObject, file: string): PropsObject;
81 updateExample(props: Omit<CodeExample, 'type'>, ressourcePath: string): Omit<CodeExample, 'type'>;
82 updateWebpackConfig(config: Configuration): Configuration;
83 usageMode: ExpandMode;
84 verbose: boolean;
85 version: string;
86 webpackConfig: Configuration | ((env?: string) => Configuration);
87}
88export interface ProcessedStyleguidistConfig extends BaseStyleguidistConfig {
89 sections: Section[];
90 theme: RecursivePartial<Theme>;
91 styles: ((th: Theme) => Styles) | Styles;
92}
93export declare type ProcessedStyleguidistCSSConfig = Pick<ProcessedStyleguidistConfig, 'theme'> & Pick<ProcessedStyleguidistConfig, 'styles'>;
94export interface SanitizedStyleguidistConfig extends BaseStyleguidistConfig {
95 sections: ConfigSection[];
96}
97/**
98 * definition of the config object where everything is optional
99 * note that teh default example can be both a string and a boolean but ends
100 * up only being a string after sanitizing
101 */
102export interface StyleguidistConfig extends RecursivePartial<Omit<SanitizedStyleguidistConfig, 'defaultExample'>> {
103 defaultExample?: string | boolean;
104}
105export {};
106
\No newline at end of file