coffeedoc / codo

CoffeeScript API documentation generator. It's like YARD but for CoffeeScript!
Other
625 stars 92 forks source link

Any interest in a pull request for properties defined in class constructor or class instance method? #185

Closed silkentrance closed 8 years ago

silkentrance commented 9 years ago

Hi, for my current project I need to declare readonly properties using Object.defineProperty or variations thereof, e.g. @property "prop", ... during construction of the class instance.

At the time being, codo will ignore such property declarations, along with any documentation associated with these nodes.

To cut things short, I am currently working on a "patch" that would allow you to

class Foo
    constructor: (bar) ->
        ###
        @property the bar all want to drink their beer in...
        ###
        @property "bar",
            enumerable: true
            ...
            get: ->
                bar
            set: ...

This, of course, requires users to declare something like this in order to make use of it

Function::property = (name, opts) ->
    Object.defineProperty @, name, opts

What do you think of this. Is it of any use or even a requirement for codo?

aseemk commented 9 years ago

FWIW, I achieve this in one of my modules by defining the properties on my class's prototype, (a) as it's more efficient, and (b) so you don't have to modify the native Function prototype.

E.g. https://github.com/thingdom/node-neo4j/blob/91fa344deef27820022199fc6ee37eb9963f9355/lib/PropertyContainer._coffee#L35-L67

And this works great with Codo's @property support.

inossidabile commented 9 years ago

So if I'm getting it right you just want to add another possible syntax for properties?

silkentrance commented 8 years ago

Since I have abandoned coffeescript in favour of babel/es6 I am closing this.