|
- #!/usr/bin/env node
-
- const docgen = require('react-docgen-typescript')
- const path = require('path')
- const fs = require('fs')
-
- const componentsPath = path.resolve(__dirname, '..', '..', 'react-common', 'src', 'components')
-
- fs.readdir(componentsPath, (err, dir) => {
- const trueFilePaths = dir.map(d => path.resolve(__dirname, '..', '..', 'react-common', 'src', 'components', d, `${d}.tsx`))
- const docs = docgen.parse(
- trueFilePaths,
- {
- shouldExtractLiteralValuesFromEnum: true,
- shouldRemoveUndefinedFromOptional: true,
- propFilter: (prop) => {
- if (prop.declarations !== undefined && prop.declarations.length > 0) {
- const hasPropAdditionalDescription = prop.declarations.find((declaration) => {
- return !declaration.fileName.includes("node_modules");
- });
-
- return Boolean(hasPropAdditionalDescription);
- }
-
- return true;
- },
- }
- )
- fs.writeFile(path.resolve(__dirname, '..', 'src', 'docgen.json'), JSON.stringify(docs, null, 2), (err) => {
-
- })
- })
|