UNPKG

react-docgen-deprecation-handler

Version:
95 lines (71 loc) • 1.85 kB
<p align="center"> <img src="https://raw.githubusercontent.com/siddharthkp/react-docgen-deprecation-handler/master/logo.png" /> <br><br> <b>Add deprecation status in prop types</b> <br><br> <img src="https://travis-ci.org/siddharthkp/react-docgen-deprecation-handler.svg?branch=master&maxAge=3600"/> </p> &nbsp; #### install ``` npm install react-docgen-deprecation-handler --save-dev ``` &nbsp; #### what does it do? You can add `@deprecated` in the leading comments for a prop, and it will appear in the documentation as a key ```jsx const Component = () => <div /> Component.propTypes = { /** @deprecated dont use this prop */ old: PropTypes.any, /** this isn't deprecated, use it */ new: PropTypes.any, /** @deprecated:new deprecated, you can add metadata like the replacement */ old2: PropTypes.any } export default Component ``` ā¬‡ļø ```js { displayName: "Component", props: { old: { type: { name: 'any' }, required: false, description: "dont use this prop", šŸ‘‰ deprecated: true }, new: { type: { name: 'any' }, required: false, description: "this isn't deprecated, use it" }, old2: { type: { name: 'any' }, required: false, description: "dont use this prop", šŸ‘‰ deprecated: true, šŸ‘‰ deprecationData: "new" }, } } ``` &nbsp; #### usage You can add this handler to `react-docgen`'s handlers ```js // grab the deprecation handler const deprecationHandler = require("react-docgen-deprecation-handler") // add this to docgen's handlers const handlers = docgen.defaultHandlers.concat(deprecationHandler) // pass these handlers to docgen.parse const data = docgen.parse(code, null, handlers) ``` &nbsp; #### like it? :star: this repo &nbsp; #### license MIT Ā© [siddharthkp](https://github.com/siddharthkp)