Пример #1
0
// Note: We have a separate binary for generating federation docs and kube docs because of the way api groups are api.Registry.
// If we import both kube-apiserver and federation-apiserver in the same binary then api groups from both kube and federation will get registered in both the apiservers
// and hence will produce incorrect flag values.
// We can potentially merge cmd/kubegendocs and this when we have fixed that problem.
func main() {
	// use os.Args instead of "flags" because "flags" will mess up the man pages!
	path := ""
	module := ""
	if len(os.Args) == 3 {
		path = os.Args[1]
		module = os.Args[2]
	} else {
		fmt.Fprintf(os.Stderr, "usage: %s [output directory] [module] \n", os.Args[0])
		os.Exit(1)
	}

	outDir, err := genutils.OutDir(path)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
		os.Exit(1)
	}

	switch module {
	case "federation-apiserver":
		// generate docs for federated-apiserver
		apiserver := fedapiservapp.NewAPIServerCommand()
		doc.GenMarkdownTree(apiserver, outDir)
	case "federation-controller-manager":
		// generate docs for kube-controller-manager
		controllermanager := fedcmapp.NewControllerManagerCommand()
		doc.GenMarkdownTree(controllermanager, outDir)
	default:
		fmt.Fprintf(os.Stderr, "Module %s is not supported", module)
		os.Exit(1)
	}
}
Пример #2
0
func do(appEnvObj interface{}) error {
	// passing empty addresses for pfsd and ppsd, that's fine because we're not
	// going to execute the command but print docs with it
	rootCmd, err := cmd.PachctlCmd("")
	if err != nil {
		return err
	}
	return doc.GenMarkdownTree(rootCmd, "./doc/pachctl/")
}
Пример #3
0
func (d *docsCmd) run() error {
	switch d.docTypeString {
	case "markdown", "mdown", "md":
		return doc.GenMarkdownTree(d.topCmd, d.dest)
	case "man":
		manHdr := &doc.GenManHeader{Title: "HELM", Section: "1"}
		return doc.GenManTree(d.topCmd, manHdr, d.dest)
	case "bash":
		return d.topCmd.GenBashCompletionFile(filepath.Join(d.dest, "completions.bash"))
	default:
		return fmt.Errorf("unknown doc type %q. Try 'markdown' or 'man'", d.docTypeString)
	}
}
Пример #4
0
Файл: lifx.go Проект: pdf/golifx
func generateDocs(c *cobra.Command, args []string) {
	if len(args) != 1 {
		if err := c.Usage(); err != nil {
			logger.WithField(`error`, err).Fatalln(`Failed to print usage`)
		}
		fmt.Println()
		logger.Fatalln(`Missing output path`)
	}

	path := args[0]
	if path[len(path)-1] != os.PathSeparator {
		path += string(os.PathSeparator)
	}
	if err := doc.GenMarkdownTree(app, path); err != nil {
		logger.WithFields(logrus.Fields{
			`filename`: args[0],
			`error`:    err,
		}).Fatalln(`Could no generate markdown`)
	}
}
Пример #5
0
func main() {
	// use os.Args instead of "flags" because "flags" will mess up the man pages!
	path := "docs/"
	if len(os.Args) == 2 {
		path = os.Args[1]
	} else if len(os.Args) > 2 {
		fmt.Fprintf(os.Stderr, "usage: %s [output directory]\n", os.Args[0])
		os.Exit(1)
	}

	outDir, err := genutils.OutDir(path)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
		os.Exit(1)
	}

	// Set environment variables used by kubectl so the output is consistent,
	// regardless of where we run.
	os.Setenv("HOME", "/home/username")
	// TODO os.Stdin should really be something like ioutil.Discard, but a Reader
	kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
	doc.GenMarkdownTree(kubectl, outDir)
}
Пример #6
0
func main() {
	doc.GenMarkdownTree(cmds.New(), "./Documentation/usage")
}
Пример #7
0
// Copyright © 2016 Geoff Holden <*****@*****.**>

package cmd

import (
	"github.com/spf13/cobra"
	"github.com/spf13/cobra/doc"
	"github.com/spf13/viper"
)

// markdownCmd represents the markdown command
var markdownCmd = &cobra.Command{
	Use:   "markdown",
	Short: "Generate Markdown documentation",
	Long:  `Generates documentation for gowx in Markdown format.`,
	Run: func(cmd *cobra.Command, args []string) {
		doc.GenMarkdownTree(RootCmd, viper.GetString("output"))
	},
}

func init() {
	docCmd.AddCommand(markdownCmd)
}
Пример #8
0
func main() {
	cmd.RootCmd.DisableAutoGenTag = true
	doc.GenMarkdownTree(cmd.RootCmd, "./docs")
}
Пример #9
0
// docsMarkdownCmd represents the markdown command
var docsMarkdownCmd = &cobra.Command{
	Use:   "markdown",
	Short: "Generates markdown documentation for fissile.",
	RunE: func(cmd *cobra.Command, args []string) error {
		var err error

		flagDocsMarkdownOutputDir = viper.GetString("md-output-dir")

		if flagDocsMarkdownOutputDir, err = absolutePath(
			flagDocsMarkdownOutputDir,
		); err != nil {
			return err
		}

		return doc.GenMarkdownTree(RootCmd, flagDocsMarkdownOutputDir)
	},
}

func init() {
	docsCmd.AddCommand(docsMarkdownCmd)

	docsMarkdownCmd.PersistentFlags().StringP(
		"md-output-dir",
		"O",
		"./docs",
		"Specifies a location where markdown documentation will be generated.",
	)

	viper.BindPFlags(docsMarkdownCmd.PersistentFlags())
}
Пример #10
0
Файл: brag.go Проект: garthk/nag
func genMarkdownTree(cmd *cobra.Command, dirname string) error {
	return doc.GenMarkdownTree(cmd, dirname)
}