I am to new to code documentation and trying to document my angular application with grunt-ngdocs.
I cloned a working example from:
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 mand 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 / and I can't figure out why do I keep getting error message if I try to document a controller :( Thanks for any help!
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./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 mand 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./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!
Share Improve this question edited Dec 16, 2015 at 8:13 Igor Raush 15.2k1 gold badge37 silver badges57 bronze badges asked Dec 15, 2015 at 20:43 noviewpointnoviewpoint 5841 gold badge10 silver badges20 bronze badges 1- any ideas on how to create a file (.pdf or .doc) with all documentation details rather than a web app? – spyder Commented Aug 10, 2016 at 15:10
3 Answers
Reset to default 5Here is how you can document sample controller:
/**
* @ngdoc function
* @name appModernizationApp.controller:DetailsCtrl
* @description
* # DetailsCtrl
* Controller of the appModernizationApp
* This controller is responsible for showing the details of the page.
* It gets initialized by requesting the JSON for types of rooms which is hosted on the server.
* It also requests for the details of the room for an existing reservation if the reservation id is present in the route using <b>HRS.getRegisteredData(reservationId)</b>.
* @requires $scope
* @requires $http
* @requires HRS
* @requires $location
* @requires $routeParams
* @requires breadcrumbs
* @requires UtilitiesService
*
* @property {object} breadcrumbs:object breadcrumbs Handles the page level/navigation at the top.
* @property {array} reservationDetails:array This holds the reservation details of the current/selected reservation.
* @property {string} registerationErrorMsg:string This variable holds the error message for all registration services.
* @property {string} roomSearchErrorMsg:string This variable holds the error message for all room search services.
* @property {array} roomDetails:array This holds the room details object. This will be a fresh object ing from service response and will be manipulated as per the view model.
* @property {boolean} submitted:boolean Holds the submitted boolean flag. Initialized with false. Changes to true when we store the details.
* @property {number} reservationId:number Gets the reservation id from the route params.
* @property {date} minDate:date Date filled in the minimum date vatiable
* @property {boolean} isRoomDetailsVisible:boolean Controls the boolean flag for visibility of room details. Initialized with false.
* @property {array} roomTypes:array Holds types of rooms from JSON.
* @property {array} expirymonth:array Months from Jan to Dec
* @property {array} expiryYear:array Years of a particular range
* @property {array} cardtype:array Type of cards
*/
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.
Use dgeni and add custom controller template:
- Create
controller.template.html
inconfig/template/ngdoc/api
with content{% extends "api/object.template.html" %}
(it will inherit from object template but you can write your own template) Go to your dgeni config and extend
idTemplates
inputeIdsProcessor
config(function (puteIdsProcessor) { puteIdsProcessor.idTemplates.find(function (idTempl) { return idTempl.idTemplate === "module:${module}.${docType}:${name}"; }).docTypes.push("controller");})
Remember to include
"controller"
inputePathsProcessor
.config(function (putePathsProcessor) { putePathsProcessor.pathTemplates.push({ docTypes: ['provider', 'service', 'directive', 'input', 'object', 'function', 'filter', 'type', 'controller'], pathTemplate: '${area}/${module}/${docType}/${name}', outputPathTemplate: 'partials/${area}/${module}/${docType}/${name}.html' });})