为什么ngdocs会生成0个文件?

时间:2014-04-28 16:13:03

标签: javascript gruntjs jsdoc

我已经设置了一个非常简单的项目来测试grunt-ngdocs(https://www.npmjs.org/package/grunt-ngdocs)。但是,当我尝试生成文档时,它无法识别任何注释。为什么?!救命啊!

Gruntfile.js

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    ngdocs: {
      options:{dest: 'docs'},
      api:{
        src:['someCode.js'],
        title:'API Documentation'
      }
    }
  });

  // Load the plugin that provide tasks.
  grunt.loadNpmTasks('grunt-ngdocs');

};

someCode.js

/**
 *
 * This is a sample function
 * @param x
 * @returns {number}
 */
var myFunc = function(x){
  return 2*x;
};

控制台输出:

slc058:ngDocPlay selah$ grunt ngdocs
Running "ngdocs:api" (ngdocs) task
Generating Documentation...
DONE. Generated 0 pages in 7ms.

Done, without errors.

1 个答案:

答案 0 :(得分:2)

我将someCode.js修改为以下内容然后才有效!

someCode.js

/**
 * @ngdoc function
 * @name myFunc
 * @description
 * This is a sample function
 * @param {number} x - any number, don't matter which
 */
var myFunc = function(x){
  return 2*x;
};