我想将ngdoc文档添加到角度服务中的函数声明中。如何在下面的示例中为myFunction执行此操作?
我认为我需要像@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 :(得分:6)
您要查找的密钥名称是@methodOf
注释。
当我使用grunt-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 :(得分:0)
我只有使用JSDoc的经验,而不是ngdoc,但您是否尝试过phone
而不是import serial
import time
def writeChar(port, char, bVerify = True):
port.flush()
port.write("\xFD")
if (char.isupper()):
# Shift left
write("\x02")
else:
port.write("\x00")
port.write("\x00")
port.write(Keys[char.upper()])
port.write("\x00")
port.write("\x00")
port.write("\x00")
port.write("\x00")
port.write("\x00")
if (char != "KEY_NONE"):
time.sleep(.1)
writeChar(port, "KEY_NONE", False)
if (bVerify):
inChar = port.read()
def writeChar2(port, char):
port.flush()
port.write(Keys2[char]+'\x00')
?
答案 2 :(得分: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
}
}]);