Skip to content

Commit 0bdf385

Browse files
committed
✨ NEW: Initial implementation
1 parent f04c2fb commit 0bdf385

File tree

19 files changed

+517
-0
lines changed

19 files changed

+517
-0
lines changed

.github/workflows/tests.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
10+
jobs:
11+
12+
pre-commit:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: "3.8"
21+
- uses: pre-commit/[email protected]
22+
23+
tests:
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
python-version: ["3.7", "3.8", "3.9", "3.10"]
29+
os: ['ubuntu-latest']
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install -e .[dev]
42+
- name: Test with pytest
43+
run: pytest -vv --cov=sphinx_sqlalchemy
44+
env:
45+
SQLALCHEMY_WARN_20: 1
46+
47+
publish:
48+
49+
name: Publish to PyPi
50+
needs: [pre-commit, tests]
51+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout source
55+
uses: actions/checkout@v2
56+
- name: Set up Python
57+
uses: actions/setup-python@v2
58+
with:
59+
python-version: 3.8
60+
- name: Build package
61+
run: |
62+
pip install wheel
63+
python setup.py sdist bdist_wheel
64+
- name: Publish
65+
uses: pypa/[email protected]
66+
with:
67+
user: __token__
68+
password: ${{ secrets.PYPI_KEY }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,5 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
.vscode/

.pre-commit-config.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
ci:
2+
autoupdate_schedule: monthly
3+
autofix_prs: true
4+
5+
exclude: &exclude_files >
6+
(?x)^(
7+
performance-benchmarks/.*/.*\.py
8+
)$
9+
10+
repos:
11+
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v4.0.1
14+
hooks:
15+
- id: check-json
16+
- id: check-yaml
17+
- id: end-of-file-fixer
18+
- id: trailing-whitespace
19+
20+
- repo: https://github.com/asottile/setup-cfg-fmt
21+
rev: v1.17.0
22+
hooks:
23+
- id: setup-cfg-fmt
24+
25+
- repo: https://github.com/mgedmin/check-manifest
26+
rev: "0.46"
27+
hooks:
28+
- id: check-manifest
29+
args: [--no-build-isolation]
30+
additional_dependencies: [setuptools>=46.4.0]
31+
32+
- repo: https://github.com/pycqa/isort
33+
rev: 5.9.3
34+
hooks:
35+
- id: isort
36+
37+
- repo: https://github.com/asottile/pyupgrade
38+
rev: v2.25.0
39+
hooks:
40+
- id: pyupgrade
41+
args: [--py37-plus]
42+
43+
- repo: https://github.com/psf/black
44+
rev: 21.7b0
45+
hooks:
46+
- id: black
47+
48+
- repo: https://github.com/PyCQA/flake8
49+
rev: '3.9.2'
50+
hooks:
51+
- id: flake8
52+
additional_dependencies:
53+
- flake8-bugbear==20.1.4
54+
- flake8-builtins==1.5.3
55+
- flake8-comprehensions==3.2.3
56+
- flake8-rst-docstrings==0.0.14
57+
- flake8-markdown==0.2.0
58+
59+
- repo: https://github.com/pre-commit/mirrors-mypy
60+
rev: v0.910-1
61+
hooks:
62+
- id: mypy
63+
additional_dependencies:
64+
- "sqlalchemy[mypy]==1.4.22"
65+
files: ^(sphinx_sqlalchemy/.*py)$

.readthedocs.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
3+
python:
4+
version: "3.8"
5+
install:
6+
- method: pip
7+
path: .
8+
extra_requirements:
9+
- docs
10+
11+
sphinx:
12+
builder: html
13+
fail_on_warning: true

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## v0.1.0 (November 2021)
4+
5+
Initial release.

MANIFEST.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
exclude docs
2+
recursive-exclude docs *
3+
exclude tests
4+
recursive-exclude tests *
5+
6+
exclude .pre-commit-config.yaml
7+
exclude tox.ini
8+
exclude .readthedocs.yml
9+
10+
include LICENSE
11+
include CHANGELOG.md
12+
include README.md

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# sphinx-sqlalchemy
2+
23
Sphinx extension for documenting SQLAlchemy ORMs

docs/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Sphinx configuration file."""
2+
import os
3+
import sys
4+
5+
# add example module to the python path
6+
sys.path.insert(0, os.path.dirname(__file__))
7+
8+
extensions = ["sphinx_sqlalchemy"]
9+
10+
html_theme = "furo"

docs/example/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""An example module."""

docs/example/models.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Example SQLAlchemy ORM models."""
2+
from sqlalchemy import CheckConstraint, Column, ForeignKey, UniqueConstraint, orm, types
3+
4+
Base = orm.declarative_base()
5+
6+
7+
class User(Base):
8+
"""A user."""
9+
10+
__tablename__ = "dbusers"
11+
__table_args__ = (UniqueConstraint("first_name", "last_name"),)
12+
pk = Column(types.Integer, primary_key=True)
13+
first_name = Column(types.String, doc="The name of the user.")
14+
last_name = Column(types.String(255), doc="The surname of the user.")
15+
dob = Column(types.Date, nullable=False, doc="The date of birth.")
16+
17+
18+
class Address(Base):
19+
"""An address."""
20+
21+
__tablename__ = "addresses"
22+
__table_args__ = (CheckConstraint("number>0", name="check1"),)
23+
pk = Column(types.Integer, primary_key=True)
24+
number = Column(types.Integer, nullable=False, doc="The number of the address.")
25+
postcode = Column(types.String, nullable=False)
26+
user_id = Column(types.Integer, ForeignKey("dbusers.pk"))
27+
user = orm.relationship("User")

0 commit comments

Comments
 (0)