控制器的 ngdoc 文档
ngdoc documentation for controller
我是代码文档的新手,正在尝试使用 grunt-ngdocs 记录我的 angular 应用程序。
我从以下位置克隆了一个工作示例:https://github.com/m7r/grunt-ngdocs-example
给定的示例缺少文档化控制器,因此我使用以下代码添加了自己的文档化控制器:
/**
* @ngdoc controller
* @name rfx.controller:testCtrl
* @description
* Description of controller.
*/
.controller('testCtrl', function() {
});
当我尝试从命令行通过 运行 grunt 构建文档时,我收到以下错误消息:
Warning: Don't know how to format @ngdoc: controller Use --force to continue.
我该如何解决这个问题?我阅读了本指南 http://www.shristitechlabs.com/adding-automatic-documentation-for-angularjs-apps/,但我不明白为什么在我尝试记录控制器时总是收到错误消息 :( 感谢您的帮助!
示例回购似乎将 grunt-ngdocs
的过时版本列为依赖项。从 0.2.2 开始支持 @ngdoc controller
,而 grunt-ngdocs-example
列出 ~0.1.1。使用最新的 grunt-ngdocs
,你应该可以开始了。
值得一提的是,用于生成 Angular 文档的 "official" 工具是 dgeni + dgeni-packages。 Angular 1.x 使用它来生成自己的文档。非常灵活和可扩展,虽然设置可能需要一些时间。
编辑 我已经 fork grunt-ngdocs-example
here,升级了 grunt-ngdocs
版本并添加了一个控制器示例。
以下是记录示例控制器的方法:
/**
* @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 coming 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
*/
使用dgeni并添加自定义控制器模板:
- 在
config/template/ngdoc/api
中创建内容 {% extends "api/object.template.html" %}
的 controller.template.html
(它将继承自对象模板,但您可以编写自己的模板)
转到您的 dgeni 配置并在 computeIdsProcessor
中扩展 idTemplates
config(function (computeIdsProcessor) {
computeIdsProcessor.idTemplates.find(function (idTempl) {
return idTempl.idTemplate === "module:${module}.${docType}:${name}";
}).docTypes.push("controller");})
记得在computePathsProcessor
中加上"controller"
.config(function (computePathsProcessor) {
computePathsProcessor.pathTemplates.push({
docTypes: ['provider', 'service', 'directive', 'input', 'object', 'function', 'filter', 'type', 'controller'],
pathTemplate: '${area}/${module}/${docType}/${name}',
outputPathTemplate: 'partials/${area}/${module}/${docType}/${name}.html'
});})
我是代码文档的新手,正在尝试使用 grunt-ngdocs 记录我的 angular 应用程序。
我从以下位置克隆了一个工作示例:https://github.com/m7r/grunt-ngdocs-example
给定的示例缺少文档化控制器,因此我使用以下代码添加了自己的文档化控制器:
/**
* @ngdoc controller
* @name rfx.controller:testCtrl
* @description
* Description of controller.
*/
.controller('testCtrl', function() {
});
当我尝试从命令行通过 运行 grunt 构建文档时,我收到以下错误消息:
Warning: Don't know how to format @ngdoc: controller Use --force to continue.
我该如何解决这个问题?我阅读了本指南 http://www.shristitechlabs.com/adding-automatic-documentation-for-angularjs-apps/,但我不明白为什么在我尝试记录控制器时总是收到错误消息 :( 感谢您的帮助!
示例回购似乎将 grunt-ngdocs
的过时版本列为依赖项。从 0.2.2 开始支持 @ngdoc controller
,而 grunt-ngdocs-example
列出 ~0.1.1。使用最新的 grunt-ngdocs
,你应该可以开始了。
值得一提的是,用于生成 Angular 文档的 "official" 工具是 dgeni + dgeni-packages。 Angular 1.x 使用它来生成自己的文档。非常灵活和可扩展,虽然设置可能需要一些时间。
编辑 我已经 fork grunt-ngdocs-example
here,升级了 grunt-ngdocs
版本并添加了一个控制器示例。
以下是记录示例控制器的方法:
/**
* @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 coming 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
*/
使用dgeni并添加自定义控制器模板:
- 在
config/template/ngdoc/api
中创建内容{% extends "api/object.template.html" %}
的controller.template.html
(它将继承自对象模板,但您可以编写自己的模板) 转到您的 dgeni 配置并在
中扩展computeIdsProcessor
idTemplates
config(function (computeIdsProcessor) { computeIdsProcessor.idTemplates.find(function (idTempl) { return idTempl.idTemplate === "module:${module}.${docType}:${name}"; }).docTypes.push("controller");})
记得在
中加上computePathsProcessor
"controller"
.config(function (computePathsProcessor) { computePathsProcessor.pathTemplates.push({ docTypes: ['provider', 'service', 'directive', 'input', 'object', 'function', 'filter', 'type', 'controller'], pathTemplate: '${area}/${module}/${docType}/${name}', outputPathTemplate: 'partials/${area}/${module}/${docType}/${name}.html' });})