coffeedoc / codo

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

Using CoffeeScript with AngularJS #216

Closed dbartholomae closed 8 years ago

dbartholomae commented 8 years ago

Hi there,

what would be the best way to document this kind of project with codo:

require 'restangular'
module.exports = require('angular').module 'backend', ['restangular']
.factory 'backend', ['Restangular', (Restangular) ->
  new class Backend
    constructor: ->
      Restangular.withConfig (provider) ->
        provider.setBaseUrl "some.url.com"
]
.name

Given that the class definition isn't on the top level, any comments before defining the class are not used for documentation. Unfortunately I need to have the class definition inside the function, as this is the way dependency injection is handled in angular: Otherwise I would not have access to Restangular.

Any ideas on best practices for this case?

dbartholomae commented 8 years ago

I found the reason why it isn't working: The assignment is parsed as a variable with the functions sourcecode as a value. Furthermore the case new class hadn't yet been taken care of in the traverser. I fixed both and then some. Currently everything is in #217, but I can split it up in different packages if needed.