Skip to content

Generate cobra docs compatible with the snooty docs tooling

License

Notifications You must be signed in to change notification settings

mongodb-labs/cobra2snooty

Repository files navigation

cobra2snooty

CI

Generate Snooty docs for the entire command tree

This program can actually generate docs for the mongocli command in the MongoDB CLI project

package main

import (
	"log"
	"os"

	"github.com/mongodb/mongocli/internal/cli/root"
	"github.com/mongodb-labs/cobra2snooty"
)

func main() {
	var profile string
	const docsPermissions = 0766
	if err := os.MkdirAll("./docs/command", docsPermissions); err != nil {
		log.Fatal(err)
	}

	mongocli := root.Builder(&profile, []string{})

	if err := cobra2snooty.GenSnootyTree(mongocli, "./docs/command"); err != nil {
		log.Fatal(err)
	}
}

This will generate a whole series of files, one for each command in the tree, in the directory specified (in this case "./docs/command")

License

cobra2snooty is released under the Apache 2.0 license. See LICENSE