2015-10-08 6 views
5

मैं एक कोणीय सेवा के भीतर एक समारोह घोषणा में ngdoc दस्तावेज जोड़ना चाहता हूं। मैं नीचे दिए गए उदाहरण में अपने समारोह के लिए यह कैसे कर सकता हूं?कोणीय सेवा में फ़ंक्शन घोषणा को दस्तावेज़ित करने के लिए ngdoc का उपयोग कैसे किया जा सकता है?

मुझे लगता है कि मुझे @closure, @functionOf या @functionIn जैसे कुछ चाहिए।

कृपया ध्यान दें कि (myMethod के विपरीत) myFunction एक विधि नहीं है।

/** 
* @ngdoc service 
* @name myApp.service:myService 
* @description 
* My application. 
*/ 
angular 
    .module('myApp') 
    .factory('myService', function() { 
    'use strict'; 

    var x = 0; 

    /** 
    * @ngdoc function 
    * @name ? 
    * @description 
    * How can this be identified as being within the closure of 
    * myService, and not be described as a constructor? 
    */ 
    function myFunction (z) { 
     x++; 
     x += z; 
    } 

    return { 
     /** 
     * @ngdoc method 
     * @name myMethod 
     * @methodOf myApp.service:myService 
     * @description 
     * A method of myService. 
     */ 
     myMethod : function (x) { 
     myFunction(x); 
     } 
    }; 
    }) 
+0

मैं यहाँ ngdocs के लिए दस्तावेज़ पाया: https://github.com/idanush/ngdocs/wiki/API-Docs-Syntax – paulhhowells

+0

और यहाँ: https://github.com/angular /angular.js/wiki/Writing-AngularJS- दस्तावेज – paulhhowells

उत्तर

5

जो कुंजी नाम आप खोज रहे हैं वह @methodOf एनोटेशन है। जब मैं एक सेवा यह समाप्त होता है निम्नलिखित की तरह लग रही के लिए घुरघुराना-ngdocs का उपयोग करके दस्तावेज़ लिख रहा हूँ:

/** 
    * @ngdoc overview 
    * @name module 
    * @description A small module containing stuff 
    */ 
angular 
    .module(module, []) 
    .factory('name', factory); 

/** 
    * @ngdoc object 
    * @name module.name 
    * @description Its a pretty bad factory 
    */ 
function factory() { 
    return { 
    doSomething: doSomething 
    }; 

    /** 
    * @ngdoc function 
    * @name module.name#doSomething 
    * @methodOf module.name 
    * @description Does the thing 
    * @param {string=} [foo='bar'] This is a parameter that does nothing, it is 
            optional and defaults to 'bar' 
    * @returns {undefined} It doesn't return 
    */ 
    function doSomething(foo){...} 
} 
+1

उत्तर लिखने के लिए धन्यवाद। मेरा सवाल यह था कि एक समारोह घोषणा दस्तावेज कैसे करें जो सेवा की विधि नहीं है। कोड उदाहरण में मैंने दिया है कि मैं myFunction (जो एक विधि नहीं है) के साथ ngdoc का उपयोग करने का एक तरीका खोजना चाहता हूं। कोड उदाहरण भी विधि का उपयोग किया गया है जिसका उपयोग myMethod (जो एक विधि है) के साथ किया जा रहा है। आपके उदाहरण में कुछ ऐसा तरीका है जिससे विधि का उपयोग करना समझ में आता है। – paulhhowells

0

मैं केवल JSDoc, नहीं ngdoc के साथ अनुभव है, लेकिन आप @memberOf बजाय @methodOf की कोशिश की है?

Link to JSDoc page for memberOf

+0

अब तक मुझे 'my सदस्य' उत्पन्न करने वाले फ़ंक्शन को बंद करने के अंदर 'myFunction' को दस्तावेज़' करने के लिए '@ सदस्य ओएफ', 'सदस्य' या' @ निजी 'का उपयोग करने के लिए ngdoc के साथ कोई रास्ता नहीं मिला है। JSDoc में कार्यक्षमता का एक उचित बिट है जो ngdoc में उपलब्ध प्रतीत नहीं होता है। मदद करने के लिए धन्यवाद के लिए धन्यवाद। – paulhhowells

0
/** 
* @ngdoc controller 
* @name MyApp.myController:myController 
* @description 
* This is myController controller. 
**/   
angular.module('MyApp').controller('myController', ['$scope', function($scope) {  

    /** 
    * @ngdoc function 
    * @name myFunction 
    * @methodOf MyApp.controller:myController 
    * @description 
    * This function does something 
    */ 
    function myFunction(){ 
    // do something 
    } 

}]); 
+0

myFunction एक विधि नहीं है – paulhhowells

संबंधित मुद्दे

 संबंधित मुद्दे