Skip to content

Commit 7aeb880

Browse files
authored
Merge pull request #840 from opsmill/merge-822-832-833-develop-to-infrahub-develop
Merge SDK API documentation PRs 822 832 833 develop to infrahub develop
2 parents 3064a1f + 0b99ab7 commit 7aeb880

86 files changed

Lines changed: 8487 additions & 1397 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/file-filters.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ markdown_all: &markdown_all
3636

3737
infrahub_reference_generated: &infrahub_reference_generated
3838
- "docs/docs/infrahubctl/*.mdx"
39-
- "docs/docs/python-sdk/reference/config.mdx"
39+
- "docs/docs/python-sdk/reference/*.mdx"
40+
- "docs/docs/python-sdk/sdk_ref/**/*.mdx"
4041

4142
documentation_all:
4243
- *development_files

.github/workflows/ci.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
- name: "Linting: markdownlint"
109109
uses: DavidAnson/markdownlint-cli2-action@v22
110110
with:
111-
config: .markdownlint.yaml
111+
config: docs/.markdownlint.yaml
112112
globs: |
113113
**/*.{md,mdx}
114114
!changelog/*.md
@@ -176,7 +176,7 @@ jobs:
176176
uses: actions/setup-node@v5
177177
with:
178178
node-version: 20
179-
cache: 'npm'
179+
cache: "npm"
180180
cache-dependency-path: docs/package-lock.json
181181
- name: "Install dependencies"
182182
run: npm install
@@ -207,6 +207,15 @@ jobs:
207207
uses: "actions/checkout@v6"
208208
with:
209209
submodules: true
210+
- name: Install NodeJS
211+
uses: actions/setup-node@v5
212+
with:
213+
node-version: 20
214+
cache: "npm"
215+
cache-dependency-path: docs/package-lock.json
216+
- name: "Install npm dependencies"
217+
run: npm install
218+
working-directory: ./docs
210219
- name: Set up Python
211220
uses: actions/setup-python@v6
212221
with:
@@ -217,9 +226,11 @@ jobs:
217226
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
218227
- name: Install dependencies
219228
run: uv sync --all-groups --all-extras
229+
- name: Docs unit tests
230+
run: npx --no-install vitest run
231+
working-directory: ./docs
220232
- name: Validate generated documentation
221233
run: uv run invoke docs-validate
222-
223234
validate-documentation-style:
224235
if: |
225236
always() && !cancelled() &&
@@ -236,6 +247,7 @@ jobs:
236247

237248
# The official GitHub Action for Vale doesn't work, installing manually instead:
238249
# https://github.com/errata-ai/vale-action/issues/103
250+
# cf -> https://github.com/nf-core/website/pull/3509
239251
- name: Download Vale
240252
run: |
241253
curl -sL "https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz" -o vale.tar.gz

.github/workflows/sync-docs.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ on:
88
- stable
99
paths:
1010
- 'docs/docs/**'
11-
- 'docs/sidebars-infrahubctl.ts'
12-
- 'docs/sidebars-python-sdk.ts'
11+
- 'docs/sidebars/sidebars-infrahubctl.ts'
12+
- 'docs/sidebars/sidebars-python-sdk.ts'
13+
- 'docs/sidebars/sidebar-utils.ts'
1314

1415
jobs:
1516
sync:
@@ -33,8 +34,9 @@ jobs:
3334
rm -f target-repo/docs/sidebars-python-sdk.ts
3435
rm -f target-repo/docs/sidebars-infrahubctl.ts
3536
cp -r source-repo/docs/docs/* target-repo/docs/docs-python-sdk/
36-
cp source-repo/docs/sidebars-infrahubctl.ts target-repo/docs/
37-
cp source-repo/docs/sidebars-python-sdk.ts target-repo/docs/
37+
cp source-repo/docs/sidebars/sidebars-infrahubctl.ts target-repo/docs/
38+
cp source-repo/docs/sidebars/sidebars-python-sdk.ts target-repo/docs/
39+
cp source-repo/docs/sidebars/sidebar-utils.ts target-repo/docs/
3840
cd target-repo
3941
git config user.name github-actions
4042
git config user.email github-actions@github.com

.vale.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ BasedOnStyles =
2323

2424
[*]
2525
BasedOnStyles = Infrahub
26+
27+
# Generated API reference docs: use GeneratedRef spelling (allows snake_case)
28+
# instead of global Infrahub spelling. Must be last to override [*].
29+
[docs/docs/python-sdk/sdk_ref/**/*.mdx]
30+
BasedOnStyles = Infrahub, GeneratedRef
31+
Infrahub.spelling = NO
32+
BlockIgnores = (?s) *((import.*?\n)|(```.*?```\n))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
extends: spelling
3+
message: "Did you really mean '%s'?"
4+
level: error
5+
filters:
6+
- '[pP]y.*\b'
7+
- '\bimport_.*\b' # Ignore variables starting with 'import_'
8+
- '\w+__value' # Skip Infrahub filters in documentation (name__value)
9+
- '\b\w+_\w+\b' # Ignore snake_case identifiers in generated API reference docs
10+
ignore: spelling-exceptions.txt

.vale/styles/Infrahub/spelling.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ message: "Did you really mean '%s'?"
44
level: error
55
filters:
66
- '[pP]y.*\b'
7-
- '\bimport_.*\b' # New filter to ignore variables starting with 'import_'
8-
- '\w+__value' # New filter to skip Infrahub filters in documentation (name__value)
7+
- '\bimport_.*\b' # Ignore variables starting with 'import_'
8+
- '\w+__value' # Skip Infrahub filters in documentation (name__value)
99
ignore: spelling-exceptions.txt

.vale/styles/spelling-exceptions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Alibaba
33
Ansible
44
append_git_suffix
55
APIs
6+
Args
67
artifact_definitions
78
artifact_name
89
async

changelog/201.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Python SDK API documentation is now generated directly from the docstrings of the classes, functions, and methods contained in the code.

docs/AGENTS.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ Docusaurus documentation following Diataxis framework.
88
cd docs && npm install # Install deps
99
cd docs && npm start # Dev server at localhost:3000
1010
cd docs && npm run build # Build static site
11-
uv run invoke docs # Generate auto-docs
12-
uv run invoke docs-validate # Validate docs are current
11+
cd docs && npm test # Run sidebar utility tests
12+
uv run invoke docs # Build documentation website
13+
uv run invoke docs-generate # Regenerate all docs (infrahubctl CLI + Python SDK)
14+
uv run invoke docs-validate # Check that generated docs match committed files
1315
```
1416

1517
## Structure
@@ -23,11 +25,19 @@ docs/docs/
2325
└── infrahubctl/ # CLI docs (auto-generated)
2426
```
2527

28+
## Sidebars
29+
30+
Sidebar navigation is dynamic: `sidebars-*.ts` files read the filesystem at build time via utility functions in `sidebar-utils.ts`.
31+
32+
- **infrahubctl**: all `.mdx` files are discovered automatically and sorted alphabetically.
33+
- **python-sdk**: guides, topics, and reference sections preserve a defined display order; new files are appended alphabetically at the end.
34+
35+
No manual sidebar update is needed when adding a new `.mdx` file. However, to control the display order of a new page, add its doc ID to the ordered list in the corresponding `sidebars-*.ts` file.
36+
2637
## Adding Documentation
2738

2839
1. Create MDX file in appropriate directory
2940
2. Add frontmatter with `title`
30-
3. Update `sidebars-*.ts` for navigation
3141

3242
## MDX Pattern
3343

@@ -52,7 +62,7 @@ Use callouts for important notes.
5262
**Always**
5363

5464
- Include both async/sync examples using Tabs
55-
- Run `uv run invoke docs-validate` after code changes
65+
- Run `uv run invoke docs-validate` after code changes to verify generated docs are up to date
5666

5767
🚫 **Never**
5868

0 commit comments

Comments
 (0)