JSDocしたい(jsdoc

$ jsdoc ./パス/**/*.js
$ jsdoc -c 設定.json -d ./出力先 ./パス/**/*.js

jsdocでJavaScriptのdocstringからドキュメントを作成できます。

インストールしたい(jsdoc

$ brew install jsdoc3
$ jsdoc --version
JSDoc 4.0.4 (Sat, 19 Oct 2024 19:05:34 GMT)

設定ファイルしたい(conf.json

{
  "source": {
    "include": ["パス1", "パス2"],
    "includePattern": ".+\\.js$"
  },
  "opts": {
    "destination": "./docs/jsdoc",
    "recurse": true,
    "template": "templates/default"
  }
}

conf.jsonでJSDocのオプションを設定できます。

ドキュメントしたい

1/**
2 * 関数の説明
3 *
4 * @param {} 引数名 - 説明
5 * @return {} 返り値 - 説明
6 * /
7function 関数名(引数) { ... }
  • string: 文字列

  • number: 数値

  • boolean: 真偽値

  • undefined: 未定義

  • null: ヌル型

  • symbol: シンボル型

  • Object: オブジェクト型

  • Array.<型>: 配列オブジェクト型

  • Function: 関数オブジェクト型

  • Date: 日付オブジェクト型

  • any: 任意の型

  • 型1|型2: ユニオン型

リファレンス