manual: the shared "<program> manual" command (ADR-0012)
FromFS turns embedded README.md + docs/**/*.md into topics (README is "readme", titles from the first heading); Run serves "manual", "manual <topic>" and "manual --json [topic]" -- the JSON shape yet reads for an installed program's manual (yet manual --package, TUI, yet-gui), same as "yet manual --json". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e8bf23a064
commit
e757fdd025
3 files changed
+294
No files matched your search
@@ -13,6 +13,7 @@ configuration resolution**: `core/paths` and `core/config`.
|
||||
yetano.dev/yetano/core
|
||||
yetano.dev/yetano/core/paths
|
||||
yetano.dev/yetano/core/config
|
||||
yetano.dev/yetano/core/manual
|
||||
```
|
||||
|
||||
Target platforms: Linux, FreeBSD, macOS, Windows. No Unix assumptions
|
||||
@@ -244,6 +245,29 @@ ecosystem-wide, shared settings (`repositories.yaml`, `trust.yaml`,
|
||||
layered into, any one application's own configuration. An application
|
||||
opts in explicitly with `config.WithYetanoDefaults(true)`.
|
||||
|
||||
## core/manual: the "<program> manual" command
|
||||
|
||||
Every Yetano program serves its own documentation (ADR-0012), embedded
|
||||
in the binary. `core/manual` is that command in one shared shape:
|
||||
|
||||
```go
|
||||
// at the module root (go:embed can't reach parent directories):
|
||||
//go:embed README.md docs
|
||||
var docsFS embed.FS
|
||||
var Manual = manual.MustFromFS("yasl", docsFS)
|
||||
|
||||
// in the CLI dispatch:
|
||||
case "manual", "doc":
|
||||
if err := yasl.Manual.Run(args[1:], os.Stdout); err != nil { ... exit non-zero ... }
|
||||
```
|
||||
|
||||
`FromFS` makes `README.md` the topic `readme` and every `docs/**/*.md`
|
||||
a topic (slug = path below `docs/` without `.md`, title = first `#`
|
||||
heading). `Run` serves `manual`, `manual <topic>` and `manual --json
|
||||
[topic]`; the JSON form (`[{slug,title,path}]` / `{slug,title,path,
|
||||
markdown}`) is what yet reads to show an installed program's manual
|
||||
(`yet manual --package`, its TUI and yet-gui).
|
||||
|
||||
## Security
|
||||
|
||||
- Environment expansion is variable substitution only -- never shell
|
||||
|
||||
Reference in new issue
Block a user