Skip to content
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

Class description does not work with @decorators #18

Closed
theogravity opened this issue Aug 23, 2015 · 4 comments
Closed

Class description does not work with @decorators #18

theogravity opened this issue Aug 23, 2015 · 4 comments

Comments

@theogravity
Copy link

Trying to use the @Radium decorator from radium

import React, { Component } from 'react'
import Radium from 'radium'

/**
 * react-docgen does not parse this description when a @decorator is present
 */
@Radium
export default class extends Component {
  static displayName = 'DocCommentExample'

  static styleguide = {
    index: '5.2',
    category: 'Features!',
    title: 'Additional examples via doc comment'
  }

  static propTypes = {
    /**
     * Block level
     */
    block: React.PropTypes.bool,
    /**
     * Style types `'default|primary|success|info'`
     */
    bsStyle: React.PropTypes.oneOf(['default', 'primary', 'success', 'info'])
  }

  static defaultProps = {
    bsStyle: 'default'
  }

  render () {
    return <div></div>
  }
}

Parsed output:

{
    "description": "",
    "displayName": "DocCommentExample",
    "props": {
        "block": {
            "type": {
                "name": "bool"
            },
            "required": false,
            "description": "Block level"
        },
        "bsStyle": {
            "type": {
                "name": "enum",
                "value": [
                    {
                        "value": "'default'",
                        "computed": false
                    },
                    {
                        "value": "'primary'",
                        "computed": false
                    },
                    {
                        "value": "'success'",
                        "computed": false
                    },
                    {
                        "value": "'info'",
                        "computed": false
                    }
                ]
            },
            "required": false,
            "description": "Style types `'default|primary|success|info'`",
            "defaultValue": {
                "value": "'default'",
                "computed": false
            }
        }
    }
}
@theogravity theogravity changed the title Class description does not work with decorators Class description does not work with @decorators Aug 23, 2015
@fkling
Copy link
Member

fkling commented Aug 23, 2015

Thanks for the report! My first guess would be that the comment might be attached to a different node. I will investigate.

@theogravity
Copy link
Author

Thanks for the prompt response!

@levithomason
Copy link

Would love to see this as well. As a temporary work around, you can place the decorator above the docblock:

import {Component} from 'react';
import Radium from 'radium';

@Radium
/**
 * This is a box for checking.
 */
class Checkbox extends Component {
  //...
}

Radium continues to work in the component and the generated doc json contains the docblock description. This was tested using webpack and babel.

@theogravity
Copy link
Author

Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants