Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
- package-ecosystem: pip
directory: /
schedule:
interval: monthly
groups:
development:
dependency-type: development
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI

on:
push:
pull_request:
workflow_call:

permissions:
contents: read

jobs:
test:
name: Python ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python }}
- name: Install package and tests
run: python -m pip install . pytest pytest-cov
- name: Test the minimum runtime dependency on Python 3.10
if: matrix.python == '3.10'
run: python -m pip install 'wcwidth==0.9.0'
- name: Run tests against installed package
run: python -m pytest --cov=advancedprinter --cov-fail-under=90
- name: Run demonstration
run: python -m advancedprinter

quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.12'
- run: python -m pip install '.[dev]'
- run: python -m ruff check .
- run: python -m ruff format --check .
- run: python -m mypy src/advancedprinter

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.12'
- run: python -m pip install build twine
- name: Build source distribution and wheel
run: python -m build
- name: Check distribution metadata and README
run: python -m twine check --strict dist/*
- name: Install wheel and verify public API
shell: bash
run: |
python -m pip install dist/*.whl
python -c "from advancedprinter import Printer, format_frame; assert format_frame('ok', color_mode='never'); Printer().success('Installed wheel works')"
- name: Check source distribution can build a wheel
shell: bash
run: python -m pip wheel --no-deps dist/*.tar.gz --wheel-dir /tmp/sdist-wheel
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: distributions
path: dist/
if-no-files-found: error
47 changes: 47 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish to PyPI

on:
release:
types: [published]

permissions:
contents: read

concurrency:
group: pypi-${{ github.event.release.tag_name }}
cancel-in-progress: false

jobs:
validate:
uses: ./.github/workflows/ci.yml

check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.12'
- run: python -m pip install .
- name: Require the release tag to match the package version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: python scripts/check_release.py

publish:
needs: [validate, check-version]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/AdvancedPrinter/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: distributions
path: dist/
- name: Publish the validated distributions with Trusted Publishing
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.idea/
.vscode/
.venv/
venv/
__pycache__/
*.py[cod]
*.egg-info/
build/
dist/
.pytest_cache/
.mypy_cache/
.ruff_cache/
.coverage*
htmlcov/
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/AdvancedPrinter.iml

This file was deleted.

36 changes: 0 additions & 36 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Changelog

## 2.0.0

### Added

- Independently configurable `Printer` instances, stream handling, and message themes.
- Readable colour/style aliases, custom hex/RGB/index colours, and depth fallback.
- Destination-aware `auto` / `always` / `never` policies, `NO_COLOR`, and Windows VT detection.
- Pure `format_text()` / `format_frame()`, ANSI stripping, and visible-width helpers.
- Success/warning/error/info helpers with visible labels; errors default to stderr.
- Unicode-aware frame wrapping, titles, padding, alignment, widths, rounded borders,
optional dedenting, and ASCII fallback.
- Standard `logging` integration without mutating records; built-in module demo.
- Typed public API, regression tests, Linux/Windows/macOS CI, distribution checks,
and GitHub Release-driven PyPI Trusted Publishing.

### Fixed

- Respect `sep`, and avoid unnecessary resets for unstyled text.
- Support zero-argument input; preserve prompt whitespace and stringify prompts.
- Support empty frames, preserve indentation and trailing whitespace, and measure
terminal cells rather than ANSI bytes or code-point counts.
- Restore outer formatting after nested spans and selective resets.
- Validate unknown colours, styles, borders, and conflicting aliases.

### Changed

- Require Python 3.10+ and `wcwidth>=0.9,<1`.
- Printing uses automatic colour policy by default; redirected output is plain.
- Unknown options raise errors instead of silently falling back.
- Consolidate packaging in `pyproject.toml` and remove tracked IDE configuration.

See `docs/migration.md` for compatibility details.

## 1.2.0 — 2024-03-06

- Add styled input prompts.
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing

Use Python 3.10 or newer. Create a virtual environment, activate it for your
platform, then install the development tools:

```bash
python -m venv .venv
# Linux/macOS: source .venv/bin/activate
# Windows PowerShell: .venv\Scripts\Activate.ps1
python -m pip install -e '.[dev]'
```

Run the same checks used by CI:

```bash
python -m pytest --cov=advancedprinter --cov-fail-under=90
python -m ruff check .
python -m ruff format --check .
python -m mypy src/advancedprinter
python -m build
python -m twine check --strict dist/*
python -m advancedprinter
```

Use `python -m ruff format .` to format changes. Tests run against the installed
package; there is no implicit `src` path injection. Build in a clean checkout
or clear old build outputs before a release so stale versions are not included.

## Project layout

| Path | Purpose |
|---|---|
| `src/advancedprinter/styles.py` | Validated colour/style specifications and aliases |
| `src/advancedprinter/terminal.py` | ANSI handling, destination policy, Windows VT support |
| `src/advancedprinter/render.py` | Pure text/frame rendering and terminal cell widths |
| `src/advancedprinter/printer.py` | Configurable streams, input, messages, palette help |
| `src/advancedprinter/logging.py` | Standard logging formatter adapter |
| `src/advancedprinter/main.py` | Original class API compatibility |
| `src/advancedprinter/_codes.py` | Original ANSI constants |
| `tests/` | Behavioural, regression, packaging, and documentation tests |
| `examples/` | Runnable demonstrations |
| `scripts/check_release.py` | Release version/tag guard |
| `.github/workflows/` | CI and Trusted Publishing |

When changing output, test both terminal and redirected streams. For frames,
include Unicode display widths, ANSI spans, empty input, and whitespace. Keep
new runtime dependencies deliberate. See `docs/releasing.md` for publishing.
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include CHANGELOG.md CONTRIBUTING.md
recursive-include docs *.md
recursive-include examples *.py
recursive-include scripts *.py
recursive-include tests *.py
Loading
Loading