Comments (15)
Working on this for the RN website, I'll submit a PR when I get it working there.
from react-docgen.
I have a working version for es6 classes, although I think it is not ready to integrate, because it is a mix between reading jsdoc and flowtype.
We also use jsdoc annotations to see if the method should be included in the docs (@api present, and not @private or @protected
) and not start with _.
https://gist.github.com/danez/ed81356bc04dc60a59b4
from react-docgen.
That's great, I got it to work for React.createClass yesterday also using a mix of reading jsdoc and flow types. I'll probably use your implementation as a base as mine was done using a custom handler directly in the RN website.
I think the logic for choosing which methods are included should be left to the clients so they can choose their own rules. We just provide all the info they can need (method name, access modifiers from jsdocs). We can just filter react methods.
from react-docgen.
I assume you mean, given
class Editor extends React.Component {
/**
* Get the value of the editor
*/
getValue() {}
}
it would extract getValue
and its docblock so that it's clear that given a ref to the component, one can call getValue
on it?
from react-docgen.
Yes. :-) Thanks for a much better bug report.
from react-docgen.
Sounds reasonable to me. I think it is common to prefix internal methods with an underscore _
, so I think it makes sense to only look for methods that are not prefixed as such.
Of course this could still extract data that is not needed, but then again, it can also just be ignored when generating the actual documentation.
from react-docgen.
We do the _
as private thing, but I'd be happy to just write the ignore code on the consumption side. Or you could have an option for ignoreUnderscoreMethods
or something. Your code, your call.
from react-docgen.
Should this feature request include static methods as well?
from react-docgen.
@scvnc: I don't see why not!
from react-docgen.
@fkling any status update on this?
from react-docgen.
@aweary: Sorry, I just didn't have the capacities so far to work on this. I might be able to get to it soon, otherwise PR's are always welcome!
from react-docgen.
In the gist the parsing of jsdoc is missing i noticed, but basically it just uses eslint/doctrine to parse the docblock.
from react-docgen.
I used tj/dox which does pretty much the same but doctrine seems better as it's doing only what we need and dox is a lot bigger.
from react-docgen.
Submitted the PR! #66
from react-docgen.
Cool, I have a look starting next week, when I'm back in town.
from react-docgen.
Related Issues (20)
- react-docgen cannot extract comments with hermes-parser HOT 3
- 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
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.