Skip to content

Allow excluding file patterns when generating component definitions #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pbugnion opened this issue Dec 9, 2018 · 0 comments
Closed

Comments

@pbugnion
Copy link

pbugnion commented Dec 9, 2018

Thanks a lot for making Dash -- we have found it very useful for building dashboards.

We ran into an issue migrating to the new dash-generate-components utility.

In dash-bootstrap-components, we keep the components in src/components. Besides components files, this also includes a few unit test files called, e.g. src/components/__tests__/DropdownMenu.test.js. When we run dash-generate-components ./src/components <output>, these test files also get picked up. This leads to a traceback in the build logs:

Error with path src/components/__tests__/DropdownMenu.test.jsError: No suitable component definition found.
Error: No suitable component definition found.
at parse (/project/pascal/dash-bootstrap-components/node_modules/react-docgen/dist/parse.js:84:9)
at Object.defaultParse [as parse] (/project/pascal/dash-bootstrap-components/node_modules/react-docgen/dist/main.js:66:30)
at parseFile (/opt/anaconda/envs/Python3/lib/python3.6/site-packages/dash/extract-meta.js:64:51)
at dirs.forEach.filename (/opt/anaconda/envs/Python3/lib/python3.6/site-packages/dash/extract-meta.js:84:17)
at Array.forEach (<anonymous>)
at collectMetadataRecursively (/opt/anaconda/envs/Python3/lib/python3.6/site-packages/dash/extract-meta.js:79:14)
at dirs.forEach.filename (/opt/anaconda/envs/Python3/lib/python3.6/site-packages/dash/extract-meta.js:82:17)
at Array.forEach (<anonymous>)
at collectMetadataRecursively (/opt/anaconda/envs/Python3/lib/python3.6/site-packages/dash/extract-meta.js:79:14)
at componentPaths.forEach.componentPath (/opt/anaconda/envs/Python3/lib/python3.6/site-packages/dash/extract-meta.js:15:5)

While the error is, of course, legitimate, it would be nice to be able to suppress these tracebacks. I can see three routes:

  • do nothing -- after all, this doesn't stop us from building metadata.json, it just makes it slightly more confusing.
  • in dash/extract-meta.js, we could explicitly blacklist __tests__ directories in the same way that files that don't end in jsx? are black-listed. AFAICT, the __tests__ directory structure is the default with jest. react-docgen ignores node_modules, __tests__ and __mocks__ by default, so there is definitely a precedent.
  • add a --ignore argument to dash-generate-components that allows passing file globs to be excluded.

Very happy to submit a PR if you decide on what the best course of action is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant