Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added -all parameter to generate docs for unexported methods. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion godocdown/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ http://github.com/robertkrimen/godocdown/blob/master/example.markdown

Usage

-all=false 
Generate documentation for all package level declarations, 
not just exported declarations. 

-output="" 
Write output to a file instead of stdout 
Write to stdout with - 
Expand Down Expand Up @@ -127,6 +131,7 @@ var (
flag_heading = flag.String("heading", "TitleCase1Word", "Heading detection method: 1Word, TitleCase, Title, TitleCase1Word, \"\"")
flag_template = flag.String("template", "", "The template file to use")
flag_noTemplate = flag.Bool("no-template", false, "Disable template processing")
flag_all = flag.Bool("all", false, "Document all code, not just exported code")
flag_output = ""
_ = func() byte {
flag.StringVar(&flag_output, "output", flag_output, "Write output to a file instead of stdout. Write to stdout with -")
Expand Down Expand Up @@ -233,6 +238,14 @@ func indentCode(target string) string {
return fmt.Sprintf("```go\n%s\n```", target)
}

func docMode() doc.Mode {
if *flag_all {
return doc.AllDecls
} else {
return doc.Mode(0)
}
}

func headifySynopsis(target string) string {
detect := RenderStyle.SynopsisHeading
if detect == nil {
Expand Down Expand Up @@ -383,7 +396,7 @@ func loadDocument(target string) (*_document, error) {
// Choose the best package for documentation. Either
// documentation, main, or whatever the package is.
for _, parsePkg := range pkgSet {
tmpPkg := doc.New(parsePkg, ".", 0)
tmpPkg := doc.New(parsePkg, ".", docMode())
switch tmpPkg.Name {
case "main":
if isCommand || name != "" {
Expand Down