From af24b2f1883e9095401b40bd3a96b762ed34755a Mon Sep 17 00:00:00 2001 From: "h.nejati" Date: Sun, 22 Nov 2026 14:01:15 +0330 Subject: [PATCH 1/4] docs: use native Zensical configuration --- .cursor/rules/documentation.mdc | 6 +- .cursor/rules/tooling-workflow.mdc | 5 +- .github/workflows/deploy-docs.yml | 7 +- .github/workflows/docs-check.yml | 3 +- .github/workflows/tests.yml | 4 +- .pre-commit-config.yaml | 1 - .readthedocs.yaml | 4 +- Makefile | 33 ++--- README.md | 20 +-- docs/404.md | 22 --- docs/community/contributing.md | 9 +- mkdocs-fast.yml | 24 ---- mkdocs-full.yml | 22 --- mkdocs.yml | 217 ---------------------------- overrides/404.html | 17 +++ zensical.toml | 221 +++++++++++++++++++++++++++++ 16 files changed, 269 insertions(+), 346 deletions(-) delete mode 100644 docs/404.md delete mode 100644 mkdocs-fast.yml delete mode 100644 mkdocs-full.yml delete mode 100644 mkdocs.yml create mode 100644 overrides/404.html create mode 100644 zensical.toml diff --git a/.cursor/rules/documentation.mdc b/.cursor/rules/documentation.mdc index e71202d60..69498c49a 100644 --- a/.cursor/rules/documentation.mdc +++ b/.cursor/rules/documentation.mdc @@ -1,5 +1,5 @@ --- -description: Documentation standards for ArchiPy MkDocs pages +description: Documentation standards for ArchiPy Zensical pages globs: docs/**/*.md alwaysApply: false --- @@ -91,7 +91,7 @@ def get_item(key: str) -> str | None: When documenting a new adapter, create **both** files: -- `docs/examples/adapters/.md` โ€” example guide with all 5 required sections +- `docs/tutorials/adapters/.md` โ€” example guide with all 5 required sections - `docs/api_reference/adapters/.md` โ€” API reference with mkdocstrings directives -Then add both entries under the appropriate `nav:` keys in `mkdocs.yml`. +Then add both pages to the appropriate sections of the `nav` array in `zensical.toml`. diff --git a/.cursor/rules/tooling-workflow.mdc b/.cursor/rules/tooling-workflow.mdc index f08080351..f65e973df 100644 --- a/.cursor/rules/tooling-workflow.mdc +++ b/.cursor/rules/tooling-workflow.mdc @@ -61,10 +61,9 @@ uv run pre-commit run --all-files ## Documentation ```bash -make docs-serve # Live-reload local server (balanced) -make docs-serve-fast # Fast rebuild (skip heavy API gen) +make docs-serve # Live-reload local server make docs-build # Build static site -make docs-deploy # Deploy to GitHub Pages +make docs-check # Clean, strict production build ``` ## Dependency Updates diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 8312343ed..d4204f436 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -7,16 +7,17 @@ on: - docs paths: - 'docs/**' + - 'overrides/**' - 'archipy/**' - 'packages/**' - - 'mkdocs*.yml' + - 'zensical.toml' - 'pyproject.toml' - 'uv.lock' - '.python-version' - '.github/workflows/deploy-docs.yml' pull_request: paths: - - 'mkdocs*.yml' + - 'zensical.toml' - '.python-version' - '.github/workflows/deploy-docs.yml' @@ -37,7 +38,7 @@ jobs: run: uv sync --locked --group docs - name: Build documentation - run: uv run --no-sync zensical build --clean -f mkdocs-full.yml + run: uv run --no-sync zensical build --clean --strict - name: Upload Pages artifact uses: actions/upload-pages-artifact@v5 diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 0b9f5599c..307195519 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -5,7 +5,8 @@ on: branches: [ '*' ] paths: - 'docs/**' - - 'mkdocs*.yml' + - 'overrides/**' + - 'zensical.toml' - 'archipy/**' - 'packages/**' - 'pyproject.toml' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 44ba187d7..4547a891a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -180,8 +180,8 @@ jobs: - '!.claude/**' - '!.idea/**' - '!LICENSE' - - '!mkdocs.yml' - - '!mkdocs-*.yml' + - '!overrides/**' + - '!zensical.toml' - '!.github/ISSUE_TEMPLATE/**' - '!.github/workflows/{close-stale-issues,deploy-docs,dependency-review,docs-check,instrumentor-compat,labeler,link-check,pr-merged-issue-comment,publish,ruff-lint,ty-lint}.yml' - '!.github/labeler.yml' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 28c13b4a9..9d6ad6848 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,6 @@ repos: entry: uv run check-yaml types: - yaml - exclude: ^mkdocs language: system - id: check-toml name: check-toml diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 667cab10c..7c570198b 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -13,9 +13,7 @@ build: curl -fsSL https://astral.sh/uv/0.13.9/install.sh -o /tmp/archipy-uv-install.sh && UV_UNMANAGED_INSTALL="$HOME/.local/bin" sh /tmp/archipy-uv-install.sh - '"$HOME/.local/bin/uv" sync --python 3.15 --locked --group docs' - - >- - "$HOME/.local/bin/uv" run --python 3.15 --no-sync zensical build - -f mkdocs.yml + - '"$HOME/.local/bin/uv" run --python 3.15 --no-sync zensical build --clean --strict' - mkdir -p "$READTHEDOCS_OUTPUT/html" && cp -a site/. "$READTHEDOCS_OUTPUT/html/" search: diff --git a/Makefile b/Makefile index fecf49611..e5265f734 100644 --- a/Makefile +++ b/Makefile @@ -231,44 +231,27 @@ check-mr: ## Run pre-commit only on files changed vs BASE (default master), e.g. $(PRE_COMMIT) run --files $$CHANGED .PHONY: docs-serve -docs-serve: ## Serve Zensical documentation locally (balanced mode) +docs-serve: ## Preview documentation locally with live reload @echo "${BLUE}Serving documentation...${NC}" - $(UV) run --group docs zensical serve -f mkdocs.yml - -.PHONY: docs-serve-fast -docs-serve-fast: ## Serve Zensical documentation with fast build (for quick iterations) - @echo "${BLUE}Serving documentation (fast mode)...${NC}" - $(UV) run --group docs zensical serve -f mkdocs-fast.yml - -.PHONY: docs-serve-no-api -docs-serve-no-api: ## Serve Zensical documentation without API auto-generation (fastest) - @echo "${BLUE}Serving documentation (no API generation)...${NC}" - ENABLE_MKDOCSTRINGS=false $(UV) run --group docs zensical serve -f mkdocs.yml + $(UV) run --group docs zensical serve .PHONY: docs-build -docs-build: ## Build Zensical documentation (balanced mode) +docs-build: ## Build the static documentation site @echo "${BLUE}Building documentation...${NC}" - $(UV) run --group docs zensical build -f mkdocs.yml + $(UV) run --group docs zensical build .PHONY: docs-check -docs-check: ## Build the docs in strict mode: broken links and API reference errors fail +docs-check: ## Run a clean, strict documentation build @echo "${BLUE}Checking documentation...${NC}" - $(UV) run --group docs zensical build --strict -f mkdocs.yml - -.PHONY: docs-build-fast -docs-build-fast: ## Build Zensical documentation with fast config - @echo "${BLUE}Building documentation (fast mode)...${NC}" - $(UV) run --group docs zensical build -f mkdocs-fast.yml + $(UV) run --group docs zensical build --clean --strict .PHONY: docs-build-full -docs-build-full: ## Build Zensical documentation with full features (for production) - @echo "${BLUE}Building documentation (full mode)...${NC}" - $(UV) run --group docs zensical build -f mkdocs-full.yml --clean +docs-build-full: docs-check ## Build the production site .PHONY: docs-time docs-time: ## Time the documentation build @echo "${BLUE}Timing documentation build...${NC}" - time $(UV) run --group docs zensical build -f mkdocs.yml + time $(UV) run --group docs zensical build .PHONY: docs-deploy docs-deploy: ## Documentation deploys from CI, not locally diff --git a/README.md b/README.md index ca98e2f92..63fa85c38 100644 --- a/README.md +++ b/README.md @@ -180,13 +180,7 @@ Support ArchiPy by checking out our amazing sponsors! [View Sponsors](SPONSORS.m ## ๐Ÿ“š Documentation -ArchiPy's documentation has been built with Zensical for improved readability and organization: - -- **Modern Interface**: Responsive theme with responsive design -- **Improved Navigation**: Intuitive organization and search -- **Clearer Examples**: Expanded code samples with explanations -- **API Reference**: Auto-generated from source code docstrings -- **Performance Optimized**: Multiple build modes for fast iteration +Zensical builds the documentation with the navigation and API reference settings in `zensical.toml`. ### Quick Start @@ -194,17 +188,11 @@ ArchiPy's documentation has been built with Zensical for improved readability an # Install documentation dependencies uv sync --group docs -# Fast mode for quick iterations (10-20s builds) -make docs-serve-fast - -# Balanced mode for regular work (30-60s builds) +# Preview the docs with live reload make docs-serve -# Full production build (2-5min, all features) -make docs-build-full - -# Deploy to GitHub Pages -make docs-deploy +# Run the same clean, strict build as CI +make docs-check ``` **See [the quickstart](https://syntaxarc.github.io/ArchiPy/getting-started/quickstart/) for more commands and tips.** diff --git a/docs/404.md b/docs/404.md deleted file mode 100644 index 709424f4a..000000000 --- a/docs/404.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: Page Not Found -description: The requested page could not be found. Navigate to the ArchiPy documentation home. ---- - -# Page Not Found - -The page you were looking for does not exist. - -It may have been moved, renamed, or deleted. - -## Find What You Need - -- [Get Started](index.md) โ€” overview and quick example -- [Installation](getting-started/installation.md) โ€” install ArchiPy and optional extras -- [Quickstart](getting-started/quickstart.md) โ€” five-minute step-by-step guide -- [Concepts](getting-started/concepts.md) โ€” Clean Architecture layers and import rules -- [Tutorials](tutorials/index.md) โ€” guides for every adapter and helper -- [API Reference](api_reference/index.md) โ€” full reference for all public classes -- [FAQ](community/faq.md) โ€” frequently asked questions - -> **Tip:** Use the search bar at the top of the page to find any topic instantly. diff --git a/docs/community/contributing.md b/docs/community/contributing.md index d811fc20d..9ca35da28 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -230,7 +230,7 @@ New adapters follow a consistent checklist. Use this as your guide when contribu - `docs/tutorials/adapters/.md` โ€” example guide (5 required sections) - `docs/api_reference/adapters/.md` โ€” API reference with mkdocstrings -8. **Update `mkdocs.yml`** โ€” add both new pages under the appropriate `nav:` keys. +8. **Update `zensical.toml`** by adding both pages to the appropriate sections of the `nav` array. > **Note:** Use the [GitHub issue templates](https://github.com/SyntaxArc/ArchiPy/issues/new/choose) when reporting > bugs, requesting features, or proposing new adapters. @@ -249,7 +249,8 @@ This section outlines the standards and practices for ArchiPy documentation. ### Documentation Structure -- `mkdocs.yml` - Main [Zensical](https://zensical.org) configuration file (`mkdocs-fast.yml` and `mkdocs-full.yml` override it) +- `zensical.toml` defines the site, navigation, theme, and API reference. [Zensical configuration](https://zensical.org/docs/setup/basics/) +- `overrides/404.html` defines the page visitors see for missing URLs. [Zensical theme overrides](https://zensical.org/docs/customization/#custom-error-pages) - `docs/` - Markdown documentation files - `index.md` - Get Started page - `api_reference/` - API documentation @@ -304,13 +305,13 @@ Build the documentation: make docs-build ``` -Check the build in strict mode (broken links and API reference errors fail): +Run the clean, strict build used by CI: ```bash make docs-check ``` -The `deploy-docs` workflow publishes to GitHub Pages on every push to `master`. +GitHub Pages deploys when documentation or API sources change on `master`. Read the Docs builds from the same configuration. ### Documentation Improvement Guidelines diff --git a/mkdocs-fast.yml b/mkdocs-fast.yml deleted file mode 100644 index 31dd924e2..000000000 --- a/mkdocs-fast.yml +++ /dev/null @@ -1,24 +0,0 @@ -# Fast build configuration for local development -# Use this for quick iterations: zensical serve -f mkdocs-fast.yml -# Plugin settings are merged over mkdocs.yml: only the differences are listed here. - -INHERIT: ./mkdocs.yml - -plugins: - mkdocstrings: - enabled: true - handlers: - python: - options: - # Maximum performance for local dev - show_source: false - show_root_toc_entry: false - heading_level: 3 - members_order: alphabetical - show_signature_annotations: false - separate_signature: false - filters: - - "!^_" - - "!^__" - members: false # Don't auto-document members - docstring_section_style: list # Faster than table diff --git a/mkdocs-full.yml b/mkdocs-full.yml deleted file mode 100644 index 66cf1e2a5..000000000 --- a/mkdocs-full.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Full documentation build with all features -# Use this for production builds: zensical build -f mkdocs-full.yml -# Plugin settings are merged over mkdocs.yml: only the differences are listed here. - -INHERIT: ./mkdocs.yml - -plugins: - mkdocstrings: - enabled: true - handlers: - python: - options: - # Full documentation features - show_object_full_path: true - filters: - - "!^_" - show_submodules: true - show_bases: true - summary: false # Full documentation - show_if_no_docstring: true - inherited_members: true # Show inherited members in production - docstring_section_style: table diff --git a/mkdocs.yml b/mkdocs.yml deleted file mode 100644 index 2a44720a1..000000000 --- a/mkdocs.yml +++ /dev/null @@ -1,217 +0,0 @@ -site_name: ArchiPy -site_url: https://syntaxarc.github.io/ArchiPy/ -site_description: Architecture + Python โ€“ Structured Development Simplified -site_author: Hossein Nejati, Mehdi Einali -repo_url: https://github.com/SyntaxArc/ArchiPy -repo_name: SyntaxArc/ArchiPy -edit_uri: edit/master/docs/ - -# Directory configuration -docs_dir: docs -site_dir: site - -# Copyright -copyright: Copyright © 2025-2026 Hossein Nejati, Mehdi Einali - -# Theme configuration -theme: - variant: classic - language: en - palette: - # Palette toggle for light mode - - media: "(prefers-color-scheme: light)" - scheme: default - primary: blue - accent: indigo - toggle: - icon: material/weather-night - name: Switch to dark mode - # Palette toggle for dark mode - - media: "(prefers-color-scheme: dark)" - scheme: slate - primary: blue - accent: indigo - toggle: - icon: material/weather-sunny - name: Switch to light mode - features: - - navigation.instant - - navigation.instant.prefetch # Prefetch pages for faster navigation - - navigation.instant.progress # Show loading progress - - navigation.tracking - - navigation.tabs - - navigation.tabs.sticky - - navigation.sections - - navigation.expand - - navigation.indexes - - toc.follow - - content.code.copy - - content.tabs.link - - content.action.edit - - navigation.top - - search.highlight - - content.code.annotate - - content.tooltips - icon: - repo: fontawesome/brands/github - logo: assets/logo.jpg - favicon: assets/logo.jpg - -# Customization -extra: - social: - - icon: fontawesome/brands/github - link: https://github.com/SyntaxArc/ArchiPy - -# Extensions -markdown_extensions: - - admonition - - attr_list - - def_list - - footnotes - - md_in_html - - toc: - permalink: true - - pymdownx.highlight: - anchor_linenums: true - line_spans: __span - pygments_lang_class: true - - pymdownx.inlinehilite - - pymdownx.snippets - - pymdownx.superfences - - pymdownx.tabbed: - alternate_style: true - - pymdownx.tasklist: - custom_checkbox: true - - pymdownx.emoji: - emoji_index: !!python/name:zensical.extensions.emoji.twemoji - emoji_generator: !!python/name:zensical.extensions.emoji.to_svg - - # Plugins -plugins: - search: { } - autorefs: { } - mkdocstrings: - enabled: !ENV [ ENABLE_MKDOCSTRINGS, true ] - default_handler: python - handlers: - python: - paths: [ ".", "packages/elasticsearch", "packages/kafka", "packages/keycloak", "packages/minio", "packages/mysql", "packages/parsian-ipg", "packages/postgres", "packages/redis", "packages/saman-ipg", "packages/scylladb", "packages/sqlite", "packages/starrocks", "packages/temporal", "packages/vault" ] - options: - # Performance optimizations - show_source: true # Show source code in API reference pages - show_root_toc_entry: true - show_object_full_path: false # Changed: Shorter paths = faster rendering - heading_level: 2 - members_order: source - docstring_style: google - # Additional performance settings - show_submodules: false # Changed: Don't auto-expand submodules - show_bases: false # Changed: Don't show base classes - show_signature_annotations: true - separate_signature: true - # Filtering to reduce content - filters: - - "!^_" # Exclude private members - - "!^__pycache__" - # Summary mode for better performance - summary: true # Show brief summaries instead of full docs - show_if_no_docstring: false # Skip undocumented items - # Inheritance settings - inherited_members: false # Don't show inherited members (big performance gain) - -# Navigation -nav: - - Get Started: - - Overview: index.md - - Installation: getting-started/installation.md - - Quickstart: getting-started/quickstart.md - - Concepts: getting-started/concepts.md - - Project Structure: getting-started/project_structure.md - - Complete Example: getting-started/complete_user_example.md - - Tutorials: - - Overview: tutorials/index.md - - Adapters: - - Overview: tutorials/adapters/index.md - - Redis: tutorials/adapters/redis.md - - PostgreSQL: tutorials/adapters/postgres.md - - MySQL: tutorials/adapters/mysql.md - - SQLite: tutorials/adapters/sqlite.md - - StarRocks: tutorials/adapters/starrocks.md - - SQLAlchemy Search Totals: tutorials/adapters/sqlalchemy.md - - Kafka: tutorials/adapters/kafka.md - - Keycloak: tutorials/adapters/keycloak.md - - MinIO: tutorials/adapters/minio.md - - ScyllaDB: tutorials/adapters/scylladb.md - - Elasticsearch: tutorials/adapters/elasticsearch.md - - Elasticsearch Patterns: tutorials/adapters/elasticsearch_patterns.md - - Temporal: tutorials/adapters/temporal.md - - Vault: tutorials/adapters/vault.md - - Email: tutorials/adapters/email.md - - Payment Gateways: tutorials/adapters/payment_gateways.md - - Helpers: - - Overview: tutorials/helpers/index.md - - Decorators: tutorials/helpers/decorators.md - - Interceptors: tutorials/helpers/interceptors.md - - Metaclasses: tutorials/helpers/metaclasses.md - - Utils: tutorials/helpers/utils.md - - Configuration: tutorials/config_management.md - - BDD Testing: tutorials/testing_strategy.md - - Error Handling: tutorials/error_handling.md - - Dependency Injection: tutorials/dependency_injection.md - - Observability: tutorials/observability.md - - Caching: tutorials/cache.md - - Scheduler: tutorials/scheduler.md - - Health Checks and Shutdown: tutorials/health_checks.md - - Pydantic AI: tutorials/pydantic_ai.md - - Models: - - Protobuf DTOs: tutorials/models/protobuf_dtos.md - - API Reference: - - Overview: api_reference/index.md - - Adapters: - - Overview: api_reference/adapters/index.md - - Base SQLAlchemy: api_reference/adapters/base.md - - Redis: api_reference/adapters/redis.md - - PostgreSQL: api_reference/adapters/postgres.md - - MySQL: api_reference/adapters/mysql.md - - SQLite: api_reference/adapters/sqlite.md - - StarRocks: api_reference/adapters/starrocks.md - - Kafka: api_reference/adapters/kafka.md - - Keycloak: api_reference/adapters/keycloak.md - - MinIO: api_reference/adapters/minio.md - - ScyllaDB: api_reference/adapters/scylladb.md - - Elasticsearch: api_reference/adapters/elasticsearch.md - - Temporal: api_reference/adapters/temporal.md - - Vault: api_reference/adapters/vault.md - - Email: api_reference/adapters/email.md - - Payment Gateways: api_reference/adapters/payment_gateways.md - - Configs: api_reference/configs.md - - Helpers: - - Overview: api_reference/helpers/index.md - - Decorators: api_reference/helpers/decorators.md - - Errors: api_reference/helpers/errors.md - - Interceptors: api_reference/helpers/interceptors.md - - Metaclasses: api_reference/helpers/metaclasses.md - - Utils: api_reference/helpers/utils.md - - Models: - - Overview: api_reference/models/index.md - - DTOs: api_reference/models/dtos.md - - Entities: api_reference/models/entities.md - - Errors: api_reference/models/errors.md - - Types: api_reference/models/types.md - - Community: - - Contributing: community/contributing.md - - Code of Conduct: community/code_of_conduct.md - - FAQ: community/faq.md - - Upgrade to ArchiPy 6.0: community/deprecations.md - - Security: community/security.md - - Changelog: - - Overview: community/changelog/index.md - - "6.x": community/changelog/6/index.md - - "5.x": community/changelog/5/index.md - - "4.x": community/changelog/4/index.md - - "3.x": community/changelog/3/index.md - - "2.x": community/changelog/2/index.md - - "1.x": community/changelog/1/index.md - - "0.x": community/changelog/0/index.md - - License: community/license.md diff --git a/overrides/404.html b/overrides/404.html new file mode 100644 index 000000000..317cacd59 --- /dev/null +++ b/overrides/404.html @@ -0,0 +1,17 @@ +{% extends "main.html" %} + +{% block content %} +

Page Not Found

+

The requested page may have moved or been removed.

+

Find What You Need

+ +

Use the search bar to find a specific topic.

+{% endblock %} diff --git a/zensical.toml b/zensical.toml new file mode 100644 index 000000000..3cf1fe2f5 --- /dev/null +++ b/zensical.toml @@ -0,0 +1,221 @@ +[project] +site_name = "ArchiPy" +site_url = "https://syntaxarc.github.io/ArchiPy/" +site_description = "Architecture + Python โ€“ Structured Development Simplified" +site_author = "Hossein Nejati, Mehdi Einali" +repo_url = "https://github.com/SyntaxArc/ArchiPy" +repo_name = "SyntaxArc/ArchiPy" +edit_uri = "edit/master/docs/" +copyright = "Copyright © 2025-2026 Hossein Nejati, Mehdi Einali" + +nav = [ + { "Get Started" = [ + { "Overview" = "index.md" }, + { "Installation" = "getting-started/installation.md" }, + { "Quickstart" = "getting-started/quickstart.md" }, + { "Concepts" = "getting-started/concepts.md" }, + { "Project Structure" = "getting-started/project_structure.md" }, + { "Complete Example" = "getting-started/complete_user_example.md" }, + ] }, + { "Tutorials" = [ + { "Overview" = "tutorials/index.md" }, + { "Adapters" = [ + { "Overview" = "tutorials/adapters/index.md" }, + { "Redis" = "tutorials/adapters/redis.md" }, + { "PostgreSQL" = "tutorials/adapters/postgres.md" }, + { "MySQL" = "tutorials/adapters/mysql.md" }, + { "SQLite" = "tutorials/adapters/sqlite.md" }, + { "StarRocks" = "tutorials/adapters/starrocks.md" }, + { "SQLAlchemy Search Totals" = "tutorials/adapters/sqlalchemy.md" }, + { "Kafka" = "tutorials/adapters/kafka.md" }, + { "Keycloak" = "tutorials/adapters/keycloak.md" }, + { "MinIO" = "tutorials/adapters/minio.md" }, + { "ScyllaDB" = "tutorials/adapters/scylladb.md" }, + { "Elasticsearch" = "tutorials/adapters/elasticsearch.md" }, + { "Elasticsearch Patterns" = "tutorials/adapters/elasticsearch_patterns.md" }, + { "Temporal" = "tutorials/adapters/temporal.md" }, + { "Vault" = "tutorials/adapters/vault.md" }, + { "Email" = "tutorials/adapters/email.md" }, + { "Payment Gateways" = "tutorials/adapters/payment_gateways.md" }, + ] }, + { "Helpers" = [ + { "Overview" = "tutorials/helpers/index.md" }, + { "Decorators" = "tutorials/helpers/decorators.md" }, + { "Interceptors" = "tutorials/helpers/interceptors.md" }, + { "Metaclasses" = "tutorials/helpers/metaclasses.md" }, + { "Utils" = "tutorials/helpers/utils.md" }, + ] }, + { "Configuration" = "tutorials/config_management.md" }, + { "BDD Testing" = "tutorials/testing_strategy.md" }, + { "Error Handling" = "tutorials/error_handling.md" }, + { "Dependency Injection" = "tutorials/dependency_injection.md" }, + { "Observability" = "tutorials/observability.md" }, + { "Caching" = "tutorials/cache.md" }, + { "Scheduler" = "tutorials/scheduler.md" }, + { "Health Checks and Shutdown" = "tutorials/health_checks.md" }, + { "Pydantic AI" = "tutorials/pydantic_ai.md" }, + { "Models" = [ + { "Protobuf DTOs" = "tutorials/models/protobuf_dtos.md" }, + ] }, + ] }, + { "API Reference" = [ + { "Overview" = "api_reference/index.md" }, + { "Adapters" = [ + { "Overview" = "api_reference/adapters/index.md" }, + { "Base SQLAlchemy" = "api_reference/adapters/base.md" }, + { "Redis" = "api_reference/adapters/redis.md" }, + { "PostgreSQL" = "api_reference/adapters/postgres.md" }, + { "MySQL" = "api_reference/adapters/mysql.md" }, + { "SQLite" = "api_reference/adapters/sqlite.md" }, + { "StarRocks" = "api_reference/adapters/starrocks.md" }, + { "Kafka" = "api_reference/adapters/kafka.md" }, + { "Keycloak" = "api_reference/adapters/keycloak.md" }, + { "MinIO" = "api_reference/adapters/minio.md" }, + { "ScyllaDB" = "api_reference/adapters/scylladb.md" }, + { "Elasticsearch" = "api_reference/adapters/elasticsearch.md" }, + { "Temporal" = "api_reference/adapters/temporal.md" }, + { "Vault" = "api_reference/adapters/vault.md" }, + { "Email" = "api_reference/adapters/email.md" }, + { "Payment Gateways" = "api_reference/adapters/payment_gateways.md" }, + ] }, + { "Configs" = "api_reference/configs.md" }, + { "Helpers" = [ + { "Overview" = "api_reference/helpers/index.md" }, + { "Decorators" = "api_reference/helpers/decorators.md" }, + { "Errors" = "api_reference/helpers/errors.md" }, + { "Interceptors" = "api_reference/helpers/interceptors.md" }, + { "Metaclasses" = "api_reference/helpers/metaclasses.md" }, + { "Utils" = "api_reference/helpers/utils.md" }, + ] }, + { "Models" = [ + { "Overview" = "api_reference/models/index.md" }, + { "DTOs" = "api_reference/models/dtos.md" }, + { "Entities" = "api_reference/models/entities.md" }, + { "Errors" = "api_reference/models/errors.md" }, + { "Types" = "api_reference/models/types.md" }, + ] }, + ] }, + { "Community" = [ + { "Contributing" = "community/contributing.md" }, + { "Code of Conduct" = "community/code_of_conduct.md" }, + { "FAQ" = "community/faq.md" }, + { "Upgrade to ArchiPy 6.0" = "community/deprecations.md" }, + { "Security" = "community/security.md" }, + { "Changelog" = [ + { "Overview" = "community/changelog/index.md" }, + { "6.x" = "community/changelog/6/index.md" }, + { "5.x" = "community/changelog/5/index.md" }, + { "4.x" = "community/changelog/4/index.md" }, + { "3.x" = "community/changelog/3/index.md" }, + { "2.x" = "community/changelog/2/index.md" }, + { "1.x" = "community/changelog/1/index.md" }, + { "0.x" = "community/changelog/0/index.md" }, + ] }, + { "License" = "community/license.md" }, + ] }, +] + +[project.theme] +variant = "classic" +language = "en" +custom_dir = "overrides" +logo = "assets/logo.jpg" +favicon = "assets/logo.jpg" +features = [ + "navigation.instant", + "navigation.instant.prefetch", + "navigation.instant.progress", + "navigation.tracking", + "navigation.tabs", + "navigation.tabs.sticky", + "navigation.sections", + "navigation.expand", + "navigation.indexes", + "toc.follow", + "content.code.copy", + "content.tabs.link", + "content.action.edit", + "navigation.top", + "search.highlight", + "content.code.annotate", + "content.tooltips", +] + +[project.theme.icon] +repo = "fontawesome/brands/github" + +[[project.theme.palette]] +media = "(prefers-color-scheme: light)" +scheme = "default" +primary = "blue" +accent = "indigo" +toggle = { icon = "material/weather-night", name = "Switch to dark mode" } + +[[project.theme.palette]] +media = "(prefers-color-scheme: dark)" +scheme = "slate" +primary = "blue" +accent = "indigo" +toggle = { icon = "material/weather-sunny", name = "Switch to light mode" } + +[[project.extra.social]] +icon = "fontawesome/brands/github" +link = "https://github.com/SyntaxArc/ArchiPy" + +[project.markdown_extensions] +admonition = {} +attr_list = {} +def_list = {} +footnotes = {} +md_in_html = {} +toc.permalink = true +pymdownx.highlight.anchor_linenums = true +pymdownx.highlight.line_spans = "__span" +pymdownx.highlight.pygments_lang_class = true +pymdownx.inlinehilite = {} +pymdownx.snippets = {} +pymdownx.superfences = {} +pymdownx.tabbed.alternate_style = true +pymdownx.tasklist.custom_checkbox = true +pymdownx.emoji.emoji_index = "zensical.extensions.emoji.twemoji" +pymdownx.emoji.emoji_generator = "zensical.extensions.emoji.to_svg" + +[project.plugins.search] + +[project.plugins.autorefs] + +[project.plugins.mkdocstrings.handlers.python] +paths = [ + ".", + "packages/elasticsearch", + "packages/kafka", + "packages/keycloak", + "packages/minio", + "packages/mysql", + "packages/parsian-ipg", + "packages/postgres", + "packages/redis", + "packages/saman-ipg", + "packages/scylladb", + "packages/sqlite", + "packages/starrocks", + "packages/temporal", + "packages/vault", +] + +[project.plugins.mkdocstrings.handlers.python.options] +docstring_style = "google" +docstring_section_style = "table" +filters = ["!^_"] +heading_level = 2 +inherited_members = true +members_order = "source" +separate_signature = true +show_bases = true +show_if_no_docstring = true +show_object_full_path = true +show_root_toc_entry = true +show_signature_annotations = true +show_source = true +show_submodules = true +summary = false From a2260c412d6fe6171cb54aa20a1236aeb81c05b7 Mon Sep 17 00:00:00 2001 From: "h.nejati" Date: Sun, 22 Nov 2026 14:08:49 +0330 Subject: [PATCH 2/4] docs: fix build warnings and legacy links --- docs/community/contributing.md | 2 +- .../keycloak/_protocols/authzen/adapter.py | 6 ++- .../keycloak/_protocols/oidc/adapter.py | 20 ++++---- .../_resources/attack_detection/adapter.py | 6 --- .../_resources/authentication/adapter.py | 24 ---------- .../client_initial_access/adapter.py | 6 --- .../client_registration_policy/adapter.py | 6 --- .../keycloak/_resources/keys/adapter.py | 6 --- .../_resources/required_actions/adapter.py | 12 ----- .../keycloak/_resources/users/adapter.py | 12 ----- zensical.toml | 46 +++++++++++++++++++ 11 files changed, 63 insertions(+), 83 deletions(-) diff --git a/docs/community/contributing.md b/docs/community/contributing.md index 9ca35da28..84838da3f 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -272,7 +272,7 @@ When including code examples: 1. Include proper type hints using Python 3.14 syntax (`x: list[str]` not `List[str]`) 2. Demonstrate proper error handling with exception chaining -3. Include docstrings with Args, Returns, and Raises sections +3. Use Google-style docstrings. Include Args, Returns, and Raises sections where applicable. 4. Show realistic use cases that align with ArchiPy's patterns 5. Keep examples concise but complete enough to understand usage diff --git a/packages/keycloak/archipy/adapters/keycloak/_protocols/authzen/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_protocols/authzen/adapter.py index 9c15f4db3..1e19fba52 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_protocols/authzen/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_protocols/authzen/adapter.py @@ -27,7 +27,8 @@ def get_authzen_configuration(self) -> KeycloakAuthzenConfigurationDTO: The decision point and the evaluation endpoints. Raises: - Mapped application errors; ``ResourceNotFoundError`` when the server's ``authzen`` feature is off. + ResourceNotFoundError: If the realm does not expose AuthZEN discovery. + BaseError: If the discovery request fails for another reason. """ return to_dto( KeycloakAuthzenConfigurationDTO, @@ -99,7 +100,8 @@ async def get_authzen_configuration(self) -> KeycloakAuthzenConfigurationDTO: The decision point and the evaluation endpoints. Raises: - Mapped application errors; ``ResourceNotFoundError`` when the server's ``authzen`` feature is off. + ResourceNotFoundError: If the realm does not expose AuthZEN discovery. + BaseError: If the discovery request fails for another reason. """ return to_dto( KeycloakAuthzenConfigurationDTO, diff --git a/packages/keycloak/archipy/adapters/keycloak/_protocols/oidc/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_protocols/oidc/adapter.py index a54b91828..37c088bed 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_protocols/oidc/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_protocols/oidc/adapter.py @@ -363,7 +363,7 @@ def exchange_token( Token response Raises: - Various application errors mapped from the Keycloak response (e.g. when exchange is not permitted). + BaseError: If Keycloak rejects the token exchange or the request fails. """ try: return to_dto_or_none( @@ -515,7 +515,7 @@ def token_exchange(self, request: KeycloakTokenExchangeRequestDTO) -> KeycloakTo The issued token and its type. Raises: - Mapped application errors when the exchange is not permitted or the request is invalid. + BaseError: If Keycloak rejects the token exchange or the request fails. """ return to_dto( KeycloakTokenExchangeResponseDTO, @@ -539,7 +539,7 @@ def jwt_bearer_grant(self, assertion: str, scope: str | None = None) -> Keycloak The access token. Keycloak issues no refresh token for this grant. Raises: - Mapped application errors when the assertion or the client setup is rejected. + BaseError: If Keycloak rejects the assertion or client configuration, or the request fails. """ return to_dto( KeycloakTokenDTO, @@ -568,7 +568,9 @@ def request_rpt(self, token: str, audience: str, permissions: list[str] | None = The RPT in ``access_token``. Raises: - Mapped application errors; ``InsufficientPermissionsError`` when no requested permission is granted. + InsufficientPermissionsError: If Keycloak denies the request, including when it grants no requested + permissions. + BaseError: If the request fails for another reason. """ form: dict[str, Any] = {"grant_type": UMA_TICKET_GRANT, "audience": audience} if permissions: @@ -804,7 +806,7 @@ async def exchange_token( Token response Raises: - Various application errors mapped from the Keycloak response (e.g. when exchange is not permitted). + BaseError: If Keycloak rejects the token exchange or the request fails. """ try: return to_dto_or_none( @@ -956,7 +958,7 @@ async def token_exchange(self, request: KeycloakTokenExchangeRequestDTO) -> Keyc The issued token and its type. Raises: - Mapped application errors when the exchange is not permitted or the request is invalid. + BaseError: If Keycloak rejects the token exchange or the request fails. """ return to_dto( KeycloakTokenExchangeResponseDTO, @@ -980,7 +982,7 @@ async def jwt_bearer_grant(self, assertion: str, scope: str | None = None) -> Ke The access token. Keycloak issues no refresh token for this grant. Raises: - Mapped application errors when the assertion or the client setup is rejected. + BaseError: If Keycloak rejects the assertion or client configuration, or the request fails. """ return to_dto( KeycloakTokenDTO, @@ -1009,7 +1011,9 @@ async def request_rpt(self, token: str, audience: str, permissions: list[str] | The RPT in ``access_token``. Raises: - Mapped application errors; ``InsufficientPermissionsError`` when no requested permission is granted. + InsufficientPermissionsError: If Keycloak denies the request, including when it grants no requested + permissions. + BaseError: If the request fails for another reason. """ form: dict[str, Any] = {"grant_type": UMA_TICKET_GRANT, "audience": audience} if permissions: diff --git a/packages/keycloak/archipy/adapters/keycloak/_resources/attack_detection/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_resources/attack_detection/adapter.py index 72252687b..f24e2a69c 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_resources/attack_detection/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_resources/attack_detection/adapter.py @@ -61,9 +61,6 @@ def clear_user_brute_force(self, user_id: str) -> KeycloakDeleteResultDTO: def clear_all_brute_force(self) -> KeycloakDeleteResultDTO: """Clear the failed login counters of every user in the realm. - Args: - (none) - Returns: The delete result. """ @@ -122,9 +119,6 @@ async def clear_user_brute_force(self, user_id: str) -> KeycloakDeleteResultDTO: async def clear_all_brute_force(self) -> KeycloakDeleteResultDTO: """Clear the failed login counters of every user in the realm. - Args: - (none) - Returns: The delete result. """ diff --git a/packages/keycloak/archipy/adapters/keycloak/_resources/authentication/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_resources/authentication/adapter.py index 63f66da24..3e9cfa659 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_resources/authentication/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_resources/authentication/adapter.py @@ -329,9 +329,6 @@ def create_execution_config( def get_client_authenticator_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: """List the client authenticator providers. - Args: - (none) - Returns: The providers. """ @@ -348,9 +345,6 @@ def get_client_authenticator_providers(self) -> list[KeycloakAuthenticatorProvid def get_form_action_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: """List the form action providers. - Args: - (none) - Returns: The providers. """ @@ -367,9 +361,6 @@ def get_form_action_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: def get_form_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: """List the form providers. - Args: - (none) - Returns: The providers. """ @@ -386,9 +377,6 @@ def get_form_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: def get_per_client_config_description(self) -> dict[str, list[KeycloakConfigPropertyDTO]]: """Describe the settings of every client authenticator. - Args: - (none) - Returns: The settings by authenticator id. """ @@ -743,9 +731,6 @@ async def create_execution_config( async def get_client_authenticator_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: """List the client authenticator providers. - Args: - (none) - Returns: The providers. """ @@ -762,9 +747,6 @@ async def get_client_authenticator_providers(self) -> list[KeycloakAuthenticator async def get_form_action_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: """List the form action providers. - Args: - (none) - Returns: The providers. """ @@ -781,9 +763,6 @@ async def get_form_action_providers(self) -> list[KeycloakAuthenticatorProviderD async def get_form_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: """List the form providers. - Args: - (none) - Returns: The providers. """ @@ -800,9 +779,6 @@ async def get_form_providers(self) -> list[KeycloakAuthenticatorProviderDTO]: async def get_per_client_config_description(self) -> dict[str, list[KeycloakConfigPropertyDTO]]: """Describe the settings of every client authenticator. - Args: - (none) - Returns: The settings by authenticator id. """ diff --git a/packages/keycloak/archipy/adapters/keycloak/_resources/client_initial_access/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_resources/client_initial_access/adapter.py index e1717f9cb..c0a586b42 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_resources/client_initial_access/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_resources/client_initial_access/adapter.py @@ -28,9 +28,6 @@ class KeycloakClientInitialAccessMixin(SyncKeycloakMixinBase): def get_client_initial_access_tokens(self) -> list[KeycloakClientInitialAccessDTO]: """List the client initial access tokens of the realm. - Args: - (none) - Returns: The tokens, without their secret value. """ @@ -96,9 +93,6 @@ class AsyncKeycloakClientInitialAccessMixin(AsyncKeycloakMixinBase): async def get_client_initial_access_tokens(self) -> list[KeycloakClientInitialAccessDTO]: """List the client initial access tokens of the realm. - Args: - (none) - Returns: The tokens, without their secret value. """ diff --git a/packages/keycloak/archipy/adapters/keycloak/_resources/client_registration_policy/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_resources/client_registration_policy/adapter.py index 4e75e284d..95ec66b8d 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_resources/client_registration_policy/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_resources/client_registration_policy/adapter.py @@ -18,9 +18,6 @@ class KeycloakClientRegistrationPolicyMixin(SyncKeycloakMixinBase): def get_client_registration_policy_providers(self) -> list[KeycloakComponentTypeDTO]: """List the client registration policy providers and their settings. - Args: - (none) - Returns: The providers. """ @@ -41,9 +38,6 @@ class AsyncKeycloakClientRegistrationPolicyMixin(AsyncKeycloakMixinBase): async def get_client_registration_policy_providers(self) -> list[KeycloakComponentTypeDTO]: """List the client registration policy providers and their settings. - Args: - (none) - Returns: The providers. """ diff --git a/packages/keycloak/archipy/adapters/keycloak/_resources/keys/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_resources/keys/adapter.py index cf020c822..5ba0cbd28 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_resources/keys/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_resources/keys/adapter.py @@ -18,9 +18,6 @@ class KeycloakKeysMixin(SyncKeycloakMixinBase): def get_realm_keys(self) -> KeycloakKeysMetadataDTO: """Get the active key ids and the metadata of every key of the realm. - Args: - (none) - Returns: The keys. """ @@ -41,9 +38,6 @@ class AsyncKeycloakKeysMixin(AsyncKeycloakMixinBase): async def get_realm_keys(self) -> KeycloakKeysMetadataDTO: """Get the active key ids and the metadata of every key of the realm. - Args: - (none) - Returns: The keys. """ diff --git a/packages/keycloak/archipy/adapters/keycloak/_resources/required_actions/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_resources/required_actions/adapter.py index 9ad9fbd7d..cdb6d6b6f 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_resources/required_actions/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_resources/required_actions/adapter.py @@ -34,9 +34,6 @@ class KeycloakRequiredActionsMixin(SyncKeycloakMixinBase): def get_required_actions(self) -> list[KeycloakRequiredActionProviderDTO]: """List the required actions registered in the realm. - Args: - (none) - Returns: The required actions. """ @@ -141,9 +138,6 @@ def register_required_action(self, provider_id: str, name: str) -> KeycloakCreat def get_unregistered_required_actions(self) -> list[KeycloakUnregisteredRequiredActionDTO]: """List the required action providers that are not registered in the realm. - Args: - (none) - Returns: The unregistered providers. """ @@ -284,9 +278,6 @@ class AsyncKeycloakRequiredActionsMixin(AsyncKeycloakMixinBase): async def get_required_actions(self) -> list[KeycloakRequiredActionProviderDTO]: """List the required actions registered in the realm. - Args: - (none) - Returns: The required actions. """ @@ -391,9 +382,6 @@ async def register_required_action(self, provider_id: str, name: str) -> Keycloa async def get_unregistered_required_actions(self) -> list[KeycloakUnregisteredRequiredActionDTO]: """List the required action providers that are not registered in the realm. - Args: - (none) - Returns: The unregistered providers. """ diff --git a/packages/keycloak/archipy/adapters/keycloak/_resources/users/adapter.py b/packages/keycloak/archipy/adapters/keycloak/_resources/users/adapter.py index a36ee8a03..ff357e6de 100644 --- a/packages/keycloak/archipy/adapters/keycloak/_resources/users/adapter.py +++ b/packages/keycloak/archipy/adapters/keycloak/_resources/users/adapter.py @@ -300,9 +300,6 @@ def count_users(self, query: dict[str, Any] | None = None) -> int: def get_user_profile_config(self) -> KeycloakUserProfileConfigDTO: """Get the realm's user profile configuration. - Args: - (none) - Returns: The user profile configuration. """ @@ -342,9 +339,6 @@ def update_user_profile_config( def get_user_profile_metadata(self) -> KeycloakUserProfileMetadataDTO: """Get the user profile metadata of the realm. - Args: - (none) - Returns: The metadata. """ @@ -1025,9 +1019,6 @@ async def count_users(self, query: dict[str, Any] | None = None) -> int: async def get_user_profile_config(self) -> KeycloakUserProfileConfigDTO: """Get the realm's user profile configuration. - Args: - (none) - Returns: The user profile configuration. """ @@ -1067,9 +1058,6 @@ async def update_user_profile_config( async def get_user_profile_metadata(self) -> KeycloakUserProfileMetadataDTO: """Get the user profile metadata of the realm. - Args: - (none) - Returns: The metadata. """ diff --git a/zensical.toml b/zensical.toml index 3cf1fe2f5..505bdb69f 100644 --- a/zensical.toml +++ b/zensical.toml @@ -184,6 +184,52 @@ pymdownx.emoji.emoji_generator = "zensical.extensions.emoji.to_svg" [project.plugins.autorefs] +# Paths published before the documentation was reorganized. +[project.plugins.redirects.redirect_maps] +"CODE_OF_CONDUCT.md" = "community/code_of_conduct.md" +"api_reference/utils.md" = "api_reference/helpers/utils.md" +"architecture.md" = "getting-started/concepts.md" +"changelog.md" = "community/changelog/index.md" +"concepts.md" = "getting-started/concepts.md" +"contributing-docs.md" = "community/contributing.md" +"contributing.md" = "community/contributing.md" +"development.md" = "community/contributing.md" +"examples/adapters/elasticsearch.md" = "tutorials/adapters/elasticsearch.md" +"examples/adapters/email.md" = "tutorials/adapters/email.md" +"examples/adapters/index.md" = "tutorials/adapters/index.md" +"examples/adapters/kafka.md" = "tutorials/adapters/kafka.md" +"examples/adapters/keycloak.md" = "tutorials/adapters/keycloak.md" +"examples/adapters/minio.md" = "tutorials/adapters/minio.md" +"examples/adapters/orm.md" = "api_reference/adapters/base.md" +"examples/adapters/parsian_payment.md" = "tutorials/adapters/payment_gateways.md" +"examples/adapters/payment_gateways.md" = "tutorials/adapters/payment_gateways.md" +"examples/adapters/postgres.md" = "tutorials/adapters/postgres.md" +"examples/adapters/redis.md" = "tutorials/adapters/redis.md" +"examples/adapters/scylladb.md" = "tutorials/adapters/scylladb.md" +"examples/adapters/sqlite.md" = "tutorials/adapters/sqlite.md" +"examples/adapters/starrocks.md" = "tutorials/adapters/starrocks.md" +"examples/adapters/temporal.md" = "tutorials/adapters/temporal.md" +"examples/bdd_testing.md" = "tutorials/testing_strategy.md" +"examples/config_management.md" = "tutorials/config_management.md" +"examples/dependency_injection.md" = "tutorials/dependency_injection.md" +"examples/error_handling.md" = "tutorials/error_handling.md" +"examples/helpers/decorators.md" = "tutorials/helpers/decorators.md" +"examples/helpers/index.md" = "tutorials/helpers/index.md" +"examples/helpers/interceptors.md" = "tutorials/helpers/interceptors.md" +"examples/helpers/metaclasses.md" = "tutorials/helpers/metaclasses.md" +"examples/helpers/utils.md" = "tutorials/helpers/utils.md" +"examples/index.md" = "tutorials/index.md" +"examples/models/protobuf_dtos.md" = "tutorials/models/protobuf_dtos.md" +"examples/observability.md" = "tutorials/observability.md" +"examples/testing_strategy.md" = "tutorials/testing_strategy.md" +"faq.md" = "community/faq.md" +"features.md" = "index.md" +"get_started.md" = "index.md" +"installation.md" = "getting-started/installation.md" +"license.md" = "community/license.md" +"security.md" = "community/security.md" +"usage.md" = "getting-started/quickstart.md" + [project.plugins.mkdocstrings.handlers.python] paths = [ ".", From 6cf61dd7672a264ac1bcee348cc3aeaa031db0da Mon Sep 17 00:00:00 2001 From: "h.nejati" Date: Sun, 22 Nov 2026 14:26:25 +0330 Subject: [PATCH 3/4] docs: slim API reference and verify examples Refs #631 --- .github/workflows/deploy-docs.yml | 4 +- .github/workflows/docs-check.yml | 18 +- .github/workflows/tests.yml | 2 + .readthedocs.yaml | 2 +- Makefile | 6 +- docs/api_reference/adapters/keycloak.md | 18 +- docs/api_reference/models/dtos.md | 241 ++++-------------------- docs/community/contributing.md | 8 + docs/community/deprecations.md | 33 ++++ docs/getting-started/quickstart.md | 24 +-- overrides/404.html | 2 +- scripts/check_docs.py | 119 ++++++++++++ scripts/smoke_docs.py | 100 ++++++++++ 13 files changed, 341 insertions(+), 236 deletions(-) create mode 100644 scripts/check_docs.py create mode 100644 scripts/smoke_docs.py diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index d4204f436..6ed64dc4b 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -11,6 +11,7 @@ on: - 'archipy/**' - 'packages/**' - 'zensical.toml' + - 'scripts/check_docs.py' - 'pyproject.toml' - 'uv.lock' - '.python-version' @@ -18,6 +19,7 @@ on: pull_request: paths: - 'zensical.toml' + - 'scripts/check_docs.py' - '.python-version' - '.github/workflows/deploy-docs.yml' @@ -38,7 +40,7 @@ jobs: run: uv sync --locked --group docs - name: Build documentation - run: uv run --no-sync zensical build --clean --strict + run: uv run --no-sync python scripts/check_docs.py - name: Upload Pages artifact uses: actions/upload-pages-artifact@v5 diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 307195519..03e2b86c2 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -7,6 +7,8 @@ on: - 'docs/**' - 'overrides/**' - 'zensical.toml' + - 'scripts/check_docs.py' + - 'scripts/smoke_docs.py' - 'archipy/**' - 'packages/**' - 'pyproject.toml' @@ -25,6 +27,14 @@ jobs: container: ghcr.io/astral-sh/uv:0.13.9-trixie env: UV_PYTHON: ${{ matrix.python-version }} + services: + redis: + image: redis:8.10.3-alpine + options: >- + --health-cmd "redis-cli ping" + --health-interval 2s + --health-timeout 2s + --health-retries 15 strategy: fail-fast: false matrix: @@ -39,13 +49,19 @@ jobs: key: uv-docs-${{ runner.arch }}-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }} - name: Install dependencies - run: uv sync --locked --group docs + run: uv sync --locked --group docs --extra redis - name: Build the docs in strict mode env: UV_NO_SYNC: "true" run: make docs-check + - name: Run documentation examples + env: + UV_NO_SYNC: "true" + REDIS__MASTER_HOST: redis + run: make docs-smoke + docs-check: needs: build if: always() diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4547a891a..a38ccfa7a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -182,6 +182,8 @@ jobs: - '!LICENSE' - '!overrides/**' - '!zensical.toml' + - '!scripts/check_docs.py' + - '!scripts/smoke_docs.py' - '!.github/ISSUE_TEMPLATE/**' - '!.github/workflows/{close-stale-issues,deploy-docs,dependency-review,docs-check,instrumentor-compat,labeler,link-check,pr-merged-issue-comment,publish,ruff-lint,ty-lint}.yml' - '!.github/labeler.yml' diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 7c570198b..d23eefa67 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -13,7 +13,7 @@ build: curl -fsSL https://astral.sh/uv/0.13.9/install.sh -o /tmp/archipy-uv-install.sh && UV_UNMANAGED_INSTALL="$HOME/.local/bin" sh /tmp/archipy-uv-install.sh - '"$HOME/.local/bin/uv" sync --python 3.15 --locked --group docs' - - '"$HOME/.local/bin/uv" run --python 3.15 --no-sync zensical build --clean --strict' + - '"$HOME/.local/bin/uv" run --python 3.15 --no-sync python scripts/check_docs.py' - mkdir -p "$READTHEDOCS_OUTPUT/html" && cp -a site/. "$READTHEDOCS_OUTPUT/html/" search: diff --git a/Makefile b/Makefile index e5265f734..236e9d46d 100644 --- a/Makefile +++ b/Makefile @@ -243,7 +243,11 @@ docs-build: ## Build the static documentation site .PHONY: docs-check docs-check: ## Run a clean, strict documentation build @echo "${BLUE}Checking documentation...${NC}" - $(UV) run --group docs zensical build --clean --strict + $(UV) run --group docs python scripts/check_docs.py + +.PHONY: docs-smoke +docs-smoke: ## Run the published quickstart and upgrade examples using Redis + $(UV) run --group docs --extra redis python scripts/smoke_docs.py .PHONY: docs-build-full docs-build-full: docs-check ## Build the production site diff --git a/docs/api_reference/adapters/keycloak.md b/docs/api_reference/adapters/keycloak.md index d5fb2d71e..61354bb48 100644 --- a/docs/api_reference/adapters/keycloak.md +++ b/docs/api_reference/adapters/keycloak.md @@ -19,18 +19,18 @@ validation, user management, and role-based access control. Abstract port interface defining the Keycloak adapter contract. ::: archipy.adapters.keycloak.ports -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Adapters Concrete Keycloak adapter wrapping the Keycloak REST API for authentication and authorization operations. ::: archipy.adapters.keycloak.adapters -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Auth Guards @@ -49,6 +49,6 @@ Ambiguous organization ownership raises `PermissionDeniedError`; it never falls See [resource ownership](../../tutorials/adapters/keycloak.md#resource-ownership) for the contract and UUID migration notes. ::: archipy.adapters.keycloak.auth -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false diff --git a/docs/api_reference/models/dtos.md b/docs/api_reference/models/dtos.md index adead8f16..5d0d3e55d 100644 --- a/docs/api_reference/models/dtos.md +++ b/docs/api_reference/models/dtos.md @@ -13,81 +13,81 @@ pagination, sorting, search, and email payloads. Base DTO classes providing common fields and validators inherited by domain-specific DTOs. ::: archipy.models.dtos.base_dtos -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Base Protobuf DTO Base DTO class for Protobuf-backed data transfer objects, bridging gRPC and Pydantic models. ::: archipy.models.dtos.base_protobuf_dto -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Pagination DTO DTOs for pagination input and output, including page number, page size, and total count fields. ::: archipy.models.dtos.pagination_dto -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Sort DTO DTOs for expressing sort order in list/search requests. ::: archipy.models.dtos.sort_dto -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Search Input DTO DTO for structured search input combining filter, sort, and pagination parameters. ::: archipy.models.dtos.search_input_dto -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Search Output DTO Base DTOs for paged search outputs, with `total_count` and the computed `total_count_estimated`. ::: archipy.models.dtos.search_output_dto -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Range DTOs DTOs for expressing numeric and date range filters in queries. ::: archipy.models.dtos.range_dtos -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Email DTOs DTOs for composing email messages including recipients, subject, body, and attachments. ::: archipy.models.dtos.email_dtos -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Rate Limit Window DTO DTO for a single rate-limit tier: maximum calls within a time window. ::: archipy.models.dtos.rate_limit_window_dto -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## RediSearch DTOs @@ -95,9 +95,9 @@ heading_level: 3 DTOs for RediSearch index schemas, document upserts, queries, aggregations, and normalized search results. ::: archipy.models.dtos.redis.search -options: -show_root_toc_entry: false -heading_level: 3 + options: + heading_level: 3 + show_source: false ## Keycloak DTOs @@ -106,181 +106,6 @@ authorization, authentication flows), UMA payloads, and OpenID Connect token, us DTOs keep unknown fields; request DTOs reject them. ::: archipy.models.dtos.keycloak -options: -show_root_toc_entry: false -heading_level: 3 - -::: archipy.models.dtos.keycloak.base -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.auth_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.token_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.user_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.group_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.role_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.client_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.client_scope_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.protocol_mapper_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.organization_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.identity_provider_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.realm_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.authz_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.authz_policy_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.auth_flow_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.authenticator_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.uma_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.event_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.key_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.certificate_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.client_policy_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.client_initial_access_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.attack_detection_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.partial_import_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.session_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.user_profile_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.management_permission_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.client_evaluation_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.component_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.common_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.authz_evaluation_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.authzen_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.protocol_mapper_config_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.required_action_dtos -options: -show_root_toc_entry: false -heading_level: 4 - -::: archipy.models.dtos.keycloak.token_exchange_dtos -options: -show_root_toc_entry: false -heading_level: 4 + options: + heading_level: 3 + show_source: false diff --git a/docs/community/contributing.md b/docs/community/contributing.md index 84838da3f..991a3f35e 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -311,6 +311,14 @@ Run the clean, strict build used by CI: make docs-check ``` +Run the published quickstart and upgrade examples with a local Redis test instance: + +```bash +make docs-smoke +``` + +Set `REDIS__MASTER_HOST` and `REDIS__PORT` to use a test instance on a different address. + GitHub Pages deploys when documentation or API sources change on `master`. Read the Docs builds from the same configuration. ### Documentation Improvement Guidelines diff --git a/docs/community/deprecations.md b/docs/community/deprecations.md index f910a8572..31a0c8305 100644 --- a/docs/community/deprecations.md +++ b/docs/community/deprecations.md @@ -30,6 +30,29 @@ functions through the same API. | `async_trace_span` | `trace_span` | | `async_trace_root` | `trace_root` | +For example, replace `@retry_decorator` with `@retry` and keep the retry policy explicit: + +```python +# retry_example.py +from collections.abc import Iterator + +from archipy.helpers.decorators import retry + + +@retry(max_retries=2, delay=0, retry_on=(ConnectionError,)) +def read_value(responses: Iterator[str | None]) -> str: + """Read a value from a source that can fail temporarily.""" + value = next(responses) + if value is None: + raise ConnectionError("Source temporarily unavailable") + return value + + +result = read_value(iter((None, "ready"))) +``` + +The first attempt raises `ConnectionError`. The second returns `"ready"`. + ### Removed import paths | Deprecated import path | Replacement | @@ -117,6 +140,16 @@ Use the paths below in Python code. For environment variables, replace each dot For example, `REDIS__SSL=true` becomes `REDIS__TLS__IS_ENABLED=true`. If you set a value under both 5.x names, keep the value you configured under the nested name. +With `REDIS__TLS__IS_ENABLED=true` set in the environment, use the nested settings in Python: + +```python +# redis_tls.py +from archipy.configs.base_config import BaseConfig + +config = BaseConfig() +redis_tls_enabled = config.REDIS.TLS.IS_ENABLED +``` + ### AUTH | 5.x field | 6.0 field | diff --git a/docs/getting-started/quickstart.md b/docs/getting-started/quickstart.md index 6ce9310e2..3a50919ff 100644 --- a/docs/getting-started/quickstart.md +++ b/docs/getting-started/quickstart.md @@ -12,6 +12,7 @@ with a typed config, a Redis adapter, and a TTL cache backed by Redis in under f - Python 3.14 or later - `uv` package manager ([installation guide](https://docs.astral.sh/uv/getting-started/installation/)) +- A running Redis instance. The example uses `localhost:6379` by default. > **Tip:** Check your Python version: > @@ -29,7 +30,7 @@ uv init ## Step 2 โ€” Install ArchiPy ```bash -uv add "archipy[redis]" +uv add "archipy[redis]" click ``` ## Step 3 โ€” Define the Configuration @@ -70,7 +71,7 @@ logger.info("Config loaded for %s (env=%s)", config.APP_NAME, config.ENVIRONMENT ## Step 4 โ€” Connect to Redis -Create a Redis adapter using the global config: +Create a Redis adapter using the global config. Set `REDIS__MASTER_HOST` and `REDIS__PORT` if Redis is running elsewhere. ```python # adapters/cache_adapter.py @@ -116,13 +117,6 @@ def get_user_name(user_id: str) -> str: name = f"User-{user_id}" # replace with a real DB call redis.set(cache_key, name, ex=_CACHE_TTL) return name - - -# First call: cache miss โ€” hits the database and stores in Redis -name = get_user_name("42") - -# Second call within 60 seconds: cache hit โ€” returns from Redis instantly -name = get_user_name("42") ``` ## Step 6 โ€” Run the App @@ -146,10 +140,11 @@ def cli(): @cli.command() -def run() -> None: +@click.argument("user_id", default="42") +def run(user_id: str) -> None: """Run a quick cache demonstration.""" - logger.info(get_user_name("42")) - logger.info(get_user_name("42")) # returns from cache + logger.info("%s", get_user_name(user_id)) + logger.info("%s", get_user_name(user_id)) # returns from cache if __name__ == "__main__": @@ -157,7 +152,7 @@ if __name__ == "__main__": ``` ```bash -python manage.py run +uv run python manage.py run ``` You should see: @@ -168,7 +163,8 @@ INFO:__main__:User-42 INFO:__main__:User-42 ``` -The second call is served from Redis without hitting the database. +The first call caches the result for 60 seconds. The second call reads it from Redis. If you rerun the example +within that window, both calls can hit the cache. Pass a different user ID to see a fresh miss. --- diff --git a/overrides/404.html b/overrides/404.html index 317cacd59..fbe9f02b3 100644 --- a/overrides/404.html +++ b/overrides/404.html @@ -4,7 +4,7 @@

Page Not Found

The requested page may have moved or been removed.

Find What You Need

-
    +
    • Get Started for an overview and quick example
    • Installation for ArchiPy and its optional extras
    • Quickstart for a five-minute guide
    • diff --git a/scripts/check_docs.py b/scripts/check_docs.py new file mode 100644 index 000000000..11744ffaf --- /dev/null +++ b/scripts/check_docs.py @@ -0,0 +1,119 @@ +"""Build the documentation and verify the generated error page and redirects.""" + +import subprocess +import sys +import tomllib +from html.parser import HTMLParser +from pathlib import Path, PurePosixPath +from urllib.parse import unquote, urljoin, urlsplit + + +class PageLinks(HTMLParser): + """Collect the links needed to verify a generated page.""" + + def __init__(self, source: Path) -> None: + super().__init__() + self.canonical: str | None = None + self.refresh: str | None = None + self.links: set[str] = set() + self.recovery_links: set[str] = set() + self._in_recovery_list = False + self.feed(source.read_text(encoding="utf-8")) + + def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: + """Record canonical, refresh, and visible fallback links.""" + attributes = dict(attrs) + if tag == "ul" and attributes.get("id") == "docs-recovery": + self._in_recovery_list = True + if tag == "a" and (href := attributes.get("href")): + self.links.add(href) + if self._in_recovery_list: + self.recovery_links.add(href) + if tag == "link" and attributes.get("rel") == "canonical": + self.canonical = attributes.get("href") + if tag == "meta" and attributes.get("http-equiv") == "refresh": + self.refresh = (attributes.get("content") or "").partition("url=")[2] + + def handle_endtag(self, tag: str) -> None: + """Stop collecting custom recovery links at the end of their list.""" + if tag == "ul": + self._in_recovery_list = False + + +def markdown_url(path: str, directory_urls: bool) -> str: + """Return the output URL for a docs-relative Markdown path.""" + source = PurePosixPath(path) + if source.name == "index.md": + return "" if source.parent == PurePosixPath(".") else f"{source.parent}/" + return f"{source.with_suffix('')}/" if directory_urls else str(source.with_suffix(".html")) + + +def site_file(site: Path, site_url: str, url: str) -> Path: + """Resolve a URL under the published site to its generated file.""" + relative = url.removeprefix(site_url) + if relative == url: + raise SystemExit(f"Expected a documentation URL under {site_url}: {url}") + path = unquote(urlsplit(relative).path) + return site / (f"{path}index.html" if not path or path.endswith("/") else path) + + +def check_output(config_path: Path) -> None: + """Verify each page redirect and the custom 404 recovery links.""" + with config_path.open("rb") as file: + project = tomllib.load(file)["project"] + site = config_path.parent / project.get("site_dir", "site") + site_url = f"{project['site_url'].rstrip('/')}/" + directory_urls = project.get("use_directory_urls", True) + redirects = project["plugins"]["redirects"]["redirect_maps"] + + for old, new in redirects.items(): + if urlsplit(old).fragment: + continue # Section redirects are handled on the destination page. + old_url = urljoin(site_url, markdown_url(old, directory_urls)) + new_path = urlsplit(new) + if new_path.scheme: + expected_url = new + else: + expected_url = urljoin(site_url, markdown_url(new_path.path, directory_urls)) + if new_path.fragment: + expected_url = f"{expected_url}#{new_path.fragment}" + if not site_file(site, site_url, expected_url).is_file(): + raise SystemExit(f"Redirect target is missing: {new}") + page = PageLinks(site_file(site, site_url, old_url)) + if ( + not page.canonical + or page.refresh != page.canonical + or page.canonical not in page.links + or urljoin(old_url, page.canonical) != expected_url + ): + raise SystemExit(f"Invalid generated redirect: {old} -> {new}") + + recovery = PageLinks(site / "404.html").recovery_links + if not recovery: + raise SystemExit("Generated 404.html is missing the custom recovery links") + missing_url = urljoin(site_url, "missing/deep/page/") + for href in sorted(recovery): + if not site_file(site, site_url, urljoin(missing_url, href)).is_file(): + raise SystemExit(f"Broken recovery link in 404.html: {href}") + print("Verified generated redirects and custom 404 links.") + + +def main() -> None: + """Run a strict build and fail on Griffe diagnostics.""" + result = subprocess.run( + [sys.executable, "-m", "zensical", "build", "--clean", "--strict"], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + check=False, + ) + print(result.stdout, end="") + if result.returncode: + raise SystemExit(result.returncode) + if any(line.startswith("griffe:") for line in result.stdout.splitlines()): + raise SystemExit("Correct the Griffe docstring diagnostics above.") + check_output(Path("zensical.toml")) + + +if __name__ == "__main__": + main() diff --git a/scripts/smoke_docs.py b/scripts/smoke_docs.py new file mode 100644 index 000000000..ac8cda31c --- /dev/null +++ b/scripts/smoke_docs.py @@ -0,0 +1,100 @@ +"""Execute the Python examples published in the quickstart and upgrade guide.""" + +import os +import re +import subprocess +import sys +from pathlib import Path +from tempfile import TemporaryDirectory +from uuid import uuid4 + +QUICKSTART = Path("docs/getting-started/quickstart.md") +UPGRADE = Path("docs/community/deprecations.md") +PYTHON_FENCES = re.compile(r"^```python\n(.*?)^```[ \t]*$", re.MULTILINE | re.DOTALL) + + +def example(page: Path, filename: str) -> str: + """Read the fenced Python example identified by its filename comment.""" + prefix = f"# {filename}\n" + matches = [block for block in PYTHON_FENCES.findall(page.read_text(encoding="utf-8")) if block.startswith(prefix)] + if len(matches) != 1: + raise SystemExit(f"{page}: expected one Python example for {filename}") + return matches[0] + + +def run_python(directory: Path, *args: str, env: dict[str, str] | None = None) -> str: + """Run an example in a fresh interpreter using the current environment.""" + result = subprocess.run( + [sys.executable, *args], + cwd=directory, + env=env, + check=False, + capture_output=True, + text=True, + timeout=20, + ) + output = result.stdout + result.stderr + if result.returncode: + raise SystemExit(f"Example failed: {' '.join(args)}\n{output}") + return output + + +def quickstart(directory: Path) -> None: + """Check the documented CLI output and Redis TTL through the adapter.""" + for filename in ("configs/app_config.py", "adapters/cache_adapter.py", "logics/user_logic.py", "manage.py"): + target = directory / filename + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(example(QUICKSTART, filename), encoding="utf-8") + + user_id = f"docs-smoke-{uuid4().hex}" + output = run_python(directory, "manage.py", "run", user_id) + cache_misses = [line for line in output.splitlines() if f"Cache miss โ€” fetching user {user_id}" in line] + responses = [line for line in output.splitlines() if line == f"INFO:__main__:User-{user_id}"] + if len(cache_misses) != 1 or len(responses) != 2: + raise SystemExit(f"Expected one cache miss and two matching results:\n{output}") + + key = f"user:name:{user_id}" + run_python( + directory, + "-c", + "import configs.app_config\n" + "from adapters.cache_adapter import redis\n" + "import sys\n" + "key = sys.argv[1]\n" + "ttl = redis.ttl(key)\n" + "redis.delete(key)\n" + "if not 0 < ttl <= 60:\n" + " raise SystemExit(f'Expected a cache TTL between 1 and 60 seconds, found {ttl}')\n", + key, + ) + + +def upgrade(directory: Path) -> None: + """Verify that the documented replacement decorator and Redis TLS setting work.""" + retry = example(UPGRADE, "retry_example.py") + run_python( + directory, + "-c", + f"{retry}\nif result != 'ready':\n raise SystemExit('Retry example did not recover')\n", + ) + + tls = example(UPGRADE, "redis_tls.py") + run_python( + directory, + "-c", + f"{tls}\nif not redis_tls_enabled:\n raise SystemExit('Nested Redis TLS env var was ignored')\n", + env={**os.environ, "REDIS__TLS__IS_ENABLED": "true"}, + ) + + +def main() -> None: + """Run the docs smoke checks without reusing project or Redis state.""" + with TemporaryDirectory(prefix="archipy-docs-examples-") as directory: + root = Path(directory) + quickstart(root) + upgrade(root) + print("Quickstart cache and 6.0 upgrade examples passed.") + + +if __name__ == "__main__": + main() From 547957358469a1b2607d65c20122db643e000f40 Mon Sep 17 00:00:00 2001 From: "h.nejati" Date: Sun, 22 Nov 2026 17:47:32 +0330 Subject: [PATCH 4/4] docs: improve 404 and adopt uv scripts Refs #631 --- .github/workflows/instrumentor-compat.yml | 2 +- Makefile | 2 +- docs/community/contributing.md | 3 ++ overrides/404.html | 60 ++++++++++++++++++----- scripts/behave_parallel.py | 35 +++++++++++-- scripts/check_docs.py | 36 +++++++++----- scripts/check_instrumentor_compat.py | 50 +++++++++++++++++++ scripts/check_instrumentor_compat.sh | 37 -------------- scripts/smoke_docs.py | 10 ++++ 9 files changed, 168 insertions(+), 67 deletions(-) create mode 100644 scripts/check_instrumentor_compat.py delete mode 100755 scripts/check_instrumentor_compat.sh diff --git a/.github/workflows/instrumentor-compat.yml b/.github/workflows/instrumentor-compat.yml index f0eacac2c..8709a83e2 100644 --- a/.github/workflows/instrumentor-compat.yml +++ b/.github/workflows/instrumentor-compat.yml @@ -29,4 +29,4 @@ jobs: - name: Install Python run: uv python install "$UV_PYTHON" - name: Check instrumentor version ranges - run: ./scripts/check_instrumentor_compat.sh + run: uv run --script scripts/check_instrumentor_compat.py diff --git a/Makefile b/Makefile index 236e9d46d..43c917abc 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,7 @@ security: ## Run security scan with Bandit .PHONY: check-instrumentor-compat check-instrumentor-compat: ## Check whether OTel instrumentors now support the library versions ArchiPy requires @echo "${BLUE}Checking OpenTelemetry instrumentor compatibility...${NC}" - ./scripts/check_instrumentor_compat.sh + $(UV) run --script scripts/check_instrumentor_compat.py # Features that run at the same time, and how many of those may start a heavy container BEHAVE_JOBS ?= 8 diff --git a/docs/community/contributing.md b/docs/community/contributing.md index 991a3f35e..1c1db0ccc 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -319,6 +319,9 @@ make docs-smoke Set `REDIS__MASTER_HOST` and `REDIS__PORT` to use a test instance on a different address. +The Make targets use the workspace lockfile. To run the docs checker with its inline uv dependencies, +use `uv run --script scripts/check_docs.py`. + GitHub Pages deploys when documentation or API sources change on `master`. Read the Docs builds from the same configuration. ### Documentation Improvement Guidelines diff --git a/overrides/404.html b/overrides/404.html index fbe9f02b3..3ed519c5e 100644 --- a/overrides/404.html +++ b/overrides/404.html @@ -1,17 +1,51 @@ {% extends "main.html" %} +{% block htmltitle %} +Page not found ยท {{ config.site_name }} +{% endblock %} + +{% block extrahead %} +{{ super() }} + +{% endblock %} + {% block content %} -

      Page Not Found

      -

      The requested page may have moved or been removed.

      -

      Find What You Need

      - -

      Use the search bar to find a specific topic.

      +

      Page not found

      +

      This page may have moved. Use the site search or choose a destination below.

      + + + +

      Followed a link here? Report the broken link.

      {% endblock %} diff --git a/scripts/behave_parallel.py b/scripts/behave_parallel.py index 2b23ae27f..ece2593c0 100644 --- a/scripts/behave_parallel.py +++ b/scripts/behave_parallel.py @@ -1,4 +1,9 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script +# /// script +# requires-python = ">=3.14,<4" +# dependencies = [] +# /// + """Run the Behave feature files in parallel, one ``behave`` process per feature. Behave has no parallel runner. Each feature starts the testcontainers it needs (the ``@needs-*`` tags of the @@ -19,7 +24,7 @@ process its own data file) and combines the data files at the end. Usage: - python scripts/behave_parallel.py [-j N] [--heavy-jobs N] [--coverage] [--exclude FEATURE ...] [FEATURE ...] [-- BEHAVE_ARGS ...] + uv run --script scripts/behave_parallel.py [-j N] [--heavy-jobs N] [--coverage] [--exclude FEATURE ...] [FEATURE ...] [-- BEHAVE_ARGS ...] """ from __future__ import annotations @@ -35,6 +40,7 @@ import time from concurrent.futures import ThreadPoolExecutor, as_completed from dataclasses import dataclass, field +from importlib.util import find_spec from pathlib import Path ROOT = Path(__file__).resolve().parent.parent @@ -380,8 +386,10 @@ def _start_shared_telemetry_stack(runs: list[FeatureRun]) -> subprocess.Popen | command.append("--apm") print("Starting the shared telemetry containers...", flush=True) stack = subprocess.Popen(command, cwd=ROOT, stdout=subprocess.PIPE, text=True) + stdout = stack.stdout + assert stdout is not None result: list[str] = [] - reader = threading.Thread(target=lambda: result.append(stack.stdout.readline()), daemon=True) + reader = threading.Thread(target=lambda: result.append(stdout.readline()), daemon=True) reader.start() reader.join(SHARED_TELEMETRY_START_TIMEOUT_SECONDS) if not result or not result[0].strip(): @@ -410,6 +418,27 @@ def main(argv: list[str]) -> int: if not runs: print("No feature files found", file=sys.stderr) return 2 + if find_spec("behave") is None: + # An inline uv script starts isolated. Features use the checkout's locked workspace extras. + version = f"{sys.version_info.major}.{sys.version_info.minor}" + environment = {key: value for key, value in os.environ.items() if key not in {"VIRTUAL_ENV", "UV_NO_SYNC"}} + os.execvpe( + "uv", + [ + "uv", + "run", + "--project", + str(ROOT), + "--locked", + "--all-extras", + "--python", + version, + "python", + __file__, + *argv, + ], + environment, + ) if arguments.coverage: for stale in ROOT.glob(".coverage*"): stale.unlink() diff --git a/scripts/check_docs.py b/scripts/check_docs.py index 11744ffaf..8de13401d 100644 --- a/scripts/check_docs.py +++ b/scripts/check_docs.py @@ -1,3 +1,14 @@ +#!/usr/bin/env -S uv run --script +# /// script +# requires-python = ">=3.14,<4" +# dependencies = [ +# "mkdocstrings-python>=2.0.11", +# "mkdocstrings>=1.0.8", +# "pymdown-extensions>=13.1.2", +# "zensical==0.1.3", +# ] +# /// + """Build the documentation and verify the generated error page and redirects.""" import subprocess @@ -17,17 +28,17 @@ def __init__(self, source: Path) -> None: self.refresh: str | None = None self.links: set[str] = set() self.recovery_links: set[str] = set() - self._in_recovery_list = False + self._in_recovery_navigation = False self.feed(source.read_text(encoding="utf-8")) def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: """Record canonical, refresh, and visible fallback links.""" attributes = dict(attrs) - if tag == "ul" and attributes.get("id") == "docs-recovery": - self._in_recovery_list = True + if tag == "nav" and attributes.get("id") == "docs-recovery": + self._in_recovery_navigation = True if tag == "a" and (href := attributes.get("href")): self.links.add(href) - if self._in_recovery_list: + if self._in_recovery_navigation: self.recovery_links.add(href) if tag == "link" and attributes.get("rel") == "canonical": self.canonical = attributes.get("href") @@ -35,9 +46,9 @@ def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None self.refresh = (attributes.get("content") or "").partition("url=")[2] def handle_endtag(self, tag: str) -> None: - """Stop collecting custom recovery links at the end of their list.""" - if tag == "ul": - self._in_recovery_list = False + """Stop collecting links at the end of the recovery navigation.""" + if tag == "nav": + self._in_recovery_navigation = False def markdown_url(path: str, directory_urls: bool) -> str: @@ -89,12 +100,13 @@ def check_output(config_path: Path) -> None: raise SystemExit(f"Invalid generated redirect: {old} -> {new}") recovery = PageLinks(site / "404.html").recovery_links - if not recovery: - raise SystemExit("Generated 404.html is missing the custom recovery links") missing_url = urljoin(site_url, "missing/deep/page/") - for href in sorted(recovery): - if not site_file(site, site_url, urljoin(missing_url, href)).is_file(): - raise SystemExit(f"Broken recovery link in 404.html: {href}") + destinations = {urljoin(missing_url, href) for href in recovery} + if site_url not in destinations: + raise SystemExit("Generated 404.html is missing the documentation home link") + for url in sorted(destinations): + if not site_file(site, site_url, url).is_file(): + raise SystemExit(f"Broken recovery link in 404.html: {url}") print("Verified generated redirects and custom 404 links.") diff --git a/scripts/check_instrumentor_compat.py b/scripts/check_instrumentor_compat.py new file mode 100644 index 000000000..f44a92523 --- /dev/null +++ b/scripts/check_instrumentor_compat.py @@ -0,0 +1,50 @@ +#!/usr/bin/env -S uv run --script +# /// script +# requires-python = ">=3.14,<4" +# dependencies = [] +# /// + +"""Tell when an OpenTelemetry instrumentor supports the library ArchiPy requires. + +ArchiPy requires sqlalchemy>=2.1.4, but opentelemetry-instrumentation-sqlalchemy still declares +sqlalchemy<2.1.0 in its "instruments" extra. ArchiPy instruments SQLAlchemy through +OTEL.INSTRUMENTATION_SKIP_DEP_CHECK. The extra is optional, so resolve both requirements +together to detect when the bypass can be removed. + +Exit codes: + 0: The conflict is still present. + 1: A pair resolves. Remove its bypass from OTEL.INSTRUMENTATION_SKIP_DEP_CHECK. + 2: The check failed, for example because of a network or index error. +""" + +import subprocess +import sys + +PAIRS = (("sqlalchemy>=2.1.4", "opentelemetry-instrumentation-sqlalchemy[instruments]>=0.66b1"),) + + +def main() -> int: + """Run uv's resolver for each library and instrumentor pair.""" + status = 0 + for library, instrumentor in PAIRS: + result = subprocess.run( + ["uv", "pip", "compile", "--python", sys.executable, "--no-header", "--quiet", "-"], + input=f"{library}\n{instrumentor}\n", + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + check=False, + ) + if result.returncode == 0: + print(f"SUPPORTED: {instrumentor} now resolves with {library}. Remove the bypass for it.") + status = 1 + elif "No solution found" in result.stdout: + print(f"STILL CONFLICTING: {instrumentor} with {library}") + else: + print(f"CHECK FAILED for {instrumentor}:\n{result.stdout}", end="") + return 2 + return status + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/check_instrumentor_compat.sh b/scripts/check_instrumentor_compat.sh deleted file mode 100755 index 6ec51bec3..000000000 --- a/scripts/check_instrumentor_compat.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# Tell when an OpenTelemetry instrumentor supports the library version ArchiPy requires. -# -# ArchiPy requires sqlalchemy>=2.1.4, but opentelemetry-instrumentation-sqlalchemy still declares -# sqlalchemy<2.1.0 in its "instruments" extra, so ArchiPy instruments SQLAlchemy through -# OTEL.INSTRUMENTATION_SKIP_DEP_CHECK. The extra is not a hard dependency, so uv never sees the conflict -# on a normal install. Resolving the extra together with ArchiPy's own bound makes uv report it. -# -# Exit codes: -# 0 conflict still present: the bypass is still needed -# 1 a pair now resolves: remove that key from OTEL.INSTRUMENTATION_SKIP_DEP_CHECK (and its default) -# 2 the check itself failed (network or index problem) -set -uo pipefail - -# "|" -PAIRS=( - "sqlalchemy>=2.1.4|opentelemetry-instrumentation-sqlalchemy[instruments]>=0.66b1" -) - -status=0 -for pair in "${PAIRS[@]}"; do - library="${pair%%|*}" - instrumentor="${pair##*|}" - output=$(printf '%s\n%s\n' "${library}" "${instrumentor}" | uv pip compile --no-header --quiet - 2>&1) - code=$? - if [ "${code}" -eq 0 ]; then - echo "SUPPORTED: ${instrumentor} now resolves with ${library}. Remove the bypass for it." - status=1 - elif echo "${output}" | grep -q "No solution found"; then - echo "STILL CONFLICTING: ${instrumentor} with ${library}" - else - echo "CHECK FAILED for ${instrumentor}:" - echo "${output}" - exit 2 - fi -done -exit "${status}" diff --git a/scripts/smoke_docs.py b/scripts/smoke_docs.py index ac8cda31c..1c877055d 100644 --- a/scripts/smoke_docs.py +++ b/scripts/smoke_docs.py @@ -1,3 +1,13 @@ +#!/usr/bin/env -S uv run --script +# /// script +# requires-python = ">=3.14,<4" +# dependencies = ["archipy[redis]", "click>=8"] +# +# [tool.uv.sources] +# archipy = { path = "..", editable = true } +# archipy-redis = { path = "../packages/redis", editable = true } +# /// + """Execute the Python examples published in the quickstart and upgrade guide.""" import os