diff --git a/cmd/disco/cmd.go b/cmd/disco/cmd.go index 4d9c2191..19d655a4 100644 --- a/cmd/disco/cmd.go +++ b/cmd/disco/cmd.go @@ -3,6 +3,7 @@ package disco import ( "context" + "github.com/project-chip/alchemy/asciidoc/render" "github.com/project-chip/alchemy/disco" "github.com/project-chip/alchemy/internal/files" "github.com/project-chip/alchemy/internal/pipeline" @@ -24,11 +25,10 @@ func discoBall(cmd *cobra.Command, args []string) (err error) { pipelineOptions := pipeline.Flags(cmd) fileOptions := files.Flags(cmd) - discoOptions := getDiscoOptions(cmd) writer := files.NewWriter[string]("Writing disco-balled docs", fileOptions) - err = disco.Pipeline(cxt, specRoot, args, pipelineOptions, discoOptions, writer) + err = disco.Pipeline(cxt, specRoot, args, pipelineOptions, getDiscoOptions(cmd), getRenderOptions(cmd), writer) return } @@ -50,6 +50,7 @@ func init() { Command.Flags().Bool("addSpaceAfterPunctuation", true, "add missing space after punctuation") Command.Flags().Bool("removeExtraSpaces", true, "remove extraneous spaces") Command.Flags().Bool("disambiguateConformanceChoice", false, "ensure conformance choices are only used once per document") + Command.Flags().Int("wrap", 0, "the maximum length of a line") } type discoOption func(bool) disco.Option @@ -82,3 +83,12 @@ func getDiscoOptions(cmd *cobra.Command) []disco.Option { } return discoOptions } + +func getRenderOptions(cmd *cobra.Command) []render.Option { + var renderOptions []render.Option + wrap, err := cmd.Flags().GetInt("wrap") + if err == nil { + renderOptions = append(renderOptions, render.Wrap(wrap)) + } + return renderOptions +} diff --git a/cmd/github/action.go b/cmd/github/action.go index 294d9fc6..8973c929 100644 --- a/cmd/github/action.go +++ b/cmd/github/action.go @@ -61,7 +61,7 @@ func Action(cmd *cobra.Command, args []string) error { var out bytes.Buffer writer := files.NewPatcher[string]("Generating patch file...", &out) - err = disco.Pipeline(cxt, ".", changedDocs, pipelineOptions, nil, writer) + err = disco.Pipeline(cxt, ".", changedDocs, pipelineOptions, nil, nil, writer) if err != nil { return fmt.Errorf("failed disco-balling: %v", err) } diff --git a/disco/pipeline.go b/disco/pipeline.go index adcc3659..da07b82c 100644 --- a/disco/pipeline.go +++ b/disco/pipeline.go @@ -10,7 +10,7 @@ import ( "github.com/project-chip/alchemy/matter/spec" ) -func Pipeline(cxt context.Context, specRoot string, docPaths []string, pipelineOptions pipeline.Options, discoOptions []Option, writer files.Writer[string]) (err error) { +func Pipeline(cxt context.Context, specRoot string, docPaths []string, pipelineOptions pipeline.Options, discoOptions []Option, renderOptions []render.Option, writer files.Writer[string]) (err error) { var docs pipeline.Map[string, *pipeline.Data[*spec.Doc]] if specRoot != "" { @@ -77,7 +77,7 @@ func Pipeline(cxt context.Context, specRoot string, docPaths []string, pipelineO return err } - renderer := render.NewRenderer() + renderer := render.NewRenderer(renderOptions...) var renders pipeline.Map[string, *pipeline.Data[string]] renders, err = pipeline.Process[render.InputDocument, string](cxt, pipelineOptions, renderer, normalizedDocs) if err != nil { diff --git a/test.adoc b/test.adoc deleted file mode 100644 index 25dfd4fd..00000000 --- a/test.adoc +++ /dev/null @@ -1,10 +0,0 @@ -[NOTE] -.CoolingAndHeating -==== -A thermostat indicating it supports CoolingAndHeating (or CoolingAndHeatingWithReheat) SHOULD be able to -request heating or cooling on demand and will usually support the Auto SystemMode. - -Systems which support cooling *or* heating, requiring external intervention to change modes or -where the whole building must be in the same mode, SHOULD report CoolingOnly or -HeatingOnly based on the current capability. -==== \ No newline at end of file