Skip to content

Commit 6ac9822

Browse files
authored
chore(docs): initial revision of docs (#74)
Initial version of documentation
1 parent a90189b commit 6ac9822

35 files changed

+2995
-1510
lines changed

.github/workflows/docs.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Documentation Building
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches:
8+
- main
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
jobs:
13+
build_and_deploy:
14+
permissions:
15+
contents: write
16+
pages: write
17+
id-token: write
18+
environment:
19+
name: github-pages
20+
url: ${{ steps.deployment.outputs.page_url }}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install additional dependencies
26+
run: sudo apt-get update && sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 libmariadb-dev && sudo apt-get autoremove -y && sudo apt-get clean -y
27+
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: 3.12
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v6
35+
36+
- name: Set up Python
37+
run: uv python install 3.12
38+
39+
- name: Install dependencies
40+
run: uv sync --all-extras --dev
41+
42+
- name: Build Release Documentation
43+
run: uv run sphinx-build -M html docs dist/docs -E -a -j auto -W --keep-going
44+
if: github.event_name == 'release'
45+
46+
- name: Build Documentation
47+
run: uv run sphinx-build -M html docs dist/docs -E -a -j auto -W --keep-going
48+
if: github.event_name != 'release'
49+
50+
- name: Upload artifact
51+
uses: actions/upload-pages-artifact@v3
52+
with:
53+
path: dist/docs/
54+
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v4

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919

2020
# Ruff replaces black, flake8, autoflake and isort
2121
- repo: https://github.com/charliermarsh/ruff-pre-commit
22-
rev: "v0.11.6" # make sure this is always consistent with hatch configs
22+
rev: "v0.11.7" # make sure this is always consistent with hatch configs
2323
hooks:
2424
- id: ruff
2525
args: [--config, ./pyproject.toml]

CONTRIBUTING.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ Contribution guide
44
Setting up the environment
55
--------------------------
66

7-
1. ``make install-pipx``
8-
2. ``make install-hatch``
9-
3. ``make configure-hatch``
10-
4. ``make install``
11-
5. Install `pre-commit <https://pre-commit.com/>`_
12-
6. ``pre-commit install``
7+
1. ``make install``
138

149
Code contributions
1510
------------------
@@ -46,7 +41,7 @@ Guidelines for writing code
4641
Writing and running tests
4742
+++++++++++++++++++++++++
4843

49-
.. todo:: Write this section
44+
Coming soon.
5045

5146
Project documentation
5247
---------------------

README.md

Lines changed: 61 additions & 46 deletions
Large diffs are not rendered by default.

docs/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Sphinx documentation
2+
_build/
3+
.buildinfo
4+
.doctrees/
5+
6+
# Python
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
11+
# Environment
12+
.env
13+
.venv
14+
env/
15+
venv/
16+
ENV/
17+
18+
# IDE
19+
.idea/
20+
.vscode/
21+
*.swp
22+
*.swo
23+
24+
# OS
25+
.DS_Store
26+
Thumbs.db

docs/__init__.py

Whitespace-only changes.

docs/_static/.gitkeep

Whitespace-only changes.

docs/_static/custom.css

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/* Theme color definitions */
2+
:root {
3+
--brand-font-size-xl: 6rem;
4+
--brand-font-size-lg: 5rem;
5+
--brand-font-size-md: 4rem;
6+
--brand-font-size-sm: 2.5rem;
7+
--brand-font-size-xs: 1.8rem;
8+
--brand-font-size-xxs: 1.6rem;
9+
10+
--brand-letter-spacing-xl: 0.25em;
11+
--brand-letter-spacing-lg: 0.2em;
12+
--brand-letter-spacing-md: 0.1em;
13+
--brand-letter-spacing-sm: 0.05em;
14+
--brand-letter-spacing-xs: 0.03em;
15+
}
16+
17+
html.light {
18+
--sl-color-primary: #202235;
19+
--sl-color-secondary: #edb641;
20+
--sl-color-accent: #ffd480;
21+
--sl-color-text-1: var(--sl-color-primary);
22+
--sl-color-text-2: var(--sl-color-secondary);
23+
--sy-c-foot-background: #f0f0f0;
24+
--yue-c-text: #000;
25+
--brand-text-glow: 0 0 10px rgba(32, 34, 53, 0.3),
26+
0 0 20px rgba(32, 34, 53, 0.2), 0 0 30px rgba(237, 182, 65, 0.1);
27+
}
28+
29+
html.dark {
30+
--sl-color-text-1: var(--sl-color-secondary);
31+
--sy-c-foot-background: black;
32+
--yue-c-text: #fff;
33+
--brand-text-glow: 0 0 10px rgba(237, 182, 65, 0.4),
34+
0 0 20px rgba(237, 182, 65, 0.3), 0 0 30px rgba(237, 182, 65, 0.2);
35+
}
36+
37+
.title-with-logo {
38+
display: flex;
39+
align-items: center;
40+
justify-content: center;
41+
margin: 5rem auto 4rem;
42+
width: 100%;
43+
padding: 0 2rem;
44+
user-select: none;
45+
-webkit-user-select: none;
46+
-moz-user-select: none;
47+
-ms-user-select: none;
48+
}
49+
50+
html[class] .title-with-logo .brand-text {
51+
font-family: var(--sl-font-sans);
52+
font-weight: 300;
53+
font-size: var(--brand-font-size-lg);
54+
letter-spacing: var(--brand-letter-spacing-xl);
55+
text-transform: uppercase;
56+
text-align: center;
57+
line-height: 1.4;
58+
max-width: 100%;
59+
word-break: break-word;
60+
word-wrap: break-word;
61+
overflow-wrap: break-word;
62+
hyphens: auto;
63+
-webkit-hyphens: auto;
64+
-ms-hyphens: auto;
65+
transition: color var(--sl-transition), text-shadow var(--sl-transition);
66+
}
67+
68+
html.light .title-with-logo .brand-text {
69+
color: var(--sl-color-text-1);
70+
text-shadow: var(--brand-text-glow);
71+
}
72+
73+
html.dark .title-with-logo .brand-text {
74+
color: var(--sl-color-text-2);
75+
text-shadow: var(--brand-text-glow);
76+
}
77+
78+
/* Button container wrapping */
79+
.buttons.wrap {
80+
display: flex;
81+
flex-wrap: wrap;
82+
gap: 0.5rem;
83+
}
84+
85+
.buttons.wrap .btn-no-wrap {
86+
flex: 0 0 auto;
87+
}
88+
89+
/* Large screens */
90+
@media (min-width: 1200px) {
91+
html[class] .title-with-logo .brand-text {
92+
font-size: var(--brand-font-size-xl);
93+
}
94+
}
95+
96+
/* Medium-small screens */
97+
@media (max-width: 991px) {
98+
html[class] .title-with-logo .brand-text {
99+
font-size: var(--brand-font-size-md);
100+
letter-spacing: var(--brand-letter-spacing-lg);
101+
}
102+
}
103+
104+
/* Small screens */
105+
@media (max-width: 767px) {
106+
html[class] .title-with-logo .brand-text {
107+
font-size: var(--brand-font-size-sm);
108+
letter-spacing: var(--brand-letter-spacing-md);
109+
}
110+
111+
html[class] .title-with-logo {
112+
margin: 2rem auto 1.5rem;
113+
}
114+
}
115+
116+
/* Extra small screens */
117+
@media (max-width: 480px) {
118+
html[class] .title-with-logo .brand-text {
119+
font-size: var(--brand-font-size-xs);
120+
letter-spacing: var(--brand-letter-spacing-sm);
121+
line-height: 1.2;
122+
}
123+
124+
html[class] .title-with-logo {
125+
margin: 1.5rem auto 1rem;
126+
padding: 0 1rem;
127+
}
128+
}
129+
130+
/* Smallest screens */
131+
@media (max-width: 360px) {
132+
html[class] .title-with-logo .brand-text {
133+
font-size: var(--brand-font-size-xxs);
134+
letter-spacing: var(--brand-letter-spacing-xs);
135+
}
136+
}
137+
138+
/* Preserve existing layout styles */
139+
#badges img {
140+
margin-top: 0;
141+
margin-bottom: 0;
142+
}
143+
144+
#badges {
145+
display: flex;
146+
flex-wrap: wrap;
147+
gap: 10px;
148+
margin-bottom: 3em;
149+
}

docs/_static/logo.svg

Lines changed: 9 additions & 0 deletions
Loading

docs/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Changelog
2+
=========
3+
4+
All notable changes to this project will be documented in this file.

docs/conf.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import sys
2+
from datetime import datetime
3+
from pathlib import Path
4+
5+
from pytest_databases.__metadata__ import __project__, __version__
6+
7+
sys.path.insert(0, str(Path("..").resolve()))
8+
9+
10+
# -- Project information -----------------------------------------------------
11+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
12+
current_year = datetime.now().year # noqa: DTZ005
13+
14+
project = __project__
15+
copyright = f"{current_year}, Litestar Organization" # noqa: A001
16+
author = "Litestar Organization"
17+
release = __version__
18+
19+
# -- General configuration ---------------------------------------------------
20+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
21+
22+
extensions = [
23+
"sphinx.ext.autodoc",
24+
"sphinx.ext.napoleon",
25+
"sphinx.ext.intersphinx",
26+
"sphinx.ext.viewcode",
27+
"sphinx.ext.githubpages",
28+
"sphinx_copybutton",
29+
"sphinx_click",
30+
"sphinx_design",
31+
"auto_pytabs.sphinx_ext",
32+
"myst_parser",
33+
"sphinx_autodoc_typehints",
34+
]
35+
36+
templates_path = ["_templates"]
37+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
38+
39+
# -- Options for HTML output -------------------------------------------------
40+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
41+
42+
html_theme = "shibuya"
43+
html_title = "Pytest Databases"
44+
pygments_style = "dracula"
45+
html_static_path = ["_static"]
46+
html_css_files = ["custom.css"]
47+
html_logo = "_static/logo.svg"
48+
html_favicon = "_static/logo.svg" # Optional: use logo as favicon
49+
50+
# Shibuya theme options: https://shibuya.lepture.com/install/
51+
html_theme_options = {
52+
"accent_color": "amber",
53+
"github_url": "https://github.com/litestar-org/pytest-databases",
54+
"discord_url": "https://discord.gg/litestar",
55+
}
56+
57+
# Autodoc settings
58+
autodoc_default_options = {
59+
"members": True,
60+
"member-order": "bysource",
61+
"special-members": "__init__",
62+
"undoc-members": True,
63+
"exclude-members": "__weakref__",
64+
}
65+
66+
# Intersphinx settings
67+
intersphinx_mapping = {
68+
"python": ("https://docs.python.org/3", None),
69+
"pytest": ("https://docs.pytest.org/en/latest", None),
70+
}

docs/contribution-guide.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:orphan:
2+
3+
.. include:: ../CONTRIBUTING.rst

docs/getting-started/basic-usage.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Basic Usage
2+
===========
3+
4+
Once a plugin is enabled (e.g., PostgreSQL), you can use its fixtures directly in your tests. There are typically two main types of fixtures:
5+
6+
1. **Service Fixture** (e.g., `postgres_service`): Provides details about the running database service (host, port, credentials, etc.). Useful for connecting with your own client.
7+
2. **Connection Fixture** (e.g., `postgres_connection`): Provides a ready-to-use connection object (where applicable) to the database service.
8+
9+
.. code-block:: python
10+
11+
# Assuming you have installed pytest-databases[postgres] and enabled the plugin
12+
# Also assuming a client like psycopg is installed: pip install psycopg
13+
import psycopg
14+
from pytest_databases.docker.postgres import PostgresService
15+
16+
# Example using the Service Fixture
17+
def test_connection_with_service_details(postgres_service: PostgresService) -> None:
18+
conn_str = (
19+
f"postgresql://{postgres_service.user}:{postgres_service.password}@"
20+
f"{postgres_service.host}:{postgres_service.port}/{postgres_service.database}"
21+
)
22+
with psycopg.connect(conn_str, autocommit=True) as conn:
23+
with conn.cursor() as cursor:
24+
cursor.execute("SELECT 1")
25+
assert cursor.fetchone() == (1,)
26+
27+
# Example using the Connection Fixture
28+
def test_with_direct_connection(postgres_connection) -> None:
29+
# postgres_connection is often a configured client or connection object
30+
with postgres_connection.cursor() as cursor:
31+
cursor.execute("CREATE TABLE IF NOT EXISTS users (id INT PRIMARY KEY, name TEXT);")
32+
cursor.execute("INSERT INTO users (id, name) VALUES (1, 'Alice');")
33+
cursor.execute("SELECT name FROM users WHERE id = 1;")
34+
assert cursor.fetchone() == ('Alice',)

0 commit comments

Comments
 (0)