THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

Update documentation generator

pull/1/head
Brett Bender 4 months ago
parent
commit
aa5ac5c8f2
Signed by: apoll <brett@brettb.xyz> GPG Key ID: 1D8324D8F593696E
3 changed files with 45 additions and 6 deletions
  1. +1
    -0
      .gitignore
  2. +43
    -6
      cmd/docs.go
  3. +1
    -0
      cmd/root.go

+ 1
- 0
.gitignore View File

@ -1,4 +1,5 @@
.idea/
docs/
qsr.exe
qsr

+ 43
- 6
cmd/docs.go View File

@ -28,9 +28,13 @@ var dir string
// docsCmd represents the docs command
var docsCmd = &cobra.Command{
Use: "docs [directory]",
Use: "docs {md|man|rest}",
Short: "Documentation Generator",
Long: `A super quick command to generate documentation for Quick Script Runner`,
Long: `A super quick command to generate documentation for Quick Script Runner
You can provide a single argument: "md", "man", or "rst" to specify what format you'd like the docs in.
Each of those being MarkDown, Man Pages, or ReStructured Text respectively.`,
ValidArgs: []string{"md", "man", "rst"},
Args: cobra.OnlyValidArgs,
Run: func(cmd *cobra.Command, args []string) {
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.Mkdir(dir, os.ModeDir)
@ -38,9 +42,42 @@ var docsCmd = &cobra.Command{
log.Fatal(err)
}
}
err := doc.GenMarkdownTree(rootCmd, dir)
if err != nil {
log.Fatal(err)
if len(args) > 0 {
switch args[0] {
case "md":
{
err := doc.GenMarkdownTree(rootCmd, dir)
if err != nil {
log.Fatal(err)
}
break
}
case "man":
{
header := &doc.GenManHeader{
Title: "QSR",
Section: "1",
}
err := doc.GenManTree(rootCmd, header, dir)
if err != nil {
log.Fatal(err)
}
break
}
case "rst":
{
err := doc.GenReSTTree(rootCmd, dir)
if err != nil {
log.Fatal(err)
}
break
}
}
} else {
err := doc.GenMarkdownTree(rootCmd, dir)
if err != nil {
log.Fatal(err)
}
}
},
}
@ -48,5 +85,5 @@ var docsCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(docsCmd)
docsCmd.Flags().StringVarP(&dir, "directory", "d", "./", "Help message for toggle")
docsCmd.Flags().StringVarP(&dir, "directory", "d", "./", "Directory to create documentation in.")
}

+ 1
- 0
cmd/root.go View File

@ -29,6 +29,7 @@ var rootCmd = &cobra.Command{
Short: "A quick and easy way to run gists",
Long: `Quick Script Runner is a command line utility that allows you to run gists
with a single command.`,
Version: "0.1.0",
}
// Execute adds all child commands to the root command and sets flags appropriately.

Loading…
Cancel
Save