Skip to content

feat: add devpub comments to read article comment threads + release v0.4.0 - #14

Merged
simplynadaf merged 2 commits into
mainfrom
feat/comments
Oct 9, 2026
Merged

simplynadaf merged 2 commits into
mainfrom
feat/comments

Conversation

@simplynadaf

@simplynadaf simplynadaf commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds devpub comments <article_id>: read the threaded comments on a Dev.to article directly in the terminal. Replies are rendered nested under their parent, with the author, date, and comment id_code. Comment HTML bodies are reduced to readable plain text.

This was prompted by a reader comment on the image-uploads article about bridging session state for comments. During scoping I split the work: reading comments is a documented, API-key/public, read-only endpoint and ships here; posting replies has no Forem V1 write endpoint and is deferred (see below).

What's included

  • api/devto.py: get_comments(article_id) (threaded tree via GET /comments?a_id=) and get_comment(id_code) (GET /comments/{id}).
  • cli/comments.py: a small HTML-to-text reducer (strip tags, unescape entities, collapse blank lines, no new dependency) and a recursive thread renderer with depth-capped indentation.
  • Command wired into the CLI group; README (Discovery table) and CHANGELOG updated.
  • Tests: 5 respx-mocked API-client tests plus 10 helper tests. Full suite 143 passed, ruff clean.

Why reply-posting is not here

The Forem V1 API exposes no comment write endpoint. Posting would require the session-cookie plus CSRF bridge already used by devpub upload, plus handling mid-session CSRF rotation. That deserves its own verification spike and PR rather than shipping an unverified write path that could 403 for every user. This PR keeps devpub's guarantee that these commands are safe and read-only.

Verification

  • pytest gives 143 passed; ruff check src/ tests/ is clean.
  • Command registration and --help confirmed via the installed console script.
  • Live smoke test against a real public article (id 4488685): correctly rendered 18 real comments across 4 threads, including nesting, indentation, multi-paragraph bodies, @username, dates, and id_code.
  • Also verified against the author's own authenticated articles, including the DevPub launch article (9 comments across 5 threads rendered correctly).
  • CI green on Python 3.10, 3.11, and 3.12.

Follow-up

Tracked in #15: the devpub reply spike (request shape and CSRF rotation behavior).

Read the threaded comments on a Dev.to article directly in the terminal.
Uses the API-key/public GET /comments endpoint, so it is fully read-only.
Replies are rendered nested under their parent with author, date, and
id_code; comment HTML bodies are reduced to plain text.

Posting replies is intentionally out of scope: the Forem V1 API has no
comment write endpoint, so that would require the session-cookie bridge
used by `devpub upload` and is tracked separately pending a verification
spike.

- api/devto.py: get_comments(a_id) and get_comment(id_code)
- cli/comments.py: HTML-to-text reducer + recursive thread renderer
- cli command wired in, README + CHANGELOG updated
- tests: 5 API-client tests + 10 helper tests (143 total pass)
Release devpub comments feature.

- devpub comments <article_id>: read threaded Dev.to comments in the
  terminal with nested replies, author, date, id_code, and --page/--limit
  pagination.

Validated against the live Dev.to API: auth, comment threading, nesting,
pagination, empty-article and invalid-id edge cases. 143 tests pass, ruff clean.
@simplynadaf simplynadaf changed the title feat: add devpub comments to read article comment threads feat: add devpub comments to read article comment threads + release v0.4.0 Oct 9, 2026
@simplynadaf

Copy link
Copy Markdown
Owner Author

🚀 Prepared for v0.4.0 release

Added a version-bump commit (4997d9b) on top of the feature:

  • Version: 0.3.0 → 0.4.0 in pyproject.toml and src/devpub/__init__.py
  • CHANGELOG: moved the comments entry from [Unreleased] into [0.4.0] - 2026-10-09, noting --page / --limit support

Live validation (account @sarvar_04, fresh API key)

  • ✅ 143 unit tests pass · ruff check clean · CLI reports devpub, version 0.4.0
  • ✅ devpub comments on real series articles — correct thread grouping, 3-level reply nesting, HTML→text, --limit paging
  • ✅ Edge cases — empty article → "No comments found"; invalid ID → readable "Not found" (no stack trace)
  • ✅ Publish round-trip — drafted the v0.4.0 series article, devpub validate passes, devpub push created a draft and wrote devto_id back to frontmatter

Once all three CI matrix jobs are green, this is ready to merge. The GitHub Release/tag (which triggers the PyPI publish) will be created as a separate, explicit step after merge.

@simplynadaf
simplynadaf merged commit 6fde81a into main Oct 9, 2026
3 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.

1 participant