Skip to content

Commit 031e8d6

Browse files
authored
Merge pull request #151 from bckohan/v3.0.0
V3.0.0
2 parents c6f706f + ca2dd62 commit 031e8d6

File tree

197 files changed

+2069
-1619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+2069
-1619
lines changed

.github/workflows/lint.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
inputs:
8+
debug:
9+
description: 'Set to on, to open ssh debug session.'
10+
required: true
11+
default: 'off'
12+
13+
jobs:
14+
15+
lint:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
# run static analysis on bleeding and trailing edges
20+
python-version: [ '3.9', '3.12' ]
21+
django-version:
22+
- 'Django~=3.2.0' # LTS April 2024
23+
- 'Django~=4.2.0' # LTS April 2026
24+
- 'Django~=5.0.0'
25+
exclude:
26+
- python-version: '3.9'
27+
django-version: 'Django~=4.2.0'
28+
- python-version: '3.9'
29+
django-version: 'Django~=5.0.0'
30+
- python-version: '3.12'
31+
django-version: 'Django~=3.2.0'
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
40+
- name: Install Poetry
41+
uses: snok/install-poetry@v1
42+
with:
43+
version: 1.8.3
44+
virtualenvs-create: true
45+
virtualenvs-in-project: true
46+
- name: Install Dependencies
47+
run: |
48+
poetry config virtualenvs.in-project true
49+
poetry run pip install --upgrade pip
50+
poetry install -E all
51+
poetry run pip install -U "${{ matrix.django-version }}"
52+
- name: Install Emacs
53+
if: ${{ github.event.inputs.debug == 'on' }}
54+
run: |
55+
sudo apt install emacs
56+
- name: Setup tmate session
57+
if: ${{ github.event.inputs.debug == 'on' }}
58+
uses: mxschmitt/action-tmate@v3
59+
with:
60+
detached: true
61+
timeout-minutes: 60
62+
- name: Run Static Analysis
63+
run: |
64+
./check.sh --no-fix
65+
poetry run python -m readme_renderer ./README.md -o /tmp/README.html

.github/workflows/test.yml

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,19 @@
11
name: test
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
inputs:
8+
debug:
9+
description: 'Set to on, to open ssh debug session.'
10+
required: true
11+
default: 'off'
412

5-
jobs:
6-
7-
static-analysis:
8-
runs-on: ubuntu-latest
9-
strategy:
10-
matrix:
11-
# run static analysis on bleeding and trailing edges
12-
python-version: [ '3.9', '3.12' ]
13-
django-version:
14-
- 'Django~=3.2.0' # LTS April 2024
15-
- 'Django~=4.2.0' # LTS April 2026
16-
- 'Django~=5.0.0'
17-
exclude:
18-
- python-version: '3.9'
19-
django-version: 'Django~=4.2.0'
20-
- python-version: '3.9'
21-
django-version: 'Django~=5.0.0'
22-
- python-version: '3.12'
23-
django-version: 'Django~=3.2.0'
24-
25-
steps:
26-
- uses: actions/checkout@v4
27-
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v5
29-
with:
30-
python-version: ${{ matrix.python-version }}
13+
schedule:
14+
- cron: '0 13 * * *' # Runs at 6 am pacific every day
3115

32-
- name: Install Poetry
33-
uses: snok/install-poetry@v1
34-
with:
35-
version: 1.5.1
36-
virtualenvs-create: true
37-
virtualenvs-in-project: true
38-
- name: Install Dependencies
39-
run: |
40-
poetry config virtualenvs.in-project true
41-
poetry run pip install --upgrade pip
42-
poetry install -E all
43-
poetry run pip install -U "${{ matrix.django-version }}"
44-
- name: Run Static Analysis
45-
run: |
46-
poetry run black render_static --check
47-
poetry run pylint render_static
48-
poetry run mypy render_static
49-
poetry check
50-
poetry run pip check
51-
poetry export --without-hashes --format=requirements.txt | poetry run safety check --stdin
52-
poetry run python -m readme_renderer ./README.md -o /tmp/README.html
53-
cd ./doc
54-
poetry run doc8 --ignore-path build --max-line-length 100
16+
jobs:
5517

5618
test:
5719
runs-on: ubuntu-latest
@@ -93,17 +55,22 @@ jobs:
9355
poetry run pip install --upgrade pip
9456
poetry install -E all
9557
poetry run pip install -U "Django~=${{ matrix.django-version }}"
58+
- name: Install Emacs
59+
if: ${{ github.event.inputs.debug == 'on' }}
60+
run: |
61+
sudo apt install emacs
62+
- name: Setup tmate session
63+
if: ${{ github.event.inputs.debug == 'on' }}
64+
uses: mxschmitt/action-tmate@v3
65+
with:
66+
detached: true
67+
timeout-minutes: 60
9668
- name: Run Unit Tests
9769
run: |
9870
poetry run pytest
9971
poetry run pip uninstall -y jinja2 pyyaml importlib-resources
10072
poetry run pytest --cov-append
10173
mv .coverage py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
102-
# - name: Setup tmate session
103-
# uses: mxschmitt/action-tmate@v3
104-
# with:
105-
# detached: true
106-
# timeout-minutes: 60
10774
- name: Store coverage files
10875
uses: actions/upload-artifact@v4
10976
with:

CONTRIBUTING.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@ static analysis tools should not produce any errors or warnings. Disabling certa
4545
warnings where justified is acceptable:
4646

4747
```shell
48-
poetry run isort render_static
49-
poetry run black render_static
50-
poetry run mypy render_static
51-
poetry run pylint render_static
52-
poetry check
53-
poetry run pip check
48+
./check.sh
5449
poetry run python -m readme_renderer ./README.md
5550
```
5651

@@ -59,7 +54,7 @@ poetry run python -m readme_renderer ./README.md
5954
`django-render-static` is setup to use
6055
[django-pytest](https://pytest-django.readthedocs.io/en/latest/) to allow
6156
[pytest](https://docs.pytest.org/en/stable/) to run Django unit tests. All the tests are housed in
62-
render_static/tests/tests.py. Before a PR is accepted, all tests must be passing and the code
57+
tests/tests.py. Before a PR is accepted, all tests must be passing and the code
6358
coverage must be at 100%.
6459

6560
To run the full suite:
@@ -78,6 +73,6 @@ For instance to run all tests in DefinesToJavascriptTest, and then just the test
7873
you would do:
7974

8075
```shell
81-
poetry run pytest render_static/tests/tests.py::DefinesToJavascriptTest
82-
poetry run pytest render_static/tests/tests.py::DefinesToJavascriptTest::test_classes_to_js
76+
poetry run pytest tests/tests.py::DefinesToJavascriptTest
77+
poetry run pytest tests/tests.py::DefinesToJavascriptTest::test_classes_to_js
8378
```

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[![Documentation Status](https://readthedocs.org/projects/django-render-static/badge/?version=latest)](http://django-render-static.readthedocs.io/?badge=latest/)
77
[![Code Cov](https://codecov.io/gh/bckohan/django-render-static/branch/main/graph/badge.svg?token=0IZOKN2DYL)](https://codecov.io/gh/bckohan/django-render-static)
88
[![Test Status](https://github.com/bckohan/django-render-static/workflows/test/badge.svg)](https://github.com/bckohan/django-render-static/actions/workflows/test.yml)
9+
[![Lint Status](https://github.com/bckohan/django-render-static/workflows/lint/badge.svg)](https://github.com/bckohan/django-render-static/actions/workflows/lint.yml)
910
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1011

1112
# django-render-static

check.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
set -e # Exit immediately if a command exits with a non-zero status.
2+
3+
if [ "$1" == "--no-fix" ]; then
4+
poetry run ruff format --check
5+
poetry run ruff check --select I
6+
poetry run ruff check
7+
else
8+
poetry run ruff format
9+
poetry run ruff check --fix --select I
10+
poetry run ruff check --fix
11+
fi
12+
13+
poetry run mypy render_static
14+
poetry run pyright
15+
poetry check
16+
poetry run pip check
17+
cd ./doc
18+
poetry run doc8 --ignore-path build --max-line-length 100 -q
19+
# check for broken links in the docs ############
20+
set +e
21+
22+
# do not run this in CI - too spurious
23+
if [ "$1" != "--no-fix" ]; then
24+
poetry run sphinx-build -b linkcheck -q ./source ./build > /dev/null 2>&1
25+
if [ $? -ne 0 ]; then
26+
cat ./build/output.txt | grep broken
27+
exit 1
28+
fi
29+
fi
30+
#################################################
31+
cd ..

doc/source/changelog.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
Change Log
33
==========
44

5+
v3.0.0
6+
======
7+
8+
**This is a major version upgrade - please see migration guide for instructions
9+
on how to** :ref:`migrate from version 2.x to 3.x. <migration_2_3>`
10+
11+
* Implemented `Move tests into top level directory. <https://github.com/bckohan/django-render-static/issues/149>`_
12+
* Implemented `Remove wrapped dependency required mishegoss and replace with jinja2 module level imports <https://github.com/bckohan/django-render-static/issues/148>`_
13+
* Implemented `Allow context import path to also point to a module. <https://github.com/bckohan/django-render-static/issues/147>`_
14+
* Implemented `Remove imports in __init__.py <https://github.com/bckohan/django-render-static/issues/146>`_
15+
* Implemented `Switch to ruff for formatting and linting <https://github.com/bckohan/django-render-static/issues/145>`_
16+
* Fixed `Support django-typer version 2.1 <https://github.com/bckohan/django-render-static/issues/144>`_
17+
18+
519
v2.2.1
620
======
721

@@ -61,7 +75,7 @@ v2.0.0
6175
======
6276

6377
**This is a major version upgrade - please see migration guide for instructions
64-
on how to** :doc:`migration` **from version 1.x to 2.x.**
78+
on how to** :ref:`migrate from version 1.x to 2.x. <migration_1_2>`
6579

6680
* Implemented `Add some default templates to ship for defines, urls and enums. <https://github.com/bckohan/django-render-static/issues/116>`_
6781
* Implemented `Generate JDoc comments in the generated URLResolver class. <https://github.com/bckohan/django-render-static/issues/115>`_

doc/source/commands.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Usage
1717
.. typer:: render_static.management.commands.renderstatic.Command:typer_app
1818
:prog: manage.py renderstatic
1919
:width: 90
20+
:theme: dark
2021

2122
Example
2223
~~~~~~~

doc/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import os
44
from pathlib import Path
55
sys.path.append(str(Path(__file__).parent.parent.parent))
6+
sys.path.append(str(Path(__file__).parent.parent.parent / 'tests'))
67
import render_static
78
import django
89

9-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'render_static.tests.settings')
10+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings')
1011
django.setup()
1112

1213
# Configuration file for the Sphinx documentation builder.

doc/source/configuration.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ here, instead use the two engines provided by `django-render-static`:
7979

8080
- ``render_static.backends.StaticDjangoTemplates``
8181
- default app directory: ``static_templates``
82-
- ``render_static.backends.StaticJinja2Templates``
82+
- ``render_static.backends.jinja2.StaticJinja2Templates``
8383
- default app directory: ``static_jinja2``
8484

8585
If ``APP_DIRS`` is true, or if an app directories loader is used such that templates are searched
@@ -111,7 +111,7 @@ template backend the loaders have been extended and static specific loaders shou
111111
- ``render_static.loaders.django.StaticFilesystemLoader``
112112
- ``render_static.loaders.django.StaticLocMemLoader``
113113

114-
- ``render_static.backends.StaticJinja2Templates``
114+
- ``render_static.backends.jinja2.StaticJinja2Templates``
115115
- ``render_static.loaders.jinja2.StaticFileSystemBatchLoader`` **default**
116116
- ``render_static.loaders.jinja2.StaticFileSystemLoader``
117117
- ``render_static.loaders.jinja2.StaticPackageLoader``
@@ -156,6 +156,8 @@ Context configuration parameters may be any of the following:
156156
- **dictionary**: Simply specify context dictionary inline
157157
- **callable**: That returns a dictionary. This allows lazy context initialization to take
158158
place after Django bootstrapping
159+
- **module**: When a module is used as a context, the module's locals will be used as the
160+
context.
159161
- **json**: A path to a JSON file
160162
- **yaml**: A path to a YAML file (yaml supports comments!)
161163
- **pickle**: A path to a python pickled dictionary
@@ -278,7 +280,7 @@ And our settings file might look like:
278280
279281
STATIC_TEMPLATES = {
280282
'ENGINES': [{
281-
'BACKEND': 'render_static.backends.StaticJinja2Templates',
283+
'BACKEND': 'render_static.backends.jinja2.StaticJinja2Templates',
282284
'OPTIONS': {
283285
'loader': StaticFileSystemBatchLoader()
284286
},

doc/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ and Jinja templates and allows contexts to be specified in python, json or YAML.
3030
You can report bugs and discuss features on the
3131
`issues page <https://github.com/bckohan/django-render-static/issues>`_.
3232

33-
`Contributions <https://github.com/bckohan/django-render-static/blob/main/CONTRIBUTING.rst>`_ are
33+
`Contributions <https://github.com/bckohan/django-render-static/blob/main/CONTRIBUTING.md>`_ are
3434
encouraged! Especially additional template tags and filters!
3535

3636
.. toctree::

0 commit comments

Comments
 (0)