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 ¶
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.
type DSL ¶
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.
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.