7

Sono di nuovo alla documentazione del codice e sto provando a documentare la mia applicazione angolare con grunt-ngdocs.documentazione di ngdoc per controller

ho clonato un esempio funzionante da: https://github.com/m7r/grunt-ngdocs-example

Il dato esempio manca un controller documentato così ho aggiunto il mio proprio controllore documentato con questo codice:

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

Quando sto cercando di costruire una documentazione da eseguendo grunt dalla riga di comando viene visualizzato il seguente messaggio di errore:

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

Come posso risolvere questo problema? Ho letto questa guida http://www.shristitechlabs.com/adding-automatic-documentation-for-angularjs-apps/ e non riesco a capire perché continuo a ricevere un messaggio di errore se provo a documentare un controller :(Grazie per qualsiasi aiuto!

+0

tutte le idee su come creare un file (.pdf o .doc), con tutti i dettagli della documentazione piuttosto che una web app? – spyder

risposta

2

Sembra che il repository di esempio non sia aggiornato versione di grunt-ngdocs elencato come una dipendenza. @ngdoc controller è supportato come di 0.2.2, mentre grunt-ngdocs-example liste ~ 0.1.1. Utilizzare l'ultima grunt-ngdocs e si dovrebbe essere a posto.

vale la pena ricordare che la funzione "ufficiale" per generare la documentazione angolare è dgeni + dgeni-packages. Viene utilizzato da Angular 1.x per generare la propria documentazione. Molto flessibile ed estendibile, sebbene l'installazione possa richiedere del tempo.


Edit ho biforcato grunt-ngdocs-examplehere, aggiornato alla versione grunt-ngdocs e aggiunto un esempio di controllo.

5

Ecco come è possibile documentare regolatore del campione:

/** 
* @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 
*/ 
0

Usa dgeni e aggiungere modello di controllo personalizzato:

  1. Crea controller.template.html in config/template/ngdoc/api con contenuti {% extends "api/object.template.html" %} (sarà ereditare da modello di oggetto, ma si puoi scrivere il tuo modello)
  2. Vai al tuo dgeni config ed estendi idTemplates in computeIdsProcessor

    config(function (computeIdsProcessor) { 
    computeIdsProcessor.idTemplates.find(function (idTempl) { 
        return idTempl.idTemplate === "module:${module}.${docType}:${name}"; 
    }).docTypes.push("controller");}) 
    
  3. Ricordati di includere "controller" in computePathsProcessor

    .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' 
    });})