Skip to content

Commit

Permalink
docs: rollback react-docgen (#6765)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletsang committed Feb 5, 2024
1 parent 35982ca commit 88334cf
Show file tree
Hide file tree
Showing 4 changed files with 326 additions and 146 deletions.
2 changes: 1 addition & 1 deletion www/package.json
Expand Up @@ -33,7 +33,7 @@
"prism-react-renderer": "^2.1.0",
"raw-loader": "^4.0.2",
"react": "^18.2.0",
"react-docgen": "^7.0.3",
"react-docgen": "^5.4.3",
"react-dom": "^18.2.0",
"react-live": "^2.4.1",
"sass": "^1.69.7",
Expand Down
3 changes: 1 addition & 2 deletions www/plugins/react-docgen-plugin/index.js
Expand Up @@ -29,8 +29,7 @@ module.exports = () => ({
const filePath = path.join(srcPath, file);
const buffer = await fs.readFile(filePath);

const output = reactDocgen.parse(buffer, {
resolver: resolveHocComponents,
const output = reactDocgen.parse(buffer, resolveHocComponents, null, {
filename: filePath,
});

Expand Down
9 changes: 7 additions & 2 deletions www/plugins/react-docgen-plugin/resolveHocComponents.js
@@ -1,10 +1,15 @@
const camelCase = require('lodash.camelcase');
const { resolver, utils } = require('react-docgen');
const { namedTypes: types, visit } = require('ast-types');
const { parse } = require('react-docgen');
const buildParser = require('react-docgen/dist/babelParser').default;

const upperFirst = (str) => str[0].toUpperCase() + str.slice(1);

const parser = buildParser({
// Avoid babel complaining about requiring a filename.
filename: 'dummy.ts',
});

module.exports = (ast) => {
let components = resolver.findAllComponentDefinitions(ast);

Expand Down Expand Up @@ -71,7 +76,7 @@ export default class ${upperFirst(
}
`;

let comp = parse(src);
let comp = parser.parse(src);
comp.__src = src;
components = components.concat(
resolver.findExportedComponentDefinition(comp),
Expand Down

0 comments on commit 88334cf

Please sign in to comment.