Skip to content

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

Merged
cpatrickalves merged 5 commits into
cpatrickalves:mainfrom
Liewzheng:fix/doc-write-ux
Nov 6, 2026
Merged

cpatrickalves merged 5 commits into
cpatrickalves:mainfrom
Liewzheng:fix/doc-write-ux

Conversation

@Liewzheng

Copy link
Copy Markdown
Contributor

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

Liewzheng and others added 5 commits September 8, 2026 13:49
…, 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.
Resolve conflicts in documents.py (keep the branch's body_to_html and
archive-before-delete) and test_documents.py (keep main's create tests,
add the branch's, drop the branch's duplicate empty-content test).
…alves#21)

doc delete:
- Accept any non-null archived_at, not only today's date, so a page the
  server archived with another date or a timestamp still gets deleted.
- Translate HTTP and JSON failures of the archive PATCH and the DELETE
  into the CLI's exit codes instead of a traceback.
- Say so when the DELETE fails after the archive: the page stays archived.
- --help now says the delete is permanent; cite ADR-0007.

Converter (utils/body_html.py):
- Split fenced blocks before paragraphs, so a fence next to text is never
  wrapped in a paragraph; accept info strings such as c++ and CRLF.
- Split code spans before linkifying, so URLs inside them stay text.
- Keep a closing paren that balances one inside a URL.
- Empty content gives an empty paragraph, as when --content is omitted.

content_text keeps line and paragraph breaks and unescapes entities.
…lves#21)

The PATCH archived_at path is not proven on any server. On a self-hosted
Community Edition server the page URL allows only GET: PATCH and DELETE
answer 405 and POST .../archive/ answers 404. doc delete goes back to a
plain DELETE and keeps the HTTP error translation, so a 405 exits with
code 4 instead of a traceback. Archiving moves to a separate issue.
@cpatrickalves

Copy link
Copy Markdown
Owner

Thanks for this PR. I pushed four commits to your branch, so please pull before you push again:

  • fc69e7c merges main into the branch, so the PR no longer conflicts. It is a merge, not a rebase, and the push was a fast-forward.
  • b2414cc fixes the converter. It splits code spans before linkifying, so a URL inside backticks stays text. It splits fences before paragraphs, so a fence next to text is no longer wrapped in a paragraph, and it accepts info strings such as c++ and CRLF line endings. It keeps a closing paren that balances one inside a URL, and empty content now gives an empty paragraph. content_text keeps line breaks and unescapes entities. doc delete turns HTTP errors into exit codes instead of a traceback.
  • f96f8d5 documents the changes in the CHANGELOG, README, docs/guides/plane-api.md and the skill reference.
  • 681646d drops archive-before-delete. On a self-hosted Community Edition server the page URL allows only GET: PATCH and DELETE answer 405, and POST .../archive/ answers 404. The PATCH archived_at call looks like it comes from feat(api): add Pages endpoints to the public v1 API makeplane/plane#9757, which is not merged, so no server confirms it yet. doc delete is back to a plain DELETE, and a 405 now exits with code 4 and a clear message. I opened fix: doc delete has no verified way to archive a page before deleting it #36 to work out the archive call.

Which Plane version or build did you test the delete flow on? If you can answer on #36, it would settle what the CLI should call.

The PR description no longer matches the code: it mentions archive-before-delete, 17 new cases, and comment commands sharing the converter. I will use this title when merging: fix(documents): convert doc content to HTML and report delete errors (#21).

@cpatrickalves
cpatrickalves merged commit ed669ea into cpatrickalves:main Nov 6, 2026
3 checks passed
cpatrickalves pushed a commit that referenced this pull request Nov 11, 2026
The skill had a two-part version that did not move with the document
changes in #21 and #22. AGENTS.md now asks for a bump with every change
under skills/.
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

3 participants