1.1.1 • Published 5 years ago

react-docgen-deprecation-handler v1.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

 

install

npm install react-docgen-deprecation-handler --save-dev

 

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

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

⬇️

{
  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"
    },
  }
}

 

usage

You can add this handler to react-docgen's handlers

// 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)

 

like it?

:star: this repo

 

license

MIT © siddharthkp