Skip to content

Commit 32a3db4

Browse files
committed
Readthedocs build fix
1 parent 353a0f3 commit 32a3db4

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

.github/workflows/docs-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323

2424
- name: Set up poetry
2525
uses: Gr1N/setup-poetry@v9
26+
with:
27+
poetry-version: "2.1.1"
2628

2729
- name: Configure poetry
2830
run: poetry config virtualenvs.in-project true

docs/conf.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1-
import openapi_schema_validator
1+
import sys
2+
from pathlib import Path
3+
import re
4+
5+
ROOT_DIR = Path(__file__).resolve().parents[1]
6+
sys.path.insert(0, str(ROOT_DIR))
7+
8+
9+
def _read_project_version() -> str:
10+
pyproject_path = ROOT_DIR / "pyproject.toml"
11+
pyproject_content = pyproject_path.read_text(encoding="utf-8")
12+
match = re.search(
13+
r"\[tool\.poetry\][\s\S]*?^version\s*=\s*\"([^\"]+)\"",
14+
pyproject_content,
15+
re.MULTILINE,
16+
)
17+
if match is None:
18+
return "unknown"
19+
return match.group(1)
220

321
project = "openapi-schema-validator"
422
copyright = "2023, Artur Maciag"
523
author = "Artur Maciag"
624

7-
release = openapi_schema_validator.__version__
25+
release = _read_project_version()
826

927
extensions = [
1028
"sphinx.ext.autodoc",

0 commit comments

Comments
 (0)