Skip to content

fix(core): escape pipes in generated argument tables - #6359

Merged
elwinar merged 5 commits into
scaleway:mainfrom
WynandVStaden:fix/docgen-escape-table-pipes
Oct 15, 2026
Merged

elwinar merged 5 commits into
scaleway:mainfrom
WynandVStaden:fix/docgen-escape-table-pipes

Conversation

@WynandVStaden

@WynandVStaden WynandVStaden commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #6354

What is wrong

internal/docgen/main.md.tmpl writes each argument's description straight into a Markdown table cell:

| {{ arg_spec_name $arg }} | {{ $arg.Short }} | {{ arg_spec_flag $arg }}  |

When the description contains a |, the cell ends there and the rest of the row spills into extra columns. That is what breaks the ip row of scw instance server create, whose description ends with (new | ipv4 | ipv6 | both | dynamic | none | <id> | <address>).

The change

  • internal/docgen/docgen.go: a small EscapeTableCell helper that replaces | with \|, registered as the escape_table_cell template function.
  • internal/docgen/main.md.tmpl: the description cell goes through it.
  • internal/docgen/docgen_test.go: one assertion on a multi-pipe description, in package docgen_test.
  • docs/commands/: regenerated. Three pages change, because the same bug had hit two more rows than the one reported:
Page Row Before After
instance.md server create → ip row split after (new (new | ipv4 | ipv6 | both | dynamic | none | <id> | <address>)
block.md volume create and volume update → perf-iops `` (`5000 15000`) ``
redis.md acl update → zone row split into 8 columns one description cell

The rest of each diff is rumdl re-padding the columns of those tables.

I only escaped the description column. The third column (arg_spec_flag) is built from defaults and enum values, and no page currently has a | there; say so if you would like it covered too.

How I checked

Run on Windows 11 with Go 1.27.1 and rumdl 0.2.78:

  • go test ./internal/docgen/ passes; go build ./... and go vet ./internal/docgen/ ./cmd/scw-doc-gen/ are clean.

  • go run ./cmd/scw-doc-gen -outdir ./docs/commands followed by rumdl fmt -s ./docs on unmodified main reproduces the committed docs except autocomplete.md, where the default shell is read from the machine. With this branch the only further differences are the three pages above. I left autocomplete.md out of the commit.

  • rumdl check on the three pages reports no issues.

  • golangci-lint run ./internal/docgen/... ./cmd/scw-doc-gen/... (v2.13.0) reports 0 issues. The first push failed CI on the testpackage rule because I had not run the linter; the later commits fix that and, following review, export the helper directly.

Not run locally: typos and the full mise run ci. docs/commands/dedibox.md also has a description with a | (Filter by IP type (server | rpnv2_subnet)), but the generator does not write that page any more, so I did not touch it.

elwinar
elwinar previously approved these changes Oct 6, 2026
Comment thread internal/docgen/export_test.go Outdated

// Exported for black-box tests of the table cell escaping.

func EscapeTableCell(s string) string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just export the function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review. I've exported the function directly and removed export_test.go

Comment thread internal/docgen/docgen_test.go Resolved
@remyleone

Copy link
Copy Markdown
Member

Thanks for your contribution @WynandVStaden could you sign your commits?

The doc generator wrote an argument's description straight into a Markdown
table cell. A description containing "|", such as the list of accepted
values for `scw instance server create ip=`, ended the cell early and pushed
the rest of the row into extra columns.

Escape "|" in the description cell and regenerate the three command pages
that had a broken row: instance, block and redis.

Closes scaleway#6354
golangci-lint's testpackage rule requires tests to live in a _test package.
Expose escapeTableCell through export_test.go, as internal/namespaces/rdb
does, and call it from package docgen_test.
The package is internal, so exporting the helper costs nothing and removes
the need for export_test.go.
@WynandVStaden
WynandVStaden force-pushed the fix/docgen-escape-table-pipes branch from c13955b to 1f7a087 Compare October 6, 2026 14:02
@WynandVStaden

Copy link
Copy Markdown
Contributor Author

Thanks for your contribution @WynandVStaden could you sign your commits?

I signed commits thanks

…le-pipes

# Conflicts:
#	docs/commands/block.md
@elwinar
elwinar enabled auto-merge October 15, 2026 08:39
@elwinar
elwinar disabled auto-merge October 15, 2026 08:39
@elwinar
elwinar added this pull request to the merge queue Oct 15, 2026
Merged via the queue into scaleway:main with commit f1dc2f2 Oct 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[doc] IP parameter for instance cmd

3 participants