Skip to content

Package css2table as a library with documented API and release workflow - #6

Open
mgroeber9110 wants to merge 6 commits into
mainfrom
claude/project-thread-x38ula
Open

mgroeber9110 wants to merge 6 commits into
mainfrom
claude/project-thread-x38ula

Conversation

@mgroeber9110

@mgroeber9110 mgroeber9110 commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Requested by Marcus · project thread

Summary

Turns the prototype into an installable, reusable Python package and adds GitHub Actions for CI and releases. Conversion output is unchanged (checked on examples/ and tests/pages/ against main).

Public API (import css2table)

  • convert(html, viewport_width=800, base_url=None, load_stylesheet=None): unchanged signature, now with type hints and a full docstring.
  • convert_file(path, ...): converts a saved page and loads its stylesheets from disk.
  • file_loader(base_dir): moved from __main__ to css2table/api.py (still importable from __main__).
  • StylesheetLoader, DEFAULT_VIEWPORT_WIDTH, __version__; py.typed marker.
  • CLI: new --version.

Packaging

  • pyproject.toml: version read from css2table.__version__, SPDX license, classifiers, project URLs, minimum dependency versions. Requires Python 3.10+ (3.9 is end of life and no longer available on GitHub's Ubuntu runners).
  • MANIFEST.in so the sdist contains the tests, test pages and tools and can run its own test suite.
  • LICENSE (MIT, confirmed by Marcus; copyright "The css2table authors"), CHANGELOG.md.

Docs

  • docs/api.md: API reference with examples (including a network stylesheet loader for a later proxy).
  • docs/releasing.md: release steps and one-time PyPI setup.
  • README: installation, library usage, links that also work on PyPI.

GitHub Actions

  • ci.yml: tests on Python 3.10 to 3.14; builds sdist and wheel, runs twine check --strict, installs the wheel into a clean venv and smoke-tests the CLI.
  • release.yml on v* tags: checks tag == __version__, runs tests, builds, creates a GitHub Release with the files and generated notes (pre-release for a/b/rc/dev tags).
  • PyPI upload via trusted publishing is off until enabled: it only runs when the repository variable PUBLISH_TO_PYPI is true. Setup steps are in docs/releasing.md (pending publisher on PyPI, environment pypi, the variable). The name css2table is currently free on PyPI.

Also

To do for Marcus

  1. Optional: set up PyPI trusted publishing as described in docs/releasing.md.
  2. After merging: git tag v0.1.0 && git push origin v0.1.0.

Noticed, not changed

values.VIEWPORT_WIDTH (used for vw/vi units) is a constant 800 and is never set from viewport_width, so vw ignores --width. Left for a separate fix to keep this PR behavior-neutral.

Test plan

  • python -m pytest: 91 passed, 1 skipped (real test pages not present).
  • Wheel installed into a fresh venv on Python 3.14; the sdist's test suite passes.
  • python -m build + twine check --strict pass; actionlint clean.

https://claude.ai/code/session_01K1zAu4mG3qrUq7adbFp4Bm


Generated by Claude Code

- Public API: convert, convert_file, encode, file_loader,
  StylesheetLoader, DEFAULT_VIEWPORT_WIDTH and __version__, with type hints,
  docstrings and a py.typed marker. The CLI now uses encode/file_loader.
- pyproject.toml: dynamic version, MIT license, classifiers, project URLs,
  minimum dependency versions; MANIFEST.in so the sdist can run its tests.
- docs/api.md (API reference), docs/releasing.md, CHANGELOG.md, LICENSE.
- GitHub Actions: CI runs the tests on Python 3.9-3.14 and builds and
  smoke-tests the wheel; a v* tag builds the release, creates a GitHub
  Release and optionally publishes to PyPI via trusted publishing.
- tests/test_api.py covers the new functions and the command line.

Conversion output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1zAu4mG3qrUq7adbFp4Bm
examples/out/ was still produced by the first prototype, before the output
size reductions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1zAu4mG3qrUq7adbFp4Bm
@mgroeber9110 mgroeber9110 self-assigned this Nov 29, 2026
claude and others added 4 commits November 29, 2026 21:33
Python 3.9 reached end of life in October 2025 and setup-python cannot
install it on the current ubuntu-latest image. Also update checkout and
setup-python to their Node 24 releases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1zAu4mG3qrUq7adbFp4Bm
Encoding the output is not part of the table conversion. The command line
keeps its --encoding option and does the charset replacement itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1zAu4mG3qrUq7adbFp4Bm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1zAu4mG3qrUq7adbFp4Bm
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.

2 participants