{"_id":"react-docgen-imported-proptype-handler","_rev":"2832355","name":"react-docgen-imported-proptype-handler","description":"evaluate imported variables for react-docgen","dist-tags":{"latest":"1.0.4"},"maintainers":[{"name":"benjroy","email":"ben@bittorrent.com"}],"time":{"modified":"2022-09-06T15:16:21.000Z","created":"2018-12-05T02:26:49.348Z","1.0.4":"2018-12-06T02:10:13.752Z","1.0.3":"2018-12-05T22:42:55.875Z","1.0.2":"2018-12-05T20:16:05.920Z","1.0.1":"2018-12-05T05:39:44.722Z","1.0.0":"2018-12-05T02:26:49.348Z"},"users":{},"author":{"name":"benjroy"},"repository":{"type":"git","url":"git+https://github.com/benjroy/react-docgen-imported-proptype-handler.git"},"versions":{"1.0.4":{"name":"react-docgen-imported-proptype-handler","version":"1.0.4","description":"evaluate imported variables for react-docgen","scripts":{"build":"rimraf dist/ && babel src/ --out-dir dist/ --ignore **/__tests__,**/__mocks__,**/src/types.js","lint":"eslint . --report-unused-disable-directives","lint-file":"eslint --report-unused-disable-directives","fix-lint":"npm run lint -- --fix","test":"jest","test:ci":"npm run lint && npm run test"},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/benjroy/react-docgen-imported-proptype-handler.git"},"keywords":[],"author":{"name":"benjroy"},"license":"MIT","bugs":{"url":"https://github.com/benjroy/react-docgen-imported-proptype-handler/issues"},"homepage":"https://github.com/benjroy/react-docgen-imported-proptype-handler#readme","devDependencies":{"@babel/cli":"^7.2.0","@babel/core":"^7.2.0","@babel/plugin-transform-runtime":"^7.2.0","@babel/preset-env":"^7.2.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^10.0.1","babel-jest":"^23.6.0","eslint":"^5.9.0","eslint-config-prettier":"^3.3.0","eslint-plugin-prettier":"^3.0.0","glob":"^7.1.3","jest":"^23.6.0","prettier":"^1.15.3","react-docgen":"^2.21.0","react-router":"^4.3.1","recast":"^0.12.9","rimraf":"^2.6.2"},"jest":{"roots":["src"],"testRegex":"/__tests__/.*-test\\.js$"},"dependencies":{"@babel/runtime":"^7.2.0"},"peerDependencies":{"recast":"^0.12.9","react-docgen":"^2.21.0"},"gitHead":"78fe19356df0f8b11d5cd4a8fe026a0dc74614b7","_id":"react-docgen-imported-proptype-handler@1.0.4","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"benjroy","email":"benjrallen@gmail.com"},"dist":{"shasum":"a7c73df8ad516b633068e0e22cad474d17dac7d9","size":19796,"noattachment":false,"key":"/react-docgen-imported-proptype-handler/-/react-docgen-imported-proptype-handler-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-docgen-imported-proptype-handler/download/react-docgen-imported-proptype-handler-1.0.4.tgz"},"maintainers":[{"name":"benjroy","email":"ben@bittorrent.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-docgen-imported-proptype-handler_1.0.4_1544062213384_0.521067997582777"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-23T04:21:07.373Z","publish_time":1544062213752,"_cnpm_publish_time":1544062213752},"1.0.3":{"name":"react-docgen-imported-proptype-handler","version":"1.0.3","description":"evaluate imported variables for react-docgen","scripts":{"build":"rimraf dist/ && babel src/ --out-dir dist/ --ignore **/__tests__,**/__mocks__,**/src/types.js","lint":"eslint . --report-unused-disable-directives","lint-file":"eslint --report-unused-disable-directives","fix-lint":"npm run lint -- --fix","test":"jest","test:ci":"npm run lint && npm run test"},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/benjroy/react-docgen-imported-proptype-handler.git"},"keywords":[],"author":{"name":"benjroy"},"license":"MIT","bugs":{"url":"https://github.com/benjroy/react-docgen-imported-proptype-handler/issues"},"homepage":"https://github.com/benjroy/react-docgen-imported-proptype-handler#readme","devDependencies":{"@babel/cli":"^7.2.0","@babel/core":"^7.2.0","@babel/plugin-transform-runtime":"^7.2.0","@babel/preset-env":"^7.2.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^10.0.1","babel-jest":"^23.6.0","eslint":"^5.9.0","eslint-config-prettier":"^3.3.0","eslint-plugin-prettier":"^3.0.0","glob":"^7.1.3","jest":"^23.6.0","prettier":"^1.15.3","react-docgen":"^2.21.0","react-router":"^4.3.1","recast":"^0.12.9","rimraf":"^2.6.2"},"jest":{"roots":["src"],"testRegex":"/__tests__/.*-test\\.js$"},"dependencies":{"@babel/runtime":"^7.2.0"},"peerDependencies":{"recast":"^0.12.9","react-docgen":"^2.21.0"},"gitHead":"bde586260aa8b7e1d955604e6d7b64b1c9c52075","_id":"react-docgen-imported-proptype-handler@1.0.3","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"benjroy","email":"benjrallen@gmail.com"},"dist":{"shasum":"db139ad2708ce1fb40e6d6175f66b9884a06a42d","size":19211,"noattachment":false,"key":"/react-docgen-imported-proptype-handler/-/react-docgen-imported-proptype-handler-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-docgen-imported-proptype-handler/download/react-docgen-imported-proptype-handler-1.0.3.tgz"},"maintainers":[{"name":"benjroy","email":"ben@bittorrent.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-docgen-imported-proptype-handler_1.0.3_1544049775595_0.5249048156376304"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-23T04:21:06.253Z","publish_time":1544049775875,"_cnpm_publish_time":1544049775875},"1.0.2":{"name":"react-docgen-imported-proptype-handler","version":"1.0.2","description":"evaluate imported variables for react-docgen","scripts":{"build":"rimraf dist/ && babel src/ --out-dir dist/ --ignore **/__tests__,**/__mocks__,**/src/types.js","lint":"eslint . --report-unused-disable-directives","lint-file":"eslint --report-unused-disable-directives","fix-lint":"npm run lint -- --fix","test":"jest","test:ci":"npm run lint && npm run test"},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/benjroy/react-docgen-imported-proptype-handler.git"},"keywords":[],"author":{"name":"benjroy"},"license":"MIT","bugs":{"url":"https://github.com/benjroy/react-docgen-imported-proptype-handler/issues"},"homepage":"https://github.com/benjroy/react-docgen-imported-proptype-handler#readme","devDependencies":{"@babel/cli":"^7.2.0","@babel/core":"^7.2.0","@babel/plugin-transform-runtime":"^7.2.0","@babel/preset-env":"^7.2.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^10.0.1","babel-jest":"^23.6.0","eslint":"^5.9.0","eslint-config-prettier":"^3.3.0","eslint-plugin-prettier":"^3.0.0","glob":"^7.1.3","jest":"^23.6.0","prettier":"^1.15.3","react-router":"^4.3.1","rimraf":"^2.6.2"},"jest":{"roots":["src"],"testRegex":"/__tests__/.*-test\\.js$"},"dependencies":{"@babel/runtime":"^7.2.0","react-docgen":"2.21.0","recast":"^0.12.9"},"gitHead":"7d0097c007ba6bf9f2b2dfc40a4cd206385bceb1","_id":"react-docgen-imported-proptype-handler@1.0.2","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"benjroy","email":"benjrallen@gmail.com"},"dist":{"shasum":"dfc8881ab90b3dfe15dc4c33b45243cd6ec3dce0","size":19007,"noattachment":false,"key":"/react-docgen-imported-proptype-handler/-/react-docgen-imported-proptype-handler-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-docgen-imported-proptype-handler/download/react-docgen-imported-proptype-handler-1.0.2.tgz"},"maintainers":[{"name":"benjroy","email":"ben@bittorrent.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-docgen-imported-proptype-handler_1.0.2_1544040965844_0.5510222490513565"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-23T04:21:05.127Z","publish_time":1544040965920,"_cnpm_publish_time":1544040965920},"1.0.1":{"name":"react-docgen-imported-proptype-handler","version":"1.0.1","description":"evaluate imported variables for react-docgen","scripts":{"build":"rimraf dist/ && babel src/ --out-dir dist/ --ignore **/__tests__,**/__mocks__,**/src/types.js","lint":"eslint . --report-unused-disable-directives","lint-file":"eslint --report-unused-disable-directives","fix-lint":"npm run lint -- --fix","test":"jest","test:ci":"npm run lint && npm run test"},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/benjroy/react-docgen-imported-proptype-handler.git"},"keywords":[],"author":{"name":"benjroy"},"license":"MIT","bugs":{"url":"https://github.com/benjroy/react-docgen-imported-proptype-handler/issues"},"homepage":"https://github.com/benjroy/react-docgen-imported-proptype-handler#readme","devDependencies":{"@babel/cli":"^7.2.0","@babel/core":"^7.2.0","@babel/plugin-transform-runtime":"^7.2.0","@babel/preset-env":"^7.2.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^10.0.1","babel-jest":"^23.6.0","eslint":"^5.9.0","eslint-config-prettier":"^3.3.0","eslint-plugin-prettier":"^3.0.0","glob":"^7.1.3","jest":"^23.6.0","prettier":"^1.15.3","react-router":"^4.3.1","rimraf":"^2.6.2"},"jest":{"roots":["src"],"testRegex":"/__tests__/.*-test\\.js$"},"dependencies":{"@babel/runtime":"^7.2.0","react-docgen":"2.21.0","recast":"^0.12.9"},"gitHead":"33359890eda9c682fe11f419ba063abe778df695","_id":"react-docgen-imported-proptype-handler@1.0.1","_npmVersion":"6.4.1","_nodeVersion":"8.14.0","_npmUser":{"name":"benjroy","email":"benjrallen@gmail.com"},"dist":{"shasum":"bc90333f2a3ed65d05eee5c1ed296b000eb50fd2","size":18767,"noattachment":false,"key":"/react-docgen-imported-proptype-handler/-/react-docgen-imported-proptype-handler-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-docgen-imported-proptype-handler/download/react-docgen-imported-proptype-handler-1.0.1.tgz"},"maintainers":[{"name":"benjroy","email":"ben@bittorrent.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-docgen-imported-proptype-handler_1.0.1_1543988384586_0.433368227698647"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-23T04:21:04.006Z","publish_time":1543988384722,"_cnpm_publish_time":1543988384722},"1.0.0":{"name":"react-docgen-imported-proptype-handler","version":"1.0.0","description":"evaluate imported variables for react-docgen","scripts":{"build":"rimraf dist/ && babel src/ --out-dir dist/ --ignore **/__tests__,**/__mocks__,**/src/types.js","lint":"eslint . --report-unused-disable-directives","lint-file":"eslint --report-unused-disable-directives","fix-lint":"npm run lint -- --fix","test":"jest","test:ci":"npm run lint && npm run test"},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/benjroy/react-docgen-imported-proptype-handler.git"},"keywords":[],"author":{"name":"benjroy"},"license":"MIT","bugs":{"url":"https://github.com/benjroy/react-docgen-imported-proptype-handler/issues"},"homepage":"https://github.com/benjroy/react-docgen-imported-proptype-handler#readme","devDependencies":{"@babel/cli":"^7.2.0","@babel/core":"^7.2.0","@babel/plugin-transform-runtime":"^7.2.0","@babel/preset-env":"^7.2.0","@babel/runtime":"^7.2.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^10.0.1","babel-jest":"^23.6.0","eslint":"^5.9.0","eslint-config-prettier":"^3.3.0","eslint-plugin-prettier":"^3.0.0","glob":"^7.1.3","jest":"^23.6.0","prettier":"^1.15.3","react-router":"^4.3.1","rimraf":"^2.6.2"},"jest":{"roots":["src"],"testRegex":"/__tests__/.*-test\\.js$"},"dependencies":{"react-docgen":"2.21.0","recast":"^0.12.9"},"gitHead":"402ea90df74d716afa6d8e5670c01c0b1248a5e0","_id":"react-docgen-imported-proptype-handler@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"benjroy","email":"benjrallen@gmail.com"},"dist":{"shasum":"5adcf4e5b26fba60e81f8fd63756f7eee556d596","size":18546,"noattachment":false,"key":"/react-docgen-imported-proptype-handler/-/react-docgen-imported-proptype-handler-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-docgen-imported-proptype-handler/download/react-docgen-imported-proptype-handler-1.0.0.tgz"},"maintainers":[{"name":"benjroy","email":"ben@bittorrent.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-docgen-imported-proptype-handler_1.0.0_1543976809170_0.40092338932603533"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-23T04:21:02.876Z","publish_time":1543976809348,"_cnpm_publish_time":1543976809348}},"readme":"\n# `react-docgen` `handler` for processing imported variables\n\n## Install\n```bash\n# install peer dependencies\nnpm install react-docgen@2.21.0 recast@0.12.9 --save-dev\n# install this handler\nnpm install react-docgen-imported-proptype-handler --save-dev\n```\n##### peerDependencies\n*note: it is necessary for this `handler` and `react-docgen` to share the same `recast` dependency*\n```bash\nnpm ls recast\n```\n*should show `recast` as `deduped` under `react-docgen`*\n```\n<project name>@<project version>\n├─┬ react-docgen@2.21.0\n│ └── recast@0.12.9  deduped\n└── recast@0.12.9\n```\n\n### Usage example\n```js\nconst { readFileSync, writeFileSync } = require('fs');\nconst { resolve, basename } = require('path');\nconst docgen = require('react-docgen');\nconst glob = require('glob');\nconst importedProptypesHandler = require('react-docgen-imported-proptype-handler').default;\n\nconst FILES = glob.sync('src/components/**/*.{js,jsx}');\n\nconst metadata = FILES.reduce((memo, filepath) => {\n  /* append display name handler to handlers list */\n  const handlers = docgen.defaultHandlers.concat([\n    importedProptypesHandler(filepath)\n  ]);\n\n  /* read file to get source code */\n  const code = readFileSync(filepath, 'utf8');\n\n  /* parse the component code to get metadata */\n  try {\n    const data = docgen.parse(code, null, handlers);\n    memo[basename(filepath)] = data;\n  } catch (err) {\n    if (err.message !== 'No suitable component definition found.') {\n      console.log('ERROR:', filepath, err);\n    }\n  }\n\n  return memo;\n}, {});\n\n\nwriteFileSync(resolve(process.cwd(), 'DOCGEN_OUTPUT.json'), JSON.stringify(metadata, null, 2));\n```\n\n#### Credit\nInspiration for this came from:\n- [Chandrasekhar Pasupuleti](https://github.com/pasupuletics), initial implementation\n- [Siddharth Kshetrapal](https://github.com/siddharthkp), for publishing [react-docgen-external-proptypes-handler](https://github.com/siddharthkp/react-docgen-external-proptypes-handler)\n- and the [issue](https://github.com/reactjs/react-docgen/issues/33) in `react-docgen`\n\n#### Why?\n`react-docgen` doesn't allow you to use variables from other files to use in `propTypes`\n\nExample:\n\n```js\nimport iconNames from './icon-names.js'\n\nIcon.propTypes = {\n  /** Icon name */\n  name: PropTypes.oneOf(iconNames).isRequired\n}\n```\n\nThis doesn't work because it's parsed as a string and not an array\n\n```json\n\"props\": {\n  \"name\": {\n    \"type\": {\n      \"name\": \"enum\",\n      \"computed\": true,\n      \"value\": \"iconNames\"\n    },\n    \"required\": true,\n    \"description\": \"Icon name\"\n  },\n}\n```\n\n#### License\nMIT © [benjroy](https://github.com/benjroy)\n\n#### Like it?\n:star: this repo\n","_attachments":{},"homepage":"https://github.com/benjroy/react-docgen-imported-proptype-handler#readme","bugs":{"url":"https://github.com/benjroy/react-docgen-imported-proptype-handler/issues"},"license":"MIT"}