Skip to content

Commit

Permalink
Merge pull request #151 from bckohan/v3.0.0
Browse files Browse the repository at this point in the history
V3.0.0
  • Loading branch information
bckohan committed Jun 7, 2024
2 parents c6f706f + ca2dd62 commit 031e8d6
Show file tree
Hide file tree
Showing 197 changed files with 2,069 additions and 1,619 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: lint

on:
push:
pull_request:
workflow_dispatch:
inputs:
debug:
description: 'Set to on, to open ssh debug session.'
required: true
default: 'off'

jobs:

lint:
runs-on: ubuntu-latest
strategy:
matrix:
# run static analysis on bleeding and trailing edges
python-version: [ '3.9', '3.12' ]
django-version:
- 'Django~=3.2.0' # LTS April 2024
- 'Django~=4.2.0' # LTS April 2026
- 'Django~=5.0.0'
exclude:
- python-version: '3.9'
django-version: 'Django~=4.2.0'
- python-version: '3.9'
django-version: 'Django~=5.0.0'
- python-version: '3.12'
django-version: 'Django~=3.2.0'

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 Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install Dependencies
run: |
poetry config virtualenvs.in-project true
poetry run pip install --upgrade pip
poetry install -E all
poetry run pip install -U "${{ matrix.django-version }}"
- name: Install Emacs
if: ${{ github.event.inputs.debug == 'on' }}
run: |
sudo apt install emacs
- name: Setup tmate session
if: ${{ github.event.inputs.debug == 'on' }}
uses: mxschmitt/action-tmate@v3
with:
detached: true
timeout-minutes: 60
- name: Run Static Analysis
run: |
./check.sh --no-fix
poetry run python -m readme_renderer ./README.md -o /tmp/README.html
77 changes: 22 additions & 55 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,19 @@
name: test

on: [push, pull_request, workflow_dispatch]
on:
push:
pull_request:
workflow_dispatch:
inputs:
debug:
description: 'Set to on, to open ssh debug session.'
required: true
default: 'off'

jobs:

static-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
# run static analysis on bleeding and trailing edges
python-version: [ '3.9', '3.12' ]
django-version:
- 'Django~=3.2.0' # LTS April 2024
- 'Django~=4.2.0' # LTS April 2026
- 'Django~=5.0.0'
exclude:
- python-version: '3.9'
django-version: 'Django~=4.2.0'
- python-version: '3.9'
django-version: 'Django~=5.0.0'
- python-version: '3.12'
django-version: 'Django~=3.2.0'

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
schedule:
- cron: '0 13 * * *' # Runs at 6 am pacific every day

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install Dependencies
run: |
poetry config virtualenvs.in-project true
poetry run pip install --upgrade pip
poetry install -E all
poetry run pip install -U "${{ matrix.django-version }}"
- name: Run Static Analysis
run: |
poetry run black render_static --check
poetry run pylint render_static
poetry run mypy render_static
poetry check
poetry run pip check
poetry export --without-hashes --format=requirements.txt | poetry run safety check --stdin
poetry run python -m readme_renderer ./README.md -o /tmp/README.html
cd ./doc
poetry run doc8 --ignore-path build --max-line-length 100
jobs:

test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -93,17 +55,22 @@ jobs:
poetry run pip install --upgrade pip
poetry install -E all
poetry run pip install -U "Django~=${{ matrix.django-version }}"
- name: Install Emacs
if: ${{ github.event.inputs.debug == 'on' }}
run: |
sudo apt install emacs
- name: Setup tmate session
if: ${{ github.event.inputs.debug == 'on' }}
uses: mxschmitt/action-tmate@v3
with:
detached: true
timeout-minutes: 60
- name: Run Unit Tests
run: |
poetry run pytest
poetry run pip uninstall -y jinja2 pyyaml importlib-resources
poetry run pytest --cov-append
mv .coverage py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# detached: true
# timeout-minutes: 60
- name: Store coverage files
uses: actions/upload-artifact@v4
with:
Expand Down
13 changes: 4 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ static analysis tools should not produce any errors or warnings. Disabling certa
warnings where justified is acceptable:

```shell
poetry run isort render_static
poetry run black render_static
poetry run mypy render_static
poetry run pylint render_static
poetry check
poetry run pip check
./check.sh
poetry run python -m readme_renderer ./README.md
```

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

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

```shell
poetry run pytest render_static/tests/tests.py::DefinesToJavascriptTest
poetry run pytest render_static/tests/tests.py::DefinesToJavascriptTest::test_classes_to_js
poetry run pytest tests/tests.py::DefinesToJavascriptTest
poetry run pytest tests/tests.py::DefinesToJavascriptTest::test_classes_to_js
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![Documentation Status](https://readthedocs.org/projects/django-render-static/badge/?version=latest)](http://django-render-static.readthedocs.io/?badge=latest/)
[![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)
[![Test Status](https://github.com/bckohan/django-render-static/workflows/test/badge.svg)](https://github.com/bckohan/django-render-static/actions/workflows/test.yml)
[![Lint Status](https://github.com/bckohan/django-render-static/workflows/lint/badge.svg)](https://github.com/bckohan/django-render-static/actions/workflows/lint.yml)
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# django-render-static
Expand Down
31 changes: 31 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set -e # Exit immediately if a command exits with a non-zero status.

if [ "$1" == "--no-fix" ]; then
poetry run ruff format --check
poetry run ruff check --select I
poetry run ruff check
else
poetry run ruff format
poetry run ruff check --fix --select I
poetry run ruff check --fix
fi

poetry run mypy render_static
poetry run pyright
poetry check
poetry run pip check
cd ./doc
poetry run doc8 --ignore-path build --max-line-length 100 -q
# check for broken links in the docs ############
set +e

# do not run this in CI - too spurious
if [ "$1" != "--no-fix" ]; then
poetry run sphinx-build -b linkcheck -q ./source ./build > /dev/null 2>&1
if [ $? -ne 0 ]; then
cat ./build/output.txt | grep broken
exit 1
fi
fi
#################################################
cd ..
16 changes: 15 additions & 1 deletion doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
Change Log
==========

v3.0.0
======

**This is a major version upgrade - please see migration guide for instructions
on how to** :ref:`migrate from version 2.x to 3.x. <migration_2_3>`

* Implemented `Move tests into top level directory. <https://github.com/bckohan/django-render-static/issues/149>`_
* Implemented `Remove wrapped dependency required mishegoss and replace with jinja2 module level imports <https://github.com/bckohan/django-render-static/issues/148>`_
* Implemented `Allow context import path to also point to a module. <https://github.com/bckohan/django-render-static/issues/147>`_
* Implemented `Remove imports in __init__.py <https://github.com/bckohan/django-render-static/issues/146>`_
* Implemented `Switch to ruff for formatting and linting <https://github.com/bckohan/django-render-static/issues/145>`_
* Fixed `Support django-typer version 2.1 <https://github.com/bckohan/django-render-static/issues/144>`_


v2.2.1
======

Expand Down Expand Up @@ -61,7 +75,7 @@ v2.0.0
======

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

* Implemented `Add some default templates to ship for defines, urls and enums. <https://github.com/bckohan/django-render-static/issues/116>`_
* Implemented `Generate JDoc comments in the generated URLResolver class. <https://github.com/bckohan/django-render-static/issues/115>`_
Expand Down
1 change: 1 addition & 0 deletions doc/source/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Usage
.. typer:: render_static.management.commands.renderstatic.Command:typer_app
:prog: manage.py renderstatic
:width: 90
:theme: dark

Example
~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import os
from pathlib import Path
sys.path.append(str(Path(__file__).parent.parent.parent))
sys.path.append(str(Path(__file__).parent.parent.parent / 'tests'))
import render_static
import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'render_static.tests.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings')
django.setup()

# Configuration file for the Sphinx documentation builder.
Expand Down
8 changes: 5 additions & 3 deletions doc/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ here, instead use the two engines provided by `django-render-static`:

- ``render_static.backends.StaticDjangoTemplates``
- default app directory: ``static_templates``
- ``render_static.backends.StaticJinja2Templates``
- ``render_static.backends.jinja2.StaticJinja2Templates``
- default app directory: ``static_jinja2``

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

- ``render_static.backends.StaticJinja2Templates``
- ``render_static.backends.jinja2.StaticJinja2Templates``
- ``render_static.loaders.jinja2.StaticFileSystemBatchLoader`` **default**
- ``render_static.loaders.jinja2.StaticFileSystemLoader``
- ``render_static.loaders.jinja2.StaticPackageLoader``
Expand Down Expand Up @@ -156,6 +156,8 @@ Context configuration parameters may be any of the following:
- **dictionary**: Simply specify context dictionary inline
- **callable**: That returns a dictionary. This allows lazy context initialization to take
place after Django bootstrapping
- **module**: When a module is used as a context, the module's locals will be used as the
context.
- **json**: A path to a JSON file
- **yaml**: A path to a YAML file (yaml supports comments!)
- **pickle**: A path to a python pickled dictionary
Expand Down Expand Up @@ -278,7 +280,7 @@ And our settings file might look like:
STATIC_TEMPLATES = {
'ENGINES': [{
'BACKEND': 'render_static.backends.StaticJinja2Templates',
'BACKEND': 'render_static.backends.jinja2.StaticJinja2Templates',
'OPTIONS': {
'loader': StaticFileSystemBatchLoader()
},
Expand Down
2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ and Jinja templates and allows contexts to be specified in python, json or YAML.
You can report bugs and discuss features on the
`issues page <https://github.com/bckohan/django-render-static/issues>`_.

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

.. toctree::
Expand Down
16 changes: 16 additions & 0 deletions doc/source/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ Migration
page documents how to migrate past the breaking changes introduced by major
version updates.

.. _migration_2_3:

2.x -> 3.x
----------

There are some import path changes in 3.0:

* ``render_static.ClassURLWriter`` -> ``render_static.transpilers.ClassURLWriter``
* ``render_static.SimpleURLWriter`` -> ``render_static.transpilers.SimpleURLWriter``
* ``render_static.EnumClassWriter`` -> ``render_static.transpilers.EnumClassWriter``
* ``render_static.DefaultDefineTranspiler`` -> ``render_static.transpilers.DefaultDefineTranspiler``
* ``render_static.backends.StaticJinja2Templates`` ->
``render_static.backends.jinja2.StaticJinja2Templates``

.. _migration_1_2:

1.x -> 2.x
----------

Expand Down
7 changes: 5 additions & 2 deletions doc/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ engine
backends
----------------------------------

.. automodule:: render_static.backends
.. automodule:: render_static.backends.django

.. autoclass:: StaticDjangoTemplates

.. automodule:: render_static.backends.jinja2

.. autoclass:: StaticJinja2Templates


Expand Down Expand Up @@ -114,7 +117,7 @@ placeholders
transpilers
----------------------------------------------------------------

.. automodule:: render_static.transpilers
.. automodule:: render_static.transpilers.base

.. autofunction:: to_js
.. autofunction:: to_js_datetime
Expand Down
4 changes: 2 additions & 2 deletions doc/source/templatetags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ specific url names. For instance:

.. code-block:: js+django

{% urls_to_js transpiler='render_static.SimpleURLWriter' %}
{% urls_to_js transpiler='render_static.transpilers.SimpleURLWriter' %}

{% override 'namespace:path_name' %}
return "/an/overridden/path";
Expand All @@ -317,7 +317,7 @@ class writer:

.. code-block:: htmldjango
{% urls_to_js transpiler='render_static.ClassURLWriter' class_name='URLResolver' %}
{% urls_to_js transpiler='render_static.transpilers.ClassURLWriter' class_name='URLResolver' %}
<! the above is equivalent to the below -->
{% urls_to_js %}
Expand Down
Loading

0 comments on commit 031e8d6

Please sign in to comment.