From e909c2a52fd1752f2fc0b0fb1222f71542c8cafa Mon Sep 17 00:00:00 2001 From: boolangery Date: Sun, 19 Jul 2026 16:22:39 +0200 Subject: [PATCH 1/3] ci: migrate from Travis CI to GitHub Actions Travis CI is no longer functional for open-source projects. - Replace .travis.yml with GitHub Actions workflows - Test via Sphinx build on Python 3.9-3.12 - Publish to PyPI on release - Update Python classifiers and add python_requires='>=3.9' --- .github/workflows/python-package.yml | 30 ++++++++++++++++++++++++++++ .github/workflows/python-publish.yml | 29 +++++++++++++++++++++++++++ setup.py | 8 +++++--- 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/python-package.yml create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..b6555ee --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,30 @@ +name: Python package + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + - name: Build Sphinx test project + run: | + cd sphinx_lua/test + sphinx-build -b html -W . _build diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..8ee9fd3 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,29 @@ +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/setup.py b/setup.py index cafe011..a01cdee 100644 --- a/setup.py +++ b/setup.py @@ -39,11 +39,13 @@ 'Intended Audience :: Developers', 'Natural Language :: English', 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Documentation :: Sphinx', 'Topic :: Software Development :: Documentation' ], + python_requires='>=3.9', keywords=['sphinx', 'documentation', 'docs', 'lua', 'luadoc', 'restructured'], ) From 11f56245ae1f1c2acd71cb3a2cb0337b125a89c3 Mon Sep 17 00:00:00 2001 From: boolangery Date: Sun, 19 Jul 2026 23:12:18 +0200 Subject: [PATCH 2/3] fix: clamp lines range to actual file line count The start_stop_line filter calculated line ranges from character offsets but could produce stop lines exceeding the actual file line count. Newer Sphinx versions validate lines ranges, causing "line number spec is out of range" warnings that fail the build with -W. Fix: read the full file once, count total lines, and clamp stop_line to total_lines. Also cleaned up file reading with a context manager. --- .gitignore | 1 + sphinx_lua/renderers.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 462ba37..4045454 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__/ .idea sphinx_lua.egg-info sphinx_lua/test/build/ +_build/ diff --git a/sphinx_lua/renderers.py b/sphinx_lua/renderers.py index d5226ba..fc88cf7 100644 --- a/sphinx_lua/renderers.py +++ b/sphinx_lua/renderers.py @@ -79,10 +79,14 @@ def process_link(s): def start_stop_line(doc_node, file_path): """ Return start stop line in the form '1-5' """ - file = open(os.path.join(self._app.confdir, file_path), "r") - start_line = file.read(doc_node.start_char).count('\n') + 1 - stop_line = file.read(doc_node.stop_char - doc_node.start_char).count('\n') + 1 + start_line - file.close() + file_path = os.path.join(self._app.confdir, file_path) + with open(file_path, "r") as f: + content = f.read() + total_lines = content.count('\n') + 1 + start_line = content[:doc_node.start_char].count('\n') + 1 + stop_line = content[:doc_node.stop_char].count('\n') + 1 + # Clamp to actual file line count (avoid "out of range" with Sphinx -W) + stop_line = min(stop_line, total_lines) return str(start_line) + "-" + str(stop_line) # Render to RST using Jinja: From 2b02f97db87cc40835421e66c3758ba8324812e6 Mon Sep 17 00:00:00 2001 From: boolangery Date: Mon, 20 Jul 2026 09:40:07 +0200 Subject: [PATCH 3/3] chore: remove .travis.yml (migrated to GitHub Actions) --- .travis.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ce5650d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -sudo: false -language: python -addons: - apt: - packages: - - npm -python: - - "2.7" - - "3.6" -install: - - npm install jsdoc@3.5.5 - - pip install tox-travis -script: - - PATH=$TRAVIS_BUILD_DIR/node_modules/.bin:$PATH tox