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
30 changes: 30 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ __pycache__/
.idea
sphinx_lua.egg-info
sphinx_lua/test/build/
_build/
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
)
12 changes: 8 additions & 4 deletions sphinx_lua/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading