Search code examples
javascriptangularjsdocumentation-generationngdocgrunt-ngdocs

ngdoc documentation for controller


I am to new to code documentation and trying to document my angular application with grunt-ngdocs.

I cloned a working example from: https://github.com/m7r/grunt-ngdocs-example

The given example lacks a documented controller so I added my own documented controller with this code:

 /**
  * @ngdoc controller
  * @name rfx.controller:testCtrl
  * @description 
  * Description of controller.
  */
 .controller('testCtrl', function() {
 });

When I am trying to build a documentation by running grunt from the command line I get the following error message:

Warning: Don't know how to format @ngdoc: controller Use --force to continue.

How do I fix this? I read this guide http://www.shristitechlabs.com/adding-automatic-documentation-for-angularjs-apps/ and I can't figure out why do I keep getting error message if I try to document a controller :( Thanks for any help!


Solution

  • It appears that the example repo has an out-of-date version of grunt-ngdocs listed as a dependency. @ngdoc controller is supported as of 0.2.2, while grunt-ngdocs-example lists ~0.1.1. Use the latest grunt-ngdocs and you should be good to go.

    It's worth mentioning that the "official" tool for generating Angular documentation is dgeni + dgeni-packages. It is used by Angular 1.x to generate its own documentation. Very flexible and extensible, although the setup can take some time.


    Edit I've forked grunt-ngdocs-example here, upgraded the grunt-ngdocs version and added a controller example.