Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Enforce JSDoc #344

Closed
samjohnb opened this issue Apr 22, 2014 · 5 comments
Closed

Enforce JSDoc #344

samjohnb opened this issue Apr 22, 2014 · 5 comments

Comments

@samjohnb
Copy link

Static analysis tools such as Java's CheckStyle and C#'s StyleCop can enforce code documentation for classes, methods and fields. I would like our client-side code documentation to be as comprehensive as our server-side. Would it be possible for JSCS to have a rule that says "you must document [method|class|field] x"?

@qfox
Copy link
Member

qfox commented Apr 22, 2014

I suppose you should take a look at https://github.com/zxqfox/jscs-jsdoc/
Agreed with your mention, it will be useful option

@samjohnb
Copy link
Author

Thanks for your help. This certainly looks useful, but I don't think jscs-jsdoc enforces the use of JSDoc. My use case would be that, this would pass

/**
* This function returns something
*
* @param {string} b An argument
* @returns {string} Something to return
*/
function a(b) {
   return "something";
}

but, this would fail (because there's no documentation):

function a(b) {
   return "something";
}

@qfox
Copy link
Member

qfox commented Apr 22, 2014

@samjohnb Yeah. I understand and can implement this check.

@samjohnb
Copy link
Author

Wow, fantastic, thanks! It would be great if this could work for all function declarations, i.e.

function a(b) {}
thing = function() {}
anotherthing(function() {})

The last one is particularly important as we are developing in AngularJS, so we have a lot of code that looks like this:

app.controller('mainController', [ '$scope', 'dataFactory', '$filter',
    function($scope, dataFactory, $filter) {
...

and it's important that we document what the controller is for, so this would be fine:

app.controller('mainController', [ '$scope', 'dataFactory', '$filter',

    /**
    * Controller for foo
    * @param {scope} scope The scope
    * @param {dataFactory} datafactory The data factory
    * @param {filter} filter The filter
    /*
    function($scope, dataFactory, $filter) {
...

@mikesherov
Copy link
Contributor

@samjohnb please continue this discussion on jscs-dev/jscs-jsdoc#4 . Thanks again for contributing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants