Skip to content

Commit 14981b6

Browse files
inhereclaude
andcommitted
docs: 记录命令文档生成特性, 标记 D3 完成
CHANGELOG/README/README.zh-CN 增加 docgen + GenDoc 说明; TODO 勾选 man/markdown 文档生成; plan 状态改为已完成并勾选提交拆分。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a64140e commit 14981b6

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ and this project adheres to semantic-ish versioning.
3434
their underlying `flag.Value`. In a sub-command's help, options inherited from
3535
ancestors are grouped under an **`Inherited Options`** section (a command's own
3636
shared options render with its local options).
37+
- **命令文档生成: 新增 `docgen` 包 + builtin `GenDoc` 命令** (≈ cobra 的 `cobra/doc`).
38+
`docgen` 可把单命令/整个 App 渲染为 **markdown** (`CmdMarkdown`/`AppMarkdown`/`MarkdownTree`)
39+
**man page(roff)** (`CmdMan`/`ManTree`)。app 添加 `builtin.GenDoc()` 后即可
40+
`./cliapp gendoc -f md|man -o ./docs` 导出。配套新增 `gflag.CliOpt.TypeName()` 类型名访问器。
3741

3842
[v3.8.0]: https://github.com/gookit/gcli/compare/v3.7.0...HEAD
3943

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Including running commands, color styles, data display, progress display, intera
4646
- Automatically generate command help information and support color display
4747
- When the command entered is incorrect, a similar command will be prompted(including an alias prompt)
4848
- Supports generation of `zsh` and `bash` command completion script files
49+
- Supports generation of `markdown` / `man page` command documentation (via `docgen` package + builtin `GenDoc` command)
4950
- Supports a single command as a stand-alone application
5051

5152
**Flag Options**:

README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The english introduction please ses **[README](README.md)**
4545
- 自动处理返回错误,`error` 会自动渲染为错误提示信息
4646
- 自动根据命令生成帮助信息,并且支持颜色显示
4747
- 支持为当前CLI应用生成 `zsh`,`bash` 下的命令补全脚本文件
48+
- 支持生成 `markdown` / `man page` 命令文档(通过 `docgen` 包 + builtin `GenDoc` 命令)
4849
- 支持将单个命令当做独立应用运行
4950

5051
## GoDoc

docs/TODO.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646

4747
> 背景与依据见 [compare-with-others.zh-CN.md](compare-with-others.zh-CN.md) 的「gcli 的差距」。
4848
49-
- [ ] 支持 man page / markdown 命令文档生成
49+
- [x] **D3 支持 man page / markdown 命令文档生成**(增量、零破坏)— [plans/feat-D3-doc-generation.md](plans/feat-D3-doc-generation.md)
50+
- [x] 新增 `docgen` 包:`CmdMarkdown/AppMarkdown/MarkdownTree` + `CmdMan/ManTree`;builtin `GenDoc()` 命令;`gflag.CliOpt.TypeName()` 访问器
51+
(commit ff308c0/58d21b6/9189f4c/a64140e)
52+
- 对标:cobra 的 `cobra/doc``GenMarkdownTree` / `GenManTree`
5053
- [x] **D1 结构体绑定:去 unsafe + 类型丰富度**(增量、低风险)— [plans/feat-D1-struct-binding.md](plans/feat-D1-struct-binding.md)
5154
- [x] `gflag/parser.go` `fromStructValue` 基础类型分支去掉 `unsafe.Pointer`/`UnsafeAddr()`
5255
改用安全的 `fv.Addr().Interface().(*T)`(commit 7830e0e)

docs/plans/feat-D3-doc-generation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 功能实现计划:D3 命令文档生成(man / markdown)
22

3-
> 状态:**待实施**
3+
> 状态:**已完成**(commit ff308c0/58d21b6/9189f4c/a64140e + 文档)
44
> 范围:新增 `docgen` 包 + builtin `GenDoc` 命令 + gflag 小访问器;约 4-6 个文件。
55
> 依据:[../compare-with-others.zh-CN.md](../compare-with-others.zh-CN.md) 差距「文档生成」;[../TODO.md](../TODO.md) 对标改进。
66
> 对标:cobra 的 `cobra/doc``GenMarkdownTree` / `GenManTree`)。
@@ -61,8 +61,8 @@
6161
- gendoc 命令:run 后目录下生成文件、退出码 0。
6262

6363
## 提交拆分(按 R002)
64-
1. `feat(gflag): 增加 CliOpt.TypeName() 类型名访问器`
65-
2. `feat(docgen): markdown 命令文档生成(CmdMarkdown/AppMarkdown/MarkdownTree)`
66-
3. `feat(docgen): man page 命令文档生成(CmdMan/ManTree)`
67-
4. `feat(builtin): GenDoc 命令导出 md/man 文档`
68-
5. `docs: CHANGELOG/README/TODO 记录文档生成特性`
64+
1. [x] `feat(gflag): 增加 CliOpt.TypeName() 类型名访问器`(commit ff308c0)
65+
2. [x] `feat(docgen): markdown 命令文档生成(CmdMarkdown/AppMarkdown/MarkdownTree)`(commit 58d21b6)
66+
3. [x] `feat(docgen): man page 命令文档生成(CmdMan/ManTree)`(commit 9189f4c)
67+
4. [x] `feat(builtin): GenDoc 命令导出 md/man 文档`(commit a64140e)
68+
5. [x] `docs: 记录命令文档生成特性, 标记 D3 完成`

0 commit comments

Comments
 (0)