feat: Add support for AsciiDoc renderer (#241)

* Implement AsciiDoc renderer

* Add missing tests to maintain expected code coverage

* Keep alphabetical order

* Refactor indent function (accept char argument and make homogeneous for both MD and Adoc renderers)

* Force asciidoc syntax in every table column

* Remove extra NL before code blocks and add autowidth tables

* Move char argument after settings in indent function

* Implement new factory function for asciidoc renderer

* Update asciidoc table docs

* Return empty indentation if no indent scpecified

* Prevent adding a trailing whitespace in table rows

* Change asciidoc alias to match file extension

* Update docs
This commit is contained in:
Rubén del Campo
2020-04-12 21:22:53 +02:00
committed by GitHub
parent c196c7cc49
commit 37375db283
76 changed files with 12643 additions and 49 deletions

43
cmd/asciidoc.go Normal file
View File

@@ -0,0 +1,43 @@
package cmd
import (
"github.com/spf13/cobra"
)
var asciidocCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Use: "asciidoc [PATH]",
Aliases: []string{"adoc"},
Short: "Generate AsciiDoc of inputs and outputs",
Annotations: formatAnnotations("asciidoc"),
RunE: formatRunE,
}
var asciidocTableCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Use: "table [PATH]",
Aliases: []string{"tbl"},
Short: "Generate AsciiDoc tables of inputs and outputs",
Annotations: formatAnnotations("asciidoc table"),
RunE: formatRunE,
}
var asciidocDocumentCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Use: "document [PATH]",
Aliases: []string{"doc"},
Short: "Generate AsciiDoc document of inputs and outputs",
Annotations: formatAnnotations("asciidoc document"),
RunE: formatRunE,
}
func init() {
asciidocCmd.PersistentFlags().BoolVar(new(bool), "no-required", false, "do not show \"Required\" column or section")
asciidocCmd.PersistentFlags().BoolVar(new(bool), "no-sensitive", false, "do not show \"Sensitive\" column or section")
asciidocCmd.PersistentFlags().IntVar(&settings.IndentLevel, "indent", 2, "indention level of AsciiDoc sections [1, 2, 3, 4, 5]")
asciidocCmd.AddCommand(asciidocTableCmd)
asciidocCmd.AddCommand(asciidocDocumentCmd)
rootCmd.AddCommand(asciidocCmd)
}

View File

@@ -35,7 +35,7 @@ func init() {
markdownCmd.PersistentFlags().BoolVar(new(bool), "no-required", false, "do not show \"Required\" column or section")
markdownCmd.PersistentFlags().BoolVar(new(bool), "no-sensitive", false, "do not show \"Sensitive\" column or section")
markdownCmd.PersistentFlags().BoolVar(new(bool), "no-escape", false, "do not escape special characters")
markdownCmd.PersistentFlags().IntVar(&settings.MarkdownIndent, "indent", 2, "indention level of Markdown sections [1, 2, 3, 4, 5]")
markdownCmd.PersistentFlags().IntVar(&settings.IndentLevel, "indent", 2, "indention level of Markdown sections [1, 2, 3, 4, 5]")
markdownCmd.AddCommand(markdownTableCmd)
markdownCmd.AddCommand(markdownDocumentCmd)