JSDoc什么都不打印

时间:2015-09-08 13:50:00

标签: javascript jsdoc

我有下一个代码

element.js

(function(){

        /**
         * Element builder
         * @param {string} url
         * @constructor
         **/
        element = function(url){
                /**
                 * Web service url
                 * @type {string} Url service
                 * @private 
                 */
                this._url = url;
        };

        /**
         * Open web service 
         * @param {Object} param
         **/
        element.prototype.open = function(param){
        };
})();

我正在尝试测试js doc并获取有关我的代码的一些文档。

我运行下一个命令

jsdoc --debug element.js

我收到了下一条消息

DEBUG: JSDoc 3.3.2 (Sat, 13 Jun 2015 22:20:28 GMT)
DEBUG: Environment info: {"env":{"conf":{"tags":{"allowUnknownTags":true,"dictionaries":["jsdoc","closure"]},"templates":{"monospaceLinks":false,"cleverLinks":false,"default":{"outputSourceFiles":true}},"source":{"includePattern":".+\\.js(doc)?$","excludePattern":"(^|\\/|\\\\)_"},"plugins":[]},"opts":{"_":["element.js"],"debug":true,"destination":"./out/","encoding":"utf8"}}}
DEBUG: Parsing source files: ["/home/ismael-trabajo/Escritorio/js/element.js"]
Parsing /home/ismael-trabajo/Escritorio/js/element.js ...WARNING: The @type tag does not permit a description; the description will be ignored. File: element.js, line: 9
WARNING: The @type tag does not permit a description; the description will be ignored. File: element.js, line: 14
complete.
DEBUG: Finished parsing source files.
DEBUG: Indexing doclets...
DEBUG: Adding inherited symbols, mixins, and interface implementations...
DEBUG: Adding borrowed doclets...
DEBUG: Post-processing complete.
Generating output files...complete.
Finished running in 0.31 seconds.

输出为index.html,空文件。我做错了什么?

的index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Home</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Home</h1>
    <h3> </h3>
</div>

<nav>
    <h2><a href="index.html">Home</a></h2>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a> on Tue Sep 08 2015 15:35:49 GMT+0200 (CEST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

谢谢大家!

1 个答案:

答案 0 :(得分:5)

我找到的解决方案是使用命名空间。

/**
 * Handles elements
 * @namespace myNameSpace
 */
(function(){

    /**
     * Element builder
     * @param {string} url
     * @constructor
     * @memberof myNameSpace
     **/
    element = function(url){
        /**
         * Web service url
         * @type {string} Url service
         * @private
         */
        this._url = url;
    };

    /**
     * Open web service
     * @param {Object} param
     * @memberof myNameSpace
     **/
    element.prototype.open = function(param){
    };
})();