generate reference documentation

Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
Christian Goll
2023-03-02 12:18:59 +01:00
parent ee7bc75bd7
commit fa78d582eb
7 changed files with 55 additions and 2 deletions

1
.gitignore vendored
View File

@@ -38,3 +38,4 @@ Defaults.mk
/etc/wwapird.conf
.dist/
userdocs/_*
userdocs/reference/*

View File

@@ -101,7 +101,7 @@ export GOPROXY
WW_GO_BUILD_TAGS := containers_image_openpgp containers_image_ostree
# Default target
all: config vendor wwctl wwclient man_pages config_defaults print_defaults wwapid wwapic wwapird print_mnts
all: config vendor wwctl wwclient man_pages config_defaults print_defaults wwapid wwapic wwapird
# Validate source and build all packages
build: lint test-it vet all
@@ -255,6 +255,12 @@ dist: vendor config
cd .dist; tar -czf ../$(WAREWULF)-$(VERSION).tar.gz $(WAREWULF)-$(VERSION)
rm -rf .dist
reference: wwctl
./wwctl genconfig reference userdocs/reference/
latexpdf: reference
make -C userdocs latexpdf
## wwapi generate code from protobuf. Requires protoc and protoc-grpc-gen-gateway to generate code.
## To setup latest protoc:
## Download the protobuf-all-[VERSION].tar.gz from https://github.com/protocolbuffers/protobuf/releases

View File

@@ -0,0 +1,17 @@
package reference
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
linkHandler := func(name, ref string) string {
return fmt.Sprintf(":ref:`%s <%s>`", name, ref)
}
err = doc.GenReSTTreeCustom(cmd.Parent().Parent(), args[0], func(arg string) string { return "" }, linkHandler)
//err = doc.GenReSTTree(cmd.Parent().Parent(), args[0])
return
}

View File

@@ -0,0 +1,22 @@
package reference
import (
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
Use: "reference",
Short: "reference generation",
Long: "This command generates the references in ReStructured Text, needs target dir as argument",
RunE: CobraRunE,
Args: cobra.ExactArgs(1),
}
)
func init() {
}
func GetCommand() *cobra.Command {
return baseCmd
}

View File

@@ -3,6 +3,7 @@ package genconf
import (
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/completions"
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/man"
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/reference"
"github.com/spf13/cobra"
)
@@ -21,6 +22,7 @@ var (
func init() {
baseCmd.AddCommand(completions.GetCommand())
baseCmd.AddCommand(man.GetCommand())
baseCmd.AddCommand(reference.GetCommand())
}
// GetRootCommand returns the root cobra.Command for the application.

View File

@@ -41,9 +41,14 @@ Welcome to the Warewulf User Guide!
Documentation <contributing/documentation>
Development Environment (KVM) <contributing/development-environment-kvm>
Development Environment (VirtualBox) <contributing/development-environment-vbox>
Glossary <contents/glossary>
.. toctree::
:maxdepth: 2
:caption: Reference
:glob:
reference/*
Glossary <reference/glossary>