feat(docs): expose heading styles via docs format#615
Open
chrischall wants to merge 2 commits into
Open
Conversation
Closes openclaw#605. `docs format` covered text attributes and a couple of paragraph attributes (alignment, line spacing) but had no way to set a paragraph's named style — the Docs API field that drives outline view / navigation pane and is the difference between a flat doc and a structured one. The markdown writer can produce HEADING_N on fresh content via leading `#`s, but offered no way to restyle existing paragraphs. Adds two new DocsFormatFlags: - `--heading-level N` (1..6): shortcut for HEADING_N. - `--named-style NAME`: full enum — NORMAL_TEXT, TITLE, SUBTITLE, HEADING_1..HEADING_6 (case-insensitive). The two are mutually exclusive. Either sets paragraphStyle.namedStyleType on the existing UpdateParagraphStyle request, so the new flags compose cleanly with --alignment and --line-spacing without an extra round-trip. Helper docsFormatNamedStyle does the validation + enum resolution. Tests cover all six heading levels, the full enum, case-insensitivity, mutual-exclusion, range-rejection, unknown-enum rejection, composition with alignment, and the any() detection used by the no-flags guard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #605.
Summary
`docs format` covered text attributes and a couple of paragraph attributes (alignment, line spacing) but had no way to set a paragraph's named style — the Docs API field that drives the outline view / navigation pane and is the difference between a flat doc and a structured one. The markdown writer can produce HEADING_N on fresh content via leading `#`s, but offered no way to restyle existing paragraphs.
New flags
Mutually exclusive. Either path sets `paragraphStyle.namedStyleType` on the existing `UpdateParagraphStyle` request, so they compose cleanly with `--alignment` and `--line-spacing` without an extra round-trip.
```
gog docs format --match=Title --heading-level=1
gog docs format --match=Title --named-style=HEADING_1
gog docs format --match="Day-by-Day" --heading-level=2 --alignment=center
```
Tests
`go test ./internal/cmd/ -count=1` → ok 23.6s.