百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
J

jdi

> 编程语言
开源

:blue_book: 一个用于生成文档的 JavaScript 文档生成器

100 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

:blue_book: 一个用于生成文档的 JavaScript 文档生成器

:blue_book: jdi

jdi is a documentation generator for JavaScript. You give it some source files (e.g. via jdi index.js) and it generates corresponding .md files from your comments (e.g index.js.md).

Inspired by the concepts of Literate programming, it encourages you to heavily document your code using Markdown.

Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do. — Donald E. Knuth, Literate Programming

Example

jdi is documented using jdi. Checkout index.js.md and jdi.md for an example. You can view the documentation via the GitHub web interface or using a Markdown previewer / editor, such as vmd:

Motivation

Let's face it: The majority of JSDoc comments are completely useless and a waste of time for the author, as well as the reader.

We shouldn't (just) document what a particular piece of code does, instead we should focus on why it does what it does. Reading source code should be more like reading a guide, as opposed to reading a manual.

I think literate programming is a wonderful concept, but I don't think introducing a separate format for programs written in "literate" form is the right way to go. Instead we should continue extracting documentation from source code, but the comments should build "frame" around your code.

Installation

The recommended way to install jdi is via npm:

bash
npm i jdi -g

-g installs jdi globally, so it can be used from the command line. Alternatively you can install jdi locally as a devDependency:

bash
npm i jdi --save-dev

Usage

Using jdi is trivial. Just some source files to it and it will happily create corresponding Markdown documents:

bash
jdi **/*.js
~/r/jdi (master) $ jdi --help

  Usage: jdi [options]

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

jdi supports globbing. If you want glob to perform the expansion on a system where the shell already does that (e.g. when using fish shell), quote the file arguments:

bash
jdi '**/*.js'

Protip: Use a Makefile for keeping your .md files in-sync with your source files:

make
%.md: %
	@./node_modules/.bin/jdi $<
bash
~/r/jdi (master) $ make index.js.md
wrote 6385 bytes to index.js.md

But after the initial run, no further .md files will be built:

bash
~/r/jdi (master) $ make index.js.md
make: `index.js.md' is up to date.

Programmatic usage

You can also require('jdi') and use the public API directly.

Prior works of art

  • Docco is quite similar, but instead of generating Markdown files, it generates HTML. Since everyone has their favorite Markdown editor anyways, I don't see any reason to actually render to generated Markdown to HTML (even though that would be trivial).
  • literate-programming is deprecated. It also extracts code from your Markdown documents as opposed to extracting Markdown from your source code. While this is closer to the original idea behind literate programming, I don't think introducing an additional build step is the way to go.

License

See LICENSE.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言