diff --git a/asciidoc/column.go b/asciidoc/column.go index 7414b9e2..ee5d7974 100644 --- a/asciidoc/column.go +++ b/asciidoc/column.go @@ -218,6 +218,13 @@ func parseColumnAttribute(a *NamedAttribute) (*TableColumnsAttribute, error) { } col.Width = One(TableColumnWidth(width)) } + case columnMatchPercentage: + percentage, err := strconv.Atoi(s) + if err != nil { + return nil, fmt.Errorf("invalid width %s: %w", s, err) + + } + col.Percentage = One(int(percentage)) case columnMatchStyle: switch s { case "a": diff --git a/asciidoc/render/element.go b/asciidoc/render/element.go index 4d851d9b..10245c86 100644 --- a/asciidoc/render/element.go +++ b/asciidoc/render/element.go @@ -140,6 +140,8 @@ func Elements(cxt *Context, prefix string, elementList ...asciidoc.Element) (err cxt.WriteString("+") case *asciidoc.Counter: renderCounter(cxt, el) + case *asciidoc.ThematicBreak: + cxt.WriteString("'''\n") case nil: default: err = fmt.Errorf("unknown render element type: %T", el) diff --git a/cmd/format/cmd.go b/cmd/format/cmd.go index db303c2d..051df8d8 100644 --- a/cmd/format/cmd.go +++ b/cmd/format/cmd.go @@ -37,7 +37,7 @@ func format(cmd *cobra.Command, args []string) (err error) { } ids := pipeline.NewConcurrentMapPresized[string, *pipeline.Data[render.InputDocument]](docs.Size()) - err = pipeline.Cast[*spec.Doc, render.InputDocument](docs, ids) + err = pipeline.Cast(docs, ids) if err != nil { return err } diff --git a/cmd/testplan/cmd.go b/cmd/testplan/cmd.go index 278cf56b..947ed7e0 100644 --- a/cmd/testplan/cmd.go +++ b/cmd/testplan/cmd.go @@ -4,6 +4,7 @@ import ( "context" "log/slog" + "github.com/hasty/alchemy/asciidoc/render" "github.com/hasty/alchemy/cmd/common" "github.com/hasty/alchemy/internal/files" "github.com/hasty/alchemy/internal/parse" @@ -24,6 +25,7 @@ var Command = &cobra.Command{ func init() { Command.Flags().String("specRoot", "connectedhomeip-spec", "the src root of your clone of CHIP-Specifications/connectedhomeip-spec") Command.Flags().String("sdkRoot", "connectedhomeip", "the root of your clone of project-chip/connectedhomeip") + Command.Flags().String("testRoot", "chip-test-plans", "the root of your clone of CHIP-Specifications/chip-test-plans") Command.Flags().Bool("overwrite", false, "overwrite existing test plans") } @@ -84,21 +86,34 @@ func tp(cmd *cobra.Command, args []string) (err error) { } } - var clusters pipeline.Map[string, *pipeline.Data[*matter.Cluster]] - clusters, err = pipeline.Process[*spec.Doc, *matter.Cluster](cxt, pipelineOptions, &common.EntityFilter[*spec.Doc, *matter.Cluster]{}, specDocs) + generator := testplan.NewGenerator(testRoot, overwrite) + var testplans pipeline.Map[string, *pipeline.Data[string]] + testplans, err = pipeline.Process[*spec.Doc, string](cxt, pipelineOptions, generator, specDocs) if err != nil { return err } - generator := testplan.NewGenerator(testRoot, overwrite) - var testplans pipeline.Map[string, *pipeline.Data[string]] - testplans, err = pipeline.Process[*matter.Cluster, string](cxt, pipelineOptions, generator, clusters) + docReader := spec.NewStringReader("Reading test plans") + testplanDocs, err := pipeline.Process[string, *spec.Doc](cxt, pipelineOptions, docReader, testplans) + if err != nil { + return err + } + + ids := pipeline.NewConcurrentMapPresized[string, *pipeline.Data[render.InputDocument]](testplanDocs.Size()) + err = pipeline.Cast(testplanDocs, ids) + if err != nil { + return err + } + + renderer := render.NewRenderer() + var renders pipeline.Map[string, *pipeline.Data[string]] + renders, err = pipeline.Process[render.InputDocument, string](cxt, pipelineOptions, renderer, ids) if err != nil { return err } writer := files.NewWriter[string]("Writing test plans", fileOptions) - _, err = pipeline.Process[string, struct{}](cxt, pipelineOptions, writer, testplans) + _, err = pipeline.Process[string, struct{}](cxt, pipelineOptions, writer, renders) if err != nil { return err } diff --git a/matter/spec/read.go b/matter/spec/read.go index 98402e8e..98ba70a2 100644 --- a/matter/spec/read.go +++ b/matter/spec/read.go @@ -63,3 +63,29 @@ func (r Reader) Process(cxt context.Context, input *pipeline.Data[struct{}], ind outputs = append(outputs, &pipeline.Data[*Doc]{Path: input.Path, Content: doc}) return } + +type StringReader struct { + name string +} + +func NewStringReader(name string) StringReader { + return StringReader{name: name} +} + +func (r StringReader) Name() string { + return r.name +} + +func (r StringReader) Type() pipeline.ProcessorType { + return pipeline.ProcessorTypeIndividual +} + +func (r StringReader) Process(cxt context.Context, input *pipeline.Data[string], index int32, total int32) (outputs []*pipeline.Data[*Doc], extras []*pipeline.Data[string], err error) { + var doc *Doc + doc, err = Read(input.Content, input.Path) + if err != nil { + return + } + outputs = append(outputs, &pipeline.Data[*Doc]{Path: input.Path, Content: doc}) + return +}