From 2ebe3287088335429e20c4301ae5c5c21d9208bc Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:27:14 +0100 Subject: [PATCH 01/10] =?UTF-8?q?=F0=9F=A7=AA=20Add=20full=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/index.rst | 17 +++++++ pyproject.toml | 2 + tests/__snapshots__/test_basic.ambr | 77 +++++++++++++++++++++++++++++ tests/modules/module1.py | 14 ++++++ tests/test_basic.py | 12 ++++- 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 tests/__snapshots__/test_basic.ambr create mode 100644 tests/modules/module1.py diff --git a/docs/index.rst b/docs/index.rst index 4e016fd..838bfcf 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,6 +3,23 @@ sphinx-sqlalchemy Sphinx extension for documenting SQLAlchemy ORMs. +Usage +----- + +Install ``sphinx_sqlalchemy``: + +.. code-block:: bash + + pip install sphinx_sqlalchemy + +Add ``sphinx_sqlalchemy`` to your ``conf.py``: + +.. code-block:: python + + extensions = [ + 'sphinx_sqlalchemy', + ] + Example ------- diff --git a/pyproject.toml b/pyproject.toml index c4ccb42..6a0a712 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,8 @@ Documentation = "https://sphinx-sqlalchemy.readthedocs.io" dev = [ "pytest", "pytest-cov", + "sphinx-pytest", + "syrupy~=4.0", ] docs = ["furo==2021.11.23"] diff --git a/tests/__snapshots__/test_basic.ambr b/tests/__snapshots__/test_basic.ambr new file mode 100644 index 0000000..4f361f3 --- /dev/null +++ b/tests/__snapshots__/test_basic.ambr @@ -0,0 +1,77 @@ +# serializer version: 1 +# name: test_basic + ''' + + + + + module1.TestUser + ( + + dbusers + ) + + + A + + user + . + + Columns: + + + + + + + + + + + pk* + + + INTEGER + + + + + + first_name + + + VARCHAR? + + + The name of the user. + + + + last_name + + + VARCHAR(255)? + + + The surname of the user. + + + + dob + + + DATE + + + The date of birth. + + Constraints: + + + + PRIMARY KEY (pk) + + + UNIQUE (first_name, last_name) + ''' +# --- diff --git a/tests/modules/module1.py b/tests/modules/module1.py new file mode 100644 index 0000000..b0b0df6 --- /dev/null +++ b/tests/modules/module1.py @@ -0,0 +1,14 @@ +from sqlalchemy import Column, UniqueConstraint, orm, types + +Base = orm.declarative_base() + + +class TestUser(Base): + """A ``user``.""" + + __tablename__ = "dbusers" + __table_args__ = (UniqueConstraint("first_name", "last_name"),) + pk = Column(types.Integer, primary_key=True) + first_name = Column(types.String, doc="The name of the user.") + last_name = Column(types.String(255), doc="The surname of the user.") + dob = Column(types.Date, nullable=False, doc="The date of birth.") diff --git a/tests/test_basic.py b/tests/test_basic.py index 1d15f76..f34b874 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,6 +1,14 @@ """Basic tests""" +import os.path +import sys +from sphinx_pytest.plugin import CreateDoctree -def test_basic(): + +def test_basic(sphinx_doctree_no_tr: CreateDoctree, snapshot): """Basic test""" - assert True + sys.path.insert(0, os.path.join(os.path.dirname(__file__), "modules")) + sphinx_doctree_no_tr.set_conf({"extensions": ["sphinx_sqlalchemy"]}) + result = sphinx_doctree_no_tr(".. sqla-model:: module1.TestUser") + assert not result.warnings + assert result.pformat() == snapshot From d3daa0f67e94a0dd69ed84dc2cf9fe7103248088 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:31:11 +0100 Subject: [PATCH 02/10] Update .readthedocs.yml --- .readthedocs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 0d0b035..f0a637d 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,7 +1,6 @@ version: 2 python: - version: "3.8" install: - method: pip path: . From 77ad3af3e78d1e31984197e0eeaf08bf89ab1cae Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:34:51 +0100 Subject: [PATCH 03/10] update --- .readthedocs.yml => .readthedocs.yaml | 1 + 1 file changed, 1 insertion(+) rename .readthedocs.yml => .readthedocs.yaml (90%) diff --git a/.readthedocs.yml b/.readthedocs.yaml similarity index 90% rename from .readthedocs.yml rename to .readthedocs.yaml index f0a637d..0d0b035 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yaml @@ -1,6 +1,7 @@ version: 2 python: + version: "3.8" install: - method: pip path: . From e30217bd3bcd36eebc05eca485ecf73ab04f9a31 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:39:45 +0100 Subject: [PATCH 04/10] Update test_basic.py --- tests/test_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index f34b874..286e50f 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -11,4 +11,4 @@ def test_basic(sphinx_doctree_no_tr: CreateDoctree, snapshot): sphinx_doctree_no_tr.set_conf({"extensions": ["sphinx_sqlalchemy"]}) result = sphinx_doctree_no_tr(".. sqla-model:: module1.TestUser") assert not result.warnings - assert result.pformat() == snapshot + assert "\n".join([li.rstrip() for li in result.pformat().splitlines()]) == snapshot From 9755c3de9ce7431e22a39ff49653528b1222297a Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:41:51 +0100 Subject: [PATCH 05/10] update --- .github/workflows/tests.yml | 2 +- pyproject.toml | 2 +- tox.ini | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8518336..2f905bb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11"] os: ['ubuntu-latest'] steps: diff --git a/pyproject.toml b/pyproject.toml index 6a0a712..cf0b504 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] keywords = ["sphinx", "extension"] -requires-python = "~=3.7" +requires-python = "~=3.8" dependencies = [ "sphinx>=3,<5", "sqlalchemy~=1.4.22", diff --git a/tox.ini b/tox.ini index 8ec9c3b..358f054 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ envlist = py38 [testenv] usedevelop = true -[testenv:py{37,38,39,310}] +[testenv:py{38,39,310,311}] description = Run unit tests with this Python version extras = dev From c22b4888386d8ff13df0ee91f4618bf960db8e52 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:46:33 +0100 Subject: [PATCH 06/10] update --- .readthedocs.yaml => .readthedocs.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename .readthedocs.yaml => .readthedocs.yml (74%) diff --git a/.readthedocs.yaml b/.readthedocs.yml similarity index 74% rename from .readthedocs.yaml rename to .readthedocs.yml index 0d0b035..62010b1 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yml @@ -1,7 +1,11 @@ version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.8" + python: - version: "3.8" install: - method: pip path: . From a5da9edcc7abd499d0905ed2f6e3ec0afa3acb5b Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:53:26 +0100 Subject: [PATCH 07/10] update --- .github/dependabot.yml | 19 +++++++++++++++++++ .github/workflows/tests.yml | 11 ++++++++++- .readthedocs.yml | 8 ++++---- pyproject.toml | 5 +++-- tox.ini | 2 -- 5 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a30a1ea --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + commit-message: + prefix: ⬆️ + schedule: + interval: monthly + - package-ecosystem: pip + directory: / + commit-message: + prefix: ⬆️ + schedule: + interval: monthly diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2f905bb..216c0a4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,12 +21,21 @@ jobs: - uses: pre-commit/action@v2.0.0 tests: + name: tests on py${{ matrix.python-version }} with sphinx~=${{ matrix.sphinx-version }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] + sphinx-version: ["7.0"] os: ['ubuntu-latest'] + include: + - python-version: "3.8" + sphinx-version: "5.0" + os: 'ubuntu-latest' + - python-version: "3.8" + sphinx-version: "6.0" + os: 'ubuntu-latest' steps: - uses: actions/checkout@v2 @@ -38,7 +47,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -e .[dev] + pip install sphinx~=${{ matrix.sphinx-version }} -e .[dev] - name: Test with pytest run: pytest -vv --cov=sphinx_sqlalchemy env: diff --git a/.readthedocs.yml b/.readthedocs.yml index 62010b1..6bc68f3 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -7,10 +7,10 @@ build: python: install: - - method: pip - path: . - extra_requirements: - - docs + - method: pip + path: . + extra_requirements: + - docs sphinx: builder: html diff --git a/pyproject.toml b/pyproject.toml index cf0b504..713d663 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,16 +17,17 @@ classifiers = [ "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules", ] keywords = ["sphinx", "extension"] requires-python = "~=3.8" dependencies = [ - "sphinx>=3,<5", + "sphinx>=5,<8", "sqlalchemy~=1.4.22", ] diff --git a/tox.ini b/tox.ini index 358f054..3ee1d48 100644 --- a/tox.ini +++ b/tox.ini @@ -13,8 +13,6 @@ usedevelop = true description = Run unit tests with this Python version extras = dev -deps = - black setenv = SQLALCHEMY_WARN_20 = 1 commands = pytest {posargs} From f73b588472cacadad03d60c1b79b8d48378c0fa0 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:55:08 +0100 Subject: [PATCH 08/10] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 713d663..998a621 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ dev = [ "sphinx-pytest", "syrupy~=4.0", ] -docs = ["furo==2021.11.23"] +docs = ["furo"] [tool.ruff] line-length = 100 From a453d63a01134e3e917dc9662e704f5495a9e543 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 16:59:38 +0100 Subject: [PATCH 09/10] Update tests.yml --- .github/workflows/tests.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 216c0a4..00614ae 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,6 +53,25 @@ jobs: env: SQLALCHEMY_WARN_20: 1 + all-good: + + # This job does nothing and is only used for the branch protection + # see https://github.com/marketplace/actions/alls-green#why + + if: always() + + needs: + - pre-commit + - tests + + runs-on: ubuntu-latest + + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + publish: name: Publish to PyPi From 1b7eca69f9c408ab31919dfc3bca36daf0fedb71 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 9 Nov 2023 17:03:12 +0100 Subject: [PATCH 10/10] Update conf.py --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index 930caab..4da73c7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,4 +7,5 @@ extensions = ["sphinx_sqlalchemy"] +html_title = "sphinx-sqlalchemy documentation" html_theme = "furo"