Documentation
¶
Overview ¶
Package webdocs renders a urfave/cli v3 command tree as static HTML. See docs/webdocs-package.md for pipeline, layout modes, and design.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render writes documentation for cmd into Options.OutputDir.
Example ¶
Render documentation for a *cli.Command. Single-page is the default; Options.PerPage = true emits one HTML file per visible subcommand.
package main
import (
"fmt"
"os"
"path/filepath"
webdocs "github.com/coilysiren/cli-web-docs"
"github.com/urfave/cli/v3"
)
func main() {
app := &cli.Command{
Name: "demo",
Usage: "tiny demo cli",
Commands: []*cli.Command{
{Name: "hello", Usage: "say hello"},
},
}
dir, _ := os.MkdirTemp("", "webdocs-example-*")
defer os.RemoveAll(dir)
if err := webdocs.Render(app, webdocs.Options{
OutputDir: dir,
Title: "Demo Docs",
}); err != nil {
fmt.Println("render:", err)
return
}
_, err := os.Stat(filepath.Join(dir, "index.html"))
fmt.Println("index.html exists:", err == nil)
}
Output: index.html exists: true
Types ¶
type Options ¶
type Options struct {
// OutputDir is the directory to write into. Created if it does not
// exist. Required.
OutputDir string
// Title overrides the page <title>. Defaults to the root command name.
Title string
// PerPage = true emits one HTML file per visible subcommand at
// "<path>.html" plus an index.html that lists the tree.
PerPage bool
// CSS overrides the embedded default stylesheet. Empty = use the
// shared layout.DefaultCSS.
CSS string
}
Options control the rendered output. Zero value is usable: single-page mode, default CSS, title taken from cmd.Name.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
custom-theme
command
Command custom-theme overrides the default stylesheet with operator CSS.
|
Command custom-theme overrides the default stylesheet with operator CSS. |
|
deep-tree
command
Command deep-tree renders a three-level nested CLI with a realistic flag surface.
|
Command deep-tree renders a three-level nested CLI with a realistic flag surface. |
|
multi-page
command
Command multi-page renders a small CLI as a multi-page docs site: one HTML file per visible subcommand plus an index that lists the tree.
|
Command multi-page renders a small CLI as a multi-page docs site: one HTML file per visible subcommand plus an index that lists the tree. |
|
render
command
Command render is a tiny example that emits cli-web-docs HTML for a sample CLI into ./site.
|
Command render is a tiny example that emits cli-web-docs HTML for a sample CLI into ./site. |
|
Package layout is the shared HTML shell for the cli-web-* family.
|
Package layout is the shared HTML shell for the cli-web-* family. |
Click to show internal directories.
Click to hide internal directories.