clidocs

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clidocs is the docs group under osapi dsl: osapi dsl docs generate, which writes the generated pages of the docs site.

Index

Constants

This section is empty.

Variables

View Source
var Group = command.Register(command.Define(
	"docs", "Write the generated pages of the docs site",
	command.Under(command.ParentDSL),
	command.Uses[Deps](),
	command.Method[GenerateInput, GenerateOutput]("generate").
		Short("Write the CLI, DSL and reference pages of the docs site").
		Long("It writes each generated page of the docs site from this binary, and\n"+
			"removes each generated page that no command, DSL or group has now:\n\n"+
			"- a page for each command, under `docs/docs/sidebar/usage/cli`;\n"+
			"- a page for each DSL, under `docs/docs/sidebar/development/dsl`, from the\n"+
			"  spec that the `spec get` command of the DSL prints;\n"+
			"- a page for each behavior, chain, endpoint group and local group, under\n"+
			"  `docs/docs/sidebar/reference`, from the output of its `list` or `get`\n"+
			"  command, such as `osapi dsl behavior get --name dns`.\n\n"+
			"A DSL page that a person wrote stays. `just cli-docs-generate` runs it, and\n"+
			"`just test` checks that the pages match the binary.").
		Example("").
		Prints(sampleGenerate).
		Example("--root ~/src/osapi").
		Handle(Generate),
))

Group is the docs group's definition.

Functions

This section is empty.

Types

type CLIInput

type CLIInput struct {
	Dir string `json:"dir" validate:"omitempty" doc:"Directory of the CLI reference pages" default:"docs/docs/sidebar/usage/cli"`
}

CLIInput is where to write the pages.

type CLIOutput

type CLIOutput struct {
	Dir   string `                      json:"dir"`
	Pages int    `                      json:"pages"`
	// contains filtered or unexported fields
}

CLIOutput is where the pages are, and how many there are.

func WriteCLI

func WriteCLI(
	_ context.Context,
	d Deps,
	in CLIInput,
) (CLIOutput, error)

WriteCLI writes the page of each command of the binary into the directory, and removes each page there that no command has.

type DSL

type DSL struct {
	Slug     string
	Title    string
	Intro    string
	Position int
	Spec     guide.Spec
}

DSL is one DSL of the binary as a page of the docs site: its file name, title, intro, place in the sidebar, and its spec, the same that its spec get command prints.

type DSLInput

type DSLInput struct {
	Dir string `json:"dir" validate:"omitempty" doc:"Directory of the DSL pages" default:"docs/docs/sidebar/development/dsl"`
}

DSLInput is where to write the DSL pages.

type DSLOutput

type DSLOutput struct {
	Dir   string `                      json:"dir"`
	Pages int    `                      json:"pages"`
	// contains filtered or unexported fields
}

DSLOutput is where the DSL pages are, and how many there are.

func WriteDSL

func WriteDSL(
	_ context.Context,
	d Deps,
	in DSLInput,
) (DSLOutput, error)

WriteDSL writes a page for each DSL of the binary into in.Dir, and removes each generated page there that no DSL has. A page that a person wrote, with no guide.Generated line, stays.

type Deps

type Deps struct {
	Root *cobra.Command
	DSLs func() []DSL
	// Pages are the pages of the reference: each is the output of the list
	// or get commands that show it.
	Pages func() ([]Page, error)
	// Tables is page, a page that a person wrote, with each generated table
	// in it written again, such as the config keys of a feature page. root
	// is the repository's root, which has the files a table reads.
	Tables func(root string, page string) (string, error)
}

Deps is what the methods use: the root command, whose tree generate documents, and the DSLs, whose specs dsl generate writes as pages.

type GenerateInput

type GenerateInput struct {
	Root string `json:"root" validate:"omitempty" doc:"Root of the osapi repository" default:"."`
}

GenerateInput is the root of the repository whose pages to write.

type GenerateOutput

type GenerateOutput struct {
	CLI       int `             json:"cli"       label:"CLI pages"`
	DSL       int `             json:"dsl"       label:"DSL pages"`
	Reference int `             json:"reference" label:"Reference pages"`
	// contains filtered or unexported fields
}

GenerateOutput is how many pages of each kind generate wrote.

func Generate

func Generate(
	ctx context.Context,
	d Deps,
	in GenerateInput,
) (GenerateOutput, error)

Generate writes each generated page of the docs site under in.Root: the page of each command, of each DSL and of the reference.

type Page

type Page struct {
	Path    string
	Title   string
	Intro   string
	Partial bool
	Parts   []Part
	// Text, when set, is the whole file, such as the _category_.json that
	// gives a folder its label and its place in the sidebar.
	Text string
}

Page is one page of the reference, at Path from the repository root. A partial, such as _catalog.mdx, is a part that a landing page imports: it has no front matter and no title. Each part is the output of a command of the group Group, rendered as the CLI prints it.

type Part

type Part struct {
	Group string
	Out   any
	// Heading, when set, heads the part in place of its output's title.
	Heading string
	// Link, when set, is the page that a cell of a table links to, by the
	// header of its column and its text.
	Link func(header string, cell string) string
}

Part is the output of one command, and the group whose output it is.

type ReferenceInput

type ReferenceInput struct {
	Root string `json:"root" validate:"omitempty" doc:"Root of the osapi repository" default:"."`
}

ReferenceInput is the root of the repository whose reference to write.

type ReferenceOutput

type ReferenceOutput struct {
	Pages int `                  json:"pages"`
	// contains filtered or unexported fields
}

ReferenceOutput is how many pages the reference has.

func WriteReference

func WriteReference(
	_ context.Context,
	d Deps,
	in ReferenceInput,
) (ReferenceOutput, error)

WriteReference writes each page of the reference, from the outputs of the commands that show it, and removes each generated page there that no command writes now. A _category_.json in a folder under a reference directory is generated too: one that no command writes now is removed, then each folder that is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL