1
#!/usr/bin/env node
2

3 0
import minimist from 'minimist'
4 0
import extractConfig from './extractConfig'
5 0
import docgen from './docgen'
6
import { SafeDocgenCLIConfig } from './config'
7

8
/**
9
 * run the `config` recursively on pages
10
 * @param config
11
 */
12 0
function run(config: SafeDocgenCLIConfig) {
13 0
	const { pages } = config
14 1
	if (pages) {
15
		// to avoid re-rendering the same pages
16 0
		delete config.pages
17 0
		pages.forEach(page => {
18 0
			const pageConf = { ...config, ...page }
19 0
			run(pageConf)
20
		})
21
	} else {
22 0
		docgen(config)
23
	}
24
}
25

26 0
const { _: pathArray, configFile, watch, cwd } = minimist(process.argv.slice(2), {
27
	alias: { c: 'configFile', w: 'watch' }
28
})
29

30 1
const conf = extractConfig(cwd || process.cwd(), watch, configFile, pathArray)
31 0
run(conf)

Read our documentation on viewing source code .

Loading