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

Minor qol tweaks #120

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 14 additions & 9 deletions documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ in the file above.

type documentationCommand struct {
CommandBase
super *SuperCommand
out string
noIndex bool
split bool
url string
idsPath string
super *SuperCommand
out string
noIndex bool
split bool
escapeMarkdown bool
url string
idsPath string
// ids is contains a numeric id of every command
// add-cloud: 1112
// remove-user: 3333
Expand Down Expand Up @@ -87,6 +88,7 @@ func (c *documentationCommand) SetFlags(f *gnuflag.FlagSet) {
f.StringVar(&c.out, "out", "", "Documentation output folder if not set the result is displayed using the standard output")
f.BoolVar(&c.noIndex, "no-index", false, "Do not generate the commands index")
f.BoolVar(&c.split, "split", false, "Generate a separate Markdown file for each command")
f.BoolVar(&c.split, "escape-markdown", true, "Escape special markdown characters e.g. < > |")
f.StringVar(&c.url, "url", "", "Documentation host URL")
f.StringVar(&c.idsPath, "discourse-ids", "", "File containing a mapping of commands and their discourse ids")
}
Expand Down Expand Up @@ -327,7 +329,7 @@ func (c *documentationCommand) writeIndex(w io.Writer) error {
}
// TODO: handle subcommands ??
}
_, err = fmt.Fprintf(w, "---\n\n")
_, err = fmt.Fprintf(w, "\n---\n\n")
return err
}

Expand Down Expand Up @@ -422,7 +424,10 @@ func (c *documentationCommand) formatCommand(ref commandReference, title bool, c
}

// Details
doc := EscapeMarkdown(info.Doc)
doc := info.Doc
if c.escapeMarkdown {
doc = EscapeMarkdown(doc)
}
if strings.TrimSpace(doc) != "" {
formatted += "## Details\n" + doc + "\n\n"
}
Expand Down Expand Up @@ -623,7 +628,7 @@ func (c *documentationCommand) formatSubcommands(subcommands map[string]string,
output += "## Subcommands\n"
for _, name := range sorted {
output += fmt.Sprintf("- [%s](%s)\n", name,
c.linkForCommand(strings.Join(append(commandSeq[1:], name), "_")))
c.linkForCommand(strings.Join(append(commandSeq[1:], name), "-")))
}
output += "\n"
}
Expand Down