Comments (24)
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.
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.
Are there any errors, other than
Error with path "dist/Components/App.js": Error: No suitable component definition found.
?
from react-docgen.
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.
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.
Could you provide some infos about your system? Which Node version, npm version, OS, shell, etc.
Just in case.
from react-docgen.
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.
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.
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.
Yeah that looks like the one. When you're checking for *\n
, does that first asterisk come from the second * in /**
?
from react-docgen.
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.
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.
Yep, that looks like it should suffice, although I would write as
/^\*(\u000A|\u000D|\u2028|\u2029)/.test(comment.value)
from react-docgen.
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.
No worries, I appreciate the help!
from react-docgen.
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.
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.
@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.
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.
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.
Ok i will try! Thanks a lot.
from react-docgen.
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.
@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.
Closing this because I cannot repro. If someone still experiences this issue, please reopen.
from react-docgen.
Related Issues (20)
- Fow indexed access types results in `unknow` HOT 2
- useCallback + useImperativeHandle methods
- Expose more TypeScript types HOT 1
- react-docgen v6.0.0 & older changelogs HOT 2
- Property accessors as template literals causes errors with react-docgen v7 HOT 4
- Better TS enum support
- TS forwardRef support HOT 1
- With Typescript Omit Union types get lost
- With forwardRef Union types get lost HOT 1
- Internal server error: Argument must be Identifier, Literal, QualifiedTypeIdentifier or TSQualifiedName. Received 'TemplateLiteral' HOT 2
- Fails when a namespaced export is used HOT 1
- When postcss modules are present, in some scenarios react-docgen tries to parse css files HOT 2
- Typescript: Component props not parsed with 'call signature' type
- Typescript: Component declaration reference is not recognized by parser
- @defaultValue is not parsed from interface
- "Attempted to resolveName for an unsupported path" error HOT 2
- Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.
- Using `Readonly<T>` utility type results in losing pieces of `T`'s information
- TypeScript: Missing Union Elements of Indexed Access Type
- Failed to parse HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-docgen.