Coder Social home page Coder Social logo

Comments (15)

janicduplessis avatar janicduplessis commented on April 28, 2024 1

Working on this for the RN website, I'll submit a PR when I get it working there.

from react-docgen.

danez avatar danez commented on April 28, 2024 1

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.

janicduplessis avatar janicduplessis commented on April 28, 2024 1

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.

fkling avatar fkling commented on April 28, 2024

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.

jherr avatar jherr commented on April 28, 2024

Yes. :-) Thanks for a much better bug report.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

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.

jherr avatar jherr commented on April 28, 2024

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.

scvnc avatar scvnc commented on April 28, 2024

Should this feature request include static methods as well?

from react-docgen.

fkling avatar fkling commented on April 28, 2024

@scvnc: I don't see why not!

from react-docgen.

aweary avatar aweary commented on April 28, 2024

@fkling any status update on this?

from react-docgen.

fkling avatar fkling commented on April 28, 2024

@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.

danez avatar danez commented on April 28, 2024

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.

janicduplessis avatar janicduplessis commented on April 28, 2024

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.

janicduplessis avatar janicduplessis commented on April 28, 2024

Submitted the PR! #66

from react-docgen.

danez avatar danez commented on April 28, 2024

Cool, I have a look starting next week, when I'm back in town.

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.