Skip to content

Conversation

@polmichel
Copy link

@polmichel polmichel commented Feb 11, 2026

Why

Problem Statement

  • There is no Python SDK API Documentation today.
  • The existing documentation generation system (tasks.py) was a monolithic set of functions mixing concerns (template rendering, CLI execution, file I/O), making it hard to understand and to extend with new generation methods.
  • Docusaurus sidebars were statically hardcoded, requiring manual edits whenever a doc page was added or removed.

Goals

This PR:

  • Introduces automatic Python SDK API documentation generation from code docstrings using mdxify, only for package node and module client.
  • Refactors the documentation generation pipeline into an extensible architecture
  • Makes Docusaurus sidebars dynamic.

Closes: IHS-195, IHS-196, IHS-197, IHS-198, IHS-199, IHS-200, IHS-201

What changed

  • New SDK API docs from docstrings IHS-196: Added mdxify-based generation (generate-sdk-api-docs invoke task) that produces MDX reference pages for infrahub_sdk.client and infrahub_sdk.node with auto-discovery validation ensuring every new package is explicitly categorized.
  • Documentation generation refactoring IHS-201: Extracted the monolithic tasks.py functions into a docs/docs_generation/ package with a Strategy pattern — ADocContentGenMethod (base), Jinja2DocContentGenMethod, CommandOutputDocContentGenMethod, FilePrintingDocContentGenMethod — composed via DocPage/MDXDocPage page objects
  • Dynamic Docusaurus sidebars IHS-200: Replaced static sidebars-infrahubctl.ts and sidebars-python-sdk.ts with filesystem-reading versions in docs/sidebars/, using shared utility functions (getCommandItems, getItemsWithOrder) with vitest tests
  • New "Python SDK API" sidebar section IHS-198: Added sdk_ref autogenerated category under Reference in the Python SDK sidebar
  • Enhanced CI docs-validate check IHS-197: Now detects modified, deleted, and new untracked files under docs/ with descriptive error messages

What stayed the same

  • All public SDK APIs unchanged
  • Existing doc content (guides, topics, reference/config, reference/templating, infrahubctl commands) regenerated identically.

Suggested review order

This group of commits is a mixed between:

  • Legacy work which has been squashed into meaningful sets of change
  • Enhancement and completion of each part of the work.

One can refer to the internal issue key IHS-<insert_key> to only focus on changes that are tied to the same initial need.
Speaking about the reviewing order, I would suggest:

  1. docs/docs_generation/ IHS-201: the new generation architecture (Strategy pattern on documentation generation methods + Page objects) -> Design decisions
    2.tasks.pyrefactoring IHS-201: how the new classes are wired into _generate_infrahub_sdk_configuration_documentation and _generate_infrahub_sdk_template_documentation -> Apply the refactoring
  2. tasks.py API docs generation IHS-196: _generate_sdk_api_docs -> New feature
  3. dynamic sidebar logic and tests IHS-200: docs/sidebars/ -> Enhance existing documentation
  4. new "Python SDK API" sidebar section IHS-198: docs/sidebars/ -> New documentation
  5. new CI check docs-validate IHS-197: docs_validate -> Documentation integrity

How to test

# Unit tests for doc generation
uv run pytest tests/unit/doc_generation/ -v

# Sidebar utility tests (vitest)
cd docs && npm test

# Full documentation generation
uv run invoke docs-generate

# CI validation check (should pass with no diff)
uv run invoke docs-validate

# Lint
uv run invoke format lint

Impact & rollout

  • Backward compatibility: No breaking changes. All existing invoke tasks still work.
  • Performance: No runtime impact -> changes only affect doc generation tooling.
  • Config/env changes: New dev dependency mdxify in pyproject.toml, vitest in docs/package.json, upgrade version of Docusaurus
  • Deployment notes: N/A

a-delannoy and others added 18 commits February 10, 2026 10:34
…ng the future documentation generation method to be tested in isolation IHS-201
…archy. This is not yet plugged into tasks.py file IHS-201
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@polmichel polmichel changed the base branch from stable to develop February 11, 2026 14:27
@github-actions github-actions bot added group/ci Issue related to the CI pipeline type/documentation Improvements or additions to documentation labels Feb 11, 2026
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 95.93909% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/template/jinja2/__init__.py 95.58% 3 Missing and 3 partials ⚠️
infrahub_sdk/template/base.py 83.33% 0 Missing and 1 partial ⚠️
infrahub_sdk/template/jinja2/exceptions.py 96.00% 1 Missing ⚠️
@@             Coverage Diff             @@
##           develop     #822      +/-   ##
===========================================
+ Coverage    80.34%   80.40%   +0.06%     
===========================================
  Files          115      120       +5     
  Lines         9873     9896      +23     
  Branches      1504     1505       +1     
===========================================
+ Hits          7932     7957      +25     
+ Misses        1420     1416       -4     
- Partials       521      523       +2     
Flag Coverage Δ
integration-tests 41.35% <0.00%> (-0.07%) ⬇️
python-3.10 51.34% <58.88%> (-0.04%) ⬇️
python-3.11 51.32% <58.88%> (-0.06%) ⬇️
python-3.12 51.34% <58.88%> (-0.06%) ⬇️
python-3.13 51.32% <58.88%> (-0.08%) ⬇️
python-3.14 52.96% <60.41%> (-0.09%) ⬇️
python-filler-3.12 24.17% <51.26%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/client.py 72.00% <ø> (ø)
infrahub_sdk/ctl/utils.py 68.53% <ø> (ø)
infrahub_sdk/jinja2.py 0.00% <ø> (ø)
infrahub_sdk/node/node.py 85.34% <ø> (+0.32%) ⬆️
infrahub_sdk/pytest_plugin/items/base.py 78.37% <ø> (ø)
infrahub_sdk/template/__init__.py 100.00% <100.00%> (+4.44%) ⬆️
infrahub_sdk/template/exceptions.py 100.00% <100.00%> (+4.00%) ⬆️
infrahub_sdk/template/filters.py 100.00% <100.00%> (ø)
infrahub_sdk/template/jinja2/filters.py 100.00% <100.00%> (ø)
infrahub_sdk/template/jinja2/models.py 100.00% <100.00%> (ø)
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@polmichel polmichel force-pushed the pmi-20260210-sdk-api-documentation branch from 2bb2cbe to 31eee1b Compare February 12, 2026 16:31
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 12, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4347025
Status: ✅  Deploy successful!
Preview URL: https://e62dd372.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pmi-20260210-sdk-api-documen.infrahub-sdk-python.pages.dev

View logs

@polmichel polmichel force-pushed the pmi-20260210-sdk-api-documentation branch from 31eee1b to b001370 Compare February 12, 2026 16:40
@polmichel polmichel force-pushed the pmi-20260210-sdk-api-documentation branch from b001370 to 037d683 Compare February 12, 2026 16:53
@polmichel polmichel force-pushed the pmi-20260210-sdk-api-documentation branch from 037d683 to fb81d93 Compare February 12, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/ci Issue related to the CI pipeline type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants