Skip to content

Commit

Permalink
test: add extra tests to cmd and format (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
princjef authored Dec 24, 2021
1 parent 070df04 commit 08e0e91
Show file tree
Hide file tree
Showing 31 changed files with 1,063 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/coverage.txt
/gomarkdoc
/bin/
README-test.md
2 changes: 1 addition & 1 deletion cmd/gomarkdoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ See https://github.com/princjef/gomarkdoc for full documentation of this tool\.
- [type PackageSpec](<#type-packagespec>)


## type [PackageSpec](<https://github.com/princjef/gomarkdoc/blob/master/cmd/gomarkdoc/command.go#L31-L45>)
## type [PackageSpec](<https://github.com/princjef/gomarkdoc/blob/master/cmd/gomarkdoc/command.go#L30-L44>)

PackageSpec defines the data available to the \-\-output option's template\. Information is recomputed for each package generated\.

Expand Down
15 changes: 7 additions & 8 deletions cmd/gomarkdoc/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"html/template"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"runtime/debug"
Expand Down Expand Up @@ -70,17 +69,19 @@ func buildCommand() *cobra.Command {
var opts commandOptions
var configFile string

cobra.OnInitialize(func() { buildConfig(configFile) })
// cobra.OnInitialize(func() { buildConfig(configFile) })

var command = &cobra.Command{
Use: "gomarkdoc [package ...]",
Short: "generate markdown documentation for golang code",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
if opts.version {
printVersion()
return
return nil
}

buildConfig(configFile)

// Load configuration from viper
opts.includeUnexported = viper.GetBool("includeUnexported")
opts.output = viper.GetString("output")
Expand All @@ -98,17 +99,15 @@ func buildCommand() *cobra.Command {
opts.repository.PathFromRoot = viper.GetString("repository.path")

if opts.check && opts.output == "" {
log.Fatal("check mode cannot be run without an output set")
return errors.New("gomarkdoc: check mode cannot be run without an output set")
}

if len(args) == 0 {
// Default to current directory
args = []string{"."}
}

if err := runCommand(args, opts); err != nil {
log.Fatal(err)
}
return runCommand(args, opts)
},
}

Expand Down
Loading

0 comments on commit 08e0e91

Please sign in to comment.