diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7412f89..66e0600 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: trailing-whitespace - id: no-commit-to-branch - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.5 + rev: v0.11.6 hooks: - id: ruff-format args: [ --preview, --config=pyproject.toml ] diff --git a/my_pkg/__init__.py b/my_pkg/__init__.py index baaed07..85345a9 100644 --- a/my_pkg/__init__.py +++ b/my_pkg/__init__.py @@ -1,3 +1,5 @@ +"""Demo init.""" # todo: change to package description. + from importlib.metadata import version -__version__ = version("my-pkg") +__version__ = version("my-pkg") # todo: replace with your package name diff --git a/pyproject.toml b/pyproject.toml index b66eb4c..2f484cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,9 +3,9 @@ name = "my-pkg" # todo: change to your package name dynamic = ["version"] description = "" authors = [ - {name = "DanielAvdar", email = "66269169+DanielAvdar@users.noreply.github.com"}, # todo: change to your name and email + { name = "DanielAvdar", email = "66269169+DanielAvdar@users.noreply.github.com" }, # todo: change to your name and email ] -license = {text = "MIT"} +license = { text = "MIT" } readme = "README.md" classifiers = [ "Programming Language :: Python :: 3", @@ -33,20 +33,19 @@ dev = [ "mypy==1.13.0", "pytest-parametrization>=2022", "ruff>=0.8.2", - + "sybil[pytest]", ] docs = [ - "sybil[pytest]", "sphinx>=8.2.0; python_version >= '3.11'", "sphinx>=7.0.0; python_version < '3.11'", "sphinx-rtd-theme>=3.0.2", ] [tool.hatch.build.targets.sdist] -only-include = ["my_pkg",] # todo: change to your package name +only-include = ["my_pkg", ] # todo: change to your package name source = "." [tool.hatch.build.targets.wheel] -only-include = ["my_pkg",] # todo: change to your package name +only-include = ["my_pkg", ] # todo: change to your package name source = "." @@ -62,13 +61,15 @@ source = "uv-dynamic-versioning" [tool.ruff] line-length = 120 -include = ["pyproject.toml", "tests/**",] +include = ["pyproject.toml", "tests/**", ] [tool.ruff.lint] -select = ["F", "B", "I", "F", "W", "E","A","N"] +select = ["F", "B", "I", "F", "W", "E", "A", "N", "D"] fixable = ["ALL"] - +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["D"] +"docs/*" = ["D"] [tool.ruff.lint.isort] combine-as-imports = true [tool.mypy] diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..c943a66 --- /dev/null +++ b/renovate.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ], + "python": { + "lockFileMaintenance": { + "enabled": true + } + }, + "schedule": [ + "every day" + ], + "packageRules": [ + { + "matchManagers": ["uv"], + "groupName": false + + } + ] +} diff --git a/tests/docs/__init__.py b/tests/docs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/docs/test_docs.py b/tests/docs/test_docs.py new file mode 100644 index 0000000..7a4f463 --- /dev/null +++ b/tests/docs/test_docs.py @@ -0,0 +1,41 @@ +from pathlib import Path + +import pytest +from sybil import Sybil +from sybil.parsers.codeblock import PythonCodeBlockParser +from sybil.parsers.doctest import DocTestParser + + +def collect_examples(folder_name): + docs_folder_path = Path(__file__).parent.parent.parent / "docs" / "source" + models_folder_path = docs_folder_path / folder_name + assert docs_folder_path.exists(), f"Docs path doesn't exist: {docs_folder_path.resolve()}" + + all_rst_files = list(docs_folder_path.glob("*.rst")) + all_rst_files.extend(list(models_folder_path.glob("*.rst"))) + print(f"Found {len(all_rst_files)} .rst files in docs folder.") + # Configure Sybil + sybil = Sybil( + parsers=[ + DocTestParser(), + PythonCodeBlockParser(), + ], + pattern="*.rst", + path=docs_folder_path.as_posix(), + ) + examples_list = [] + for f_path in all_rst_files: + document_ = sybil.parse(f_path) + + examples_ = list(document_) + examples_files = [e.path for e in examples_] + examples_start_lines = [e.start for e in examples_] + + examples_list.extend(zip(examples_files, examples_start_lines, examples_)) + # examples_list=[example for example in examples_] + return examples_list + + +@pytest.mark.parametrize("file_path, line, example", collect_examples("")) +def test_doc_examples(file_path, line, example): + example.evaluate() diff --git a/uv.lock b/uv.lock index 8bbafdb..1a5db80 100644 --- a/uv.lock +++ b/uv.lock @@ -1,10 +1,10 @@ version = 1 revision = 1 -requires-python = ">=3.9, <4" +requires-python = ">=3.9" resolution-markers = [ + "python_full_version >= '3.11'", "python_full_version == '3.10.*'", "python_full_version < '3.10'", - "python_full_version >= '3.11'", ] [[package]] @@ -24,8 +24,8 @@ name = "alabaster" version = "1.0.0" source = { registry = "https://pypi.org/simple" } resolution-markers = [ - "python_full_version == '3.10.*'", "python_full_version >= '3.11'", + "python_full_version == '3.10.*'", ] sdist = { url = "https://files.pythonhosted.org/packages/a6/f8/d9c74d0daf3f742840fd818d69cfae176fa332022fd44e3469487d5a9420/alabaster-1.0.0.tar.gz", hash = "sha256:c00dca57bca26fa62a6d7d0a9fcce65f3e026e9bfe33e9c538fd3fbb2144fd9e", size = 24210 } wheels = [ @@ -418,13 +418,13 @@ dev = [ { name = "pytest-cov" }, { name = "pytest-parametrization" }, { name = "ruff" }, + { name = "sybil", extra = ["pytest"] }, ] docs = [ { name = "sphinx", version = "7.4.7", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, { name = "sphinx", version = "8.1.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.10.*'" }, { name = "sphinx", version = "8.2.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, { name = "sphinx-rtd-theme" }, - { name = "sybil", extra = ["pytest"] }, ] [package.metadata] @@ -439,12 +439,12 @@ dev = [ { name = "pytest-cov", specifier = ">=4.0.0" }, { name = "pytest-parametrization", specifier = ">=2022" }, { name = "ruff", specifier = ">=0.8.2" }, + { name = "sybil", extras = ["pytest"] }, ] docs = [ { name = "sphinx", marker = "python_full_version < '3.11'", specifier = ">=7.0.0" }, { name = "sphinx", marker = "python_full_version >= '3.11'", specifier = ">=8.2.0" }, { name = "sphinx-rtd-theme", specifier = ">=3.0.2" }, - { name = "sybil", extras = ["pytest"] }, ] [[package]]