「JSDoc」の版間の差分

提供: Node.js/JavaScript入門
移動: 案内検索
(ページの作成:「JSDocとは、JavaScriptのためのAPIドキュメントジェネレータです。Doxygenとか、その類のツールです。jsdocコマンドを用いて、HTML...」)
 
(関連項目)
 
行119: 行119:
  
 
== 関連項目 ==
 
== 関連項目 ==
 +
{{jsdoc}}
 
<!-- vim: filetype=mediawiki
 
<!-- vim: filetype=mediawiki
 
-->
 
-->

2014年9月7日 (日) 22:05時点における最新版

JSDocとは、JavaScriptのためのAPIドキュメントジェネレータです。Doxygenとか、その類のツールです。jsdocコマンドを用いて、HTMLドキュメントを生成します。現在は、JSDoc 3が開発されています。

読み方

JSDoc
じゅーえす どっく

概要

いくつものテンプレートが提供されているので、オシャレなドキュメントが簡単に作成できます。

インストール

jsdocをインストールします。jsdocコマンドがインストールされます。

$ sudo npm install -g jsdoc

使用方法

ソースコード

ソースコードにJSDocの記法でドキュメントを記載します。

/*
 * calc.js
 * Copyright (C) 2014 kaoru <kaoru@bsd>
 */
 
/**
 * Return the sum of a and b.
 * @param {Number} a 1st number.
 * @param {Number} b 2nd number.
 * @returns {Number} Sum of number.
 */
function sum(a,b) {
        return a+b;
}

ドキュメントの生成

jsdocコマンドを用いて、ドキュメントを作成します。

$ jsdoc calc.js

自動的に、out というディレクトリが作成され、その中にドキュメントが生成されます。

以下、w3mで表示したページです。

Global

Methods

sum(a, b) → {Number}

    Return the sum of a and b.

    Parameters:

    Name  Type  Description
    a    Number 1st number.
    b    Number 2nd number.

    Source:
          ☆ calc.js, line 15

    Returns:

    Sum of number.

    Type
        Number

Index

Global

  • sum


Documentation generated by JSDoc 3.3.0-alpha9 on Sun Sep 07 2014 21:54:19
GMT+0900 (JST)

使い方

コマンドラインオプション

JSDoc 3.3.0-alpha9 (Sat, 28 Jun 2014 15:26:03 GMT)
 
Options:
    -t, --template <value>       The path to the template to use. Default:
                                 path/to/jsdoc/templates/default
    -c, --configure <value>      The path to the configuration file.
                                 Default: path/to/jsdoc/conf.json
    -e, --encoding <value>       Assume this encoding when reading all
                                 source files. Default: utf8
    -T, --test                   Run all tests and quit.
    -d, --destination <value>    The path to the output folder. Use
                                 "console" to dump data to the console.
                                 Default: ./out/
    -p, --private                Display symbols marked with the @private
                                 tag. Default: false
    -r, --recurse                Recurse into subdirectories when scanning
                                 for source code files.
    -h, --help                   Print this message and quit.
    -X, --explain                Dump all found doclet internals to console
                                 and quit.
    -q, --query <value>          A query string to parse and store in
                                 env.opts.query. Example: foo=bar&baz=true
    -u, --tutorials <value>      Directory in which JSDoc should search for
                                 tutorials.
    -v, --version                Display the version number and quit.
    --debug                      Log information for debugging JSDoc. On
                                 Rhino, launches the debugger when passed as
                                 the first option.
    --verbose                    Log detailed information to the console as
                                 JSDoc runs.
    --pedantic                   Treat errors as fatal errors, and treat
                                 warnings as errors. Default: false
    --match <value>              Only run tests containing <value>.
    --nocolor                    Do not use color in console output from
                                 tests.
 
Visit http://usejsdoc.org for more information.

関連項目