Skip to content

feat(docs): support --replace --markdown --tab whole-tab re-render (#595)#625

Merged
steipete merged 2 commits into
openclaw:mainfrom
sebsnyk:feat/595-tab-rerender
May 22, 2026
Merged

feat(docs): support --replace --markdown --tab whole-tab re-render (#595)#625
steipete merged 2 commits into
openclaw:mainfrom
sebsnyk:feat/595-tab-rerender

Conversation

@sebsnyk
Copy link
Copy Markdown
Contributor

@sebsnyk sebsnyk commented May 21, 2026

Summary

Closes #595.

gog docs write <docId> --replace --markdown --tab=<tab> previously errored with --markdown with --replace does not support --tab (Drive's markdown converter operates on entire documents). Drive's converter is whole-document-only, but the Docs API itself happily targets tab ranges, so the whole-tab re-render is a small workaround at the gogcli layer:

  1. Look up the tab's end index via documents.get with includeTabsContent=true.
  2. If the tab has any body content (endIndex > 2), issue a DeleteContentRange covering [1, endIndex-1] with the tab ID.
  3. Render the markdown locally and submit via the existing insertDocsMarkdownAt helper at index 1 with the tab ID — the same path that already powers --append --markdown --tab (including bullets, tables, code, images, and inline formatting).

No new dependencies; reuses ParseMarkdown / MarkdownToDocsRequests / TableInserter / insertImagesIntoDocs, all of which already accept a tab ID. Empty tabs skip the delete step; unknown --tab values still produce the standard tab-not-found error before any batchUpdate.

gog docs write <docId> --replace --markdown --tab "Gold list" --file gold.md
# Replaces only the Gold list tab content with the markdown-rendered version.
# Other tabs are untouched.

Test plan

  • go build ./... clean.
  • go test ./... clean (43.8s on internal/cmd).
  • New unit tests in internal/cmd/docs_write_markdown_tab_test.go:
    • TestDocsWrite_MarkdownReplaceWithTab — asserts a non-empty tab produces DeleteContentRange{Range:{Start:1,End:19,TabId:t.second}} followed by InsertText{Location:{Index:1,TabId:t.second}} + formatting requests all carrying the tab ID; verifies Drive is never called.
    • TestDocsWrite_MarkdownReplaceWithTab_EmptyTab — asserts the delete step is skipped when the tab body is empty (Docs API rejects end <= start ranges).
    • TestDocsWrite_MarkdownReplaceWithTab_TabNotFound — asserts an unknown tab title produces the standard tab not found: "Missing" error before any batchUpdate is issued.
  • CHANGELOG.md updated under 0.17.1 Added.
  • docs/docs-editing.md updated with the new tab-rerender example.

Notes for reviewer

  • Help text for --markdown was not changed; its existing wording (requires --replace or --append) is still accurate.
  • Pageless mode continues to apply post-write when requested; it's a document-level property, not per-tab.
  • The error string --markdown with --replace does not support --tab (...) was removed since the case it described is now supported.

🤖 Generated with Claude Code

sebsnyk and others added 2 commits May 22, 2026 01:07
…penclaw#595)

Drive's markdown converter is whole-document-only, so `docs write
--replace --markdown --tab=<tab>` previously errored. Implement the
workaround at the gogcli layer by wiping the targeted tab's body via
`DeleteContentRange` and re-rendering the markdown locally through the
same Docs `batchUpdate` path used by `--append --markdown`. Other tabs
are left untouched.

Empty-tab handling skips the delete step (Docs rejects ranges where
end <= start), and a tab-not-found error is surfaced before any
batchUpdate is issued.
@steipete steipete force-pushed the feat/595-tab-rerender branch from b48aa90 to fcdc05f Compare May 22, 2026 00:16
@steipete steipete merged commit 58b866e into openclaw:main May 22, 2026
7 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.

docs write --replace --markdown should support --tab (whole-tab re-render)

2 participants