Skip to content

fix(documents): doc create/update content conversion and archive-before-delete - #22

Open
Liewzheng wants to merge 1 commit into
cpatrickalves:mainfrom
Liewzheng:fix/doc-write-ux
Open

fix(documents): doc create/update content conversion and archive-before-delete#22
Liewzheng wants to merge 1 commit into
cpatrickalves:mainfrom
Liewzheng:fix/doc-write-ux

Conversation

@Liewzheng

Copy link
Copy Markdown

Description

Fixes three independent doc write-path defects (#21):

  1. doc create crash — always pass description_html when constructing CreatePage (it is a required pydantic field). With --content, the body now goes through a proper HTML conversion instead of a single <p> wrapper. (Superset of fix(documents): pass description_html when constructing CreatePage #10 — same fix for the constructor, plus the conversion below.)
  2. Content conversion — new shared utils/body_html.py (body_to_html()): blank-line paragraphs, single newlines → <br/>, bare URLs → anchors (trailing punctuation excluded), backticks → <code> (escaped), fenced blocks → <pre><code>. Same conversion logic the comment commands use.
  3. doc delete no-op — archive first by PATCHing archived_at (today, YYYY-MM-DD), verify the response actually carries archived_at (verify-write pattern; refuse to delete otherwise), then DELETE.

Also fixes doc update to treat --content "" as intentional (is not None instead of truthiness).

Test Scenarios

  • uv run pytest -q — 197 passed, including 17 new cases (converter units, create/update payloads, archive-before-delete ordering, refuse-to-delete when archiving does not stick).
  • ruff check / ruff format --check clean on touched files.

References

…, archive before delete (PLANECLI-7)

- doc create crashed constructing CreatePage: description_html is a
  required SDK field with no default, and --content bodies were wrapped
  in a single paragraph tag. CreatePage now always carries
  description_html (an empty paragraph when no content is given), and
  --content/--body text goes through the shared body_to_html converter
  (blank lines split paragraphs, single newlines become br tags, bare
  URLs become anchors, backticks become code tags, fenced blocks become
  pre-wrapped code) — the same conversion the comment commands use on
  integration-main.
- doc update reuses the same converter and guards --content with
  is not None so an explicitly empty value still reaches the API.
- doc delete now PATCHes archived_at (today, YYYY-MM-DD) and verifies
  the response actually carries it before DELETEing: the API only
  deletes archived pages and silently ignores unknown fields, so a bare
  DELETE left documents alive with no error.
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.

fix: doc create crashes, --content loses formatting, doc delete silently no-ops

1 participant