Coder Social home page Coder Social logo

Comments (24)

fkling avatar fkling commented on April 28, 2024

Mmh, I can't repro. I ran react-docgen with just the source of Fauxbox.jsx and the output includes the description.

I also cloned your repo and ran npm run docs and I can also see the description.

Did you try to delete node_modules and npm install again?

from react-docgen.

mfunkie avatar mfunkie commented on April 28, 2024

npm install after deleting node_modules/ didn't work, and I even checked to see if my react-docgen global was out of date just in case the npm script was not using the local node_modules/.bin to no dice. After that I tried deleting the repo and re-cloning which still did not work.

I suppose if you cannot reproduce, it's fine to close this bug, but I just cannot get the docs task to fill out the description.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

Are there any errors, other than

Error with path "dist/Components/App.js": Error: No suitable component definition found.

?

from react-docgen.

mfunkie avatar mfunkie commented on April 28, 2024

That's the only one I'm getting when running the task. I know it's at least successfully completing because deleting docs/docs.json and re-running gets me all of the Components, just none of the descriptions.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

The only thing I could think of is that the comments are stripped somehow. But in that case it shouldn't work for me either.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

Could you provide some infos about your system? Which Node version, npm version, OS, shell, etc.

Just in case.

from react-docgen.

mfunkie avatar mfunkie commented on April 28, 2024

Node version: v0.10.29 (Note: Just upgraded to 0.12.2 and tried to no luck)
npm version: 2.7.0 (Note: Just upgraded to 2.7.4 to no luck)
OS: OS X Yosemite.3
Shell: fish (Note: I switched to bash and tried to no luck)

from react-docgen.

mfunkie avatar mfunkie commented on April 28, 2024

Found the issue that updating caused a fix. My line endings were set to Windows for some reason, and changing them to Unix style started letting Descriptions funnel through.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

Glad you found the issue/solution! I think this line is responsible: https://github.com/reactjs/react-docgen/blob/master/src/utils/docblock.js#L37.

I guess we could support Windows line endings? Feel free to open a new issue for that if you feel strongly about it.

from react-docgen.

mfunkie avatar mfunkie commented on April 28, 2024

Yeah that looks like the one. When you're checking for *\n, does that first asterisk come from the second * in /** ?

from react-docgen.

fkling avatar fkling commented on April 28, 2024

Yes. The /*, */ are already stripped by the parser, since they are delimiters of the comment. So, my way of determining whether a comment is a docblock comment, is to look for *<line break> at the beginning.

I think we should actually consider any line terminator that the ECMAScript spec considers as valid.

from react-docgen.

mfunkie avatar mfunkie commented on April 28, 2024

So maybe something like

comment.value.match(/^\*(\r|\n)/).length

instead?

I'm sure there's a way to match unicode in regex, I just haven't done it in a long while.

Edit: from what I understand, it might look like

comment.value.match(/^\*(\u000A|\u000D|\u2028|\u2029)/).length

from react-docgen.

fkling avatar fkling commented on April 28, 2024

Yep, that looks like it should suffice, although I would write as

/^\*(\u000A|\u000D|\u2028|\u2029)/.test(comment.value)

from react-docgen.

mfunkie avatar mfunkie commented on April 28, 2024

Yup, that sounds better. I'm running into node issues when testing, so it may be a while before I can get in a pull request on that running.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

No worries, I appreciate the help!

from react-docgen.

gonzochic avatar gonzochic commented on April 28, 2024

Hi,
im using react-docgen on Windows and I am not able to get the prop type description in. It seems that the changes mentioned by @fkling and @mfunkie have not been implemented in the code. Have there been any issues with the implementation?

from react-docgen.

mfunkie avatar mfunkie commented on April 28, 2024

It worked pretty well when I ran the code change locally, I just couldn't get testing to run properly on my machine so I put it on the back burner and made sure all my line-endings were Unix. Would love to see it make it in though.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

@gonzochic: Thanks for brining this up again. I haven't implemented the changes yet but I will take care of it now!

from react-docgen.

fkling avatar fkling commented on April 28, 2024

It turns out that this is not a problem with react-docgen but with recast. I will create a PR there.

To expand a little: It seems that recast (or something) normalizes comments to use \n as line terminator. That's why all we need to do in order to fix this is to make sure recast understands the different line terminators.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

This was fixed in recast in v0.10.31. I added a (now passing) test that that I believe suffices to verify that this issue is fixed.

I'm not publishing a new version for this. If you reinstall react-docgen you should get the latest version of recast. Please give it a try and let me know!

from react-docgen.

gonzochic avatar gonzochic commented on April 28, 2024

Ok i will try! Thanks a lot.

from react-docgen.

gonzochic avatar gonzochic commented on April 28, 2024

Hi,
for me it is still not working (i updated it to recast 0.10.32). Maybe it is because of the ES2015 Syntax?
Here is my example code:

import React from 'react';

/**
 * General component description.
 */

export default class DocTest extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return null;
  }
}

DocTest.propTypes = {
  /**
     * Description of prop "prop1".
 */
  prop1: React.PropTypes.string.isRequired
};
DocTest.defaultProps = {
  prop1: 'default'
};

and as a result of the react-docgen script i get:

{
  "description": "",
  "props": {
    "prop1": {
      "type": {
        "name": "string"
      },
      "required": true,
      "description": "",
      "defaultValue": {
        "value": "'default'",
        "computed": false
      }
    }
  }
}

As you can see the description is not taken from the React Component. Do you have any hints on this issue?

from react-docgen.

fkling avatar fkling commented on April 28, 2024

@gonzochic: Mmh, your example works for me, but I guess the line terminators you are using might get lost somehow along the way. Not really sure what to do :-/

from react-docgen.

fkling avatar fkling commented on April 28, 2024

Closing this because I cannot repro. If someone still experiences this issue, please reopen.

from react-docgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.