The enum value of oneOf doesn't recognize description.

Open
#381 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
documentation

Research direction

Start with the reported Box component and its PropTypes.oneOf example, then compare the generated JSON with the inline comments on each enum value. Trace how oneOf values are represented and confirm that the output includes their descriptions while preserving the prop-level description. Done means the documented example produces descriptions for both “row” and “column”.

Written by the indexing model from the issue text.

Description

help wanted improvement

Hi,react-docgen does't recognize description for oneOf enum value.Sometimes enum value will make people so confused.It's good to show the comment in description.

Example Component

import React, { Component } from 'react'
import PropTypes from 'prop-types'

class Box extends Component {
  render() {
    return <div>box</div>
  }
}

Box.propTypes = {
  /** 排列 */
  flexDirection: PropTypes.oneOf([
    /** 横向 */
    'row',
    /** 纵向 */
    'column',
  ]),
}

export default Box;

Output Docgen

The comment "横向, 纵向" doesn't show in description.

{
  "description": "",
  "displayName": "Box",
  "methods": [],
  "props": {
    "name": {
      "flexDirection": {
        "defaultValue": {
          "value": "'column'",
          "computed": false
        },
        "type": {
          "name": "enum",
          "value": [{
            "value": "'row'",
            "computed": false
          }, {
            "value": "'column'",
            "computed": false
          }]
        },
        "required": false,
        "description": "排列"
      }
    }
  }
}
Dominant language
TypeScript
Stars
3.8k
Forks
316
Avg merge
3h 28m
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reactjs/react-docgen

All issues in reactjs/react-docgen

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.