Skip to content

Commit

Permalink
init migration python sdk doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wartraxx51 committed Feb 24, 2025
1 parent 3870abe commit 7868fd7
Show file tree
Hide file tree
Showing 82 changed files with 20,435 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ poetry_files: &poetry_files

doc_files: &doc_files
- "docs/**"
- package.json
- package-lock.json

python_all: &python_all
- "**/*.py"
Expand All @@ -36,3 +38,6 @@ documentation_all:
- *development_files
- *doc_files
- *markdown_all

infrahub_reference_generated: &infrahub_reference_generated
- "docs/docs/python-sdk/reference/config.mdx"
88 changes: 87 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ env:
INFRAHUB_IMAGE_VER: "local"
PYTEST_XDIST_WORKER_COUNT: 4
INFRAHUB_TEST_IN_DOCKER: 1
VALE_VERSION: "3.0.7"
VALE_VERSION: "3.7.1"
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
METRICS_ENDPOINT: ${{ secrets.METRICS_ENDPOINT }}

Expand All @@ -36,6 +36,7 @@ jobs:
timeout-minutes: 5
outputs:
documentation: ${{ steps.changes.outputs.documentation_all }}
documentation_generated: ${{ steps.changes.outputs.documentation_generated_all }}
helm: ${{ steps.changes.outputs.helm_all }}
python: ${{ steps.changes.outputs.python_all }}
yaml: ${{ steps.changes.outputs.yaml_all }}
Expand Down Expand Up @@ -115,6 +116,91 @@ jobs:
SHELLCHECK_OPTS: --exclude=SC2086 --exclude=SC2046 --exclude=SC2004 --exclude=SC2129


documentation:
defaults:
run:
working-directory: ./docs
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.documentation == 'true'
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
submodules: true
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: docs/package-lock.json
- name: "Install dependencies"
run: npm install
- name: "Setup Python environment"
run: "pip install invoke toml"
- name: "Build docs website"
run: "invoke docs"

validate-generated-documentation:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(needs.files-changed.outputs.python == 'true') || (needs.files-changed.outputs.documentation_generated == 'true')
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: "Setup Python environment"
run: |
pipx install poetry==1.8.5
poetry config virtualenvs.create true --local
poetry env use 3.12
- name: "Install dependencies"
run: "poetry install --no-interaction --no-ansi --extras ctl"
- name: "Setup environment"
run: "pip install invoke toml"
- name: "Validate generated documentation"
run: "poetry run invoke docs-validate"

validate-documentation-style:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
submodules: true

# The official GitHub Action for Vale doesn't work, installing manually instead:
# https://github.com/errata-ai/vale-action/issues/103
- name: Download Vale
run: |
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
tar -xzf vale.tar.gz
env:
VALE_VERSION: ${{ env.VALE_VERSION }}
- name: "Validate documentation style"
run: ./vale $(find ./docs -type f \( -name "*.mdx" -o -name "*.md" \) )

unit-tests:
env:
# workaround for Rich table column width
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/sync-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# yamllint disable rule:truthy rule:line-length
name: Sync Folders

on:
push:
branches:
- stable
paths:
- 'docs/docs/**'
- 'docs/sidebars.ts'
pull_request:
branches:
- stable

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
path: source-repo

- name: Checkout target repository
uses: actions/checkout@v4
with:
repository: opsmill/infrahub-docs
token: ${{ secrets.PAT_TOKEN }}
path: target-repo

- name: Sync folders
run: |
rm -rf target-repo/docs/docs-python-sdk/*
rm -f target-repo/docs/sidebars-python-sdk.ts
rm -f target-repo/docs/sidebars-infrahubctl.ts
cp -r source-repo/docs/docs/* target-repo/docs/docs-python-sdk/
cp source-repo/docs/sidebars-infrahubctl.ts target-repo/docs/
cp source-repo/docs/sidebars-python-sdk.ts target-repo/docs/
cd target-repo
git config user.name github-actions
git config user.email github-actions@github.com
git add .
if ! (git diff --quiet && git diff --staged --quiet); then git commit -m "Sync doc Python SDK from infrahub repo" && git push; fi
15 changes: 15 additions & 0 deletions .vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
StylesPath = .vale/styles

MinAlertLevel = warning

[formats]
mdx = md

[docs/**/*.md]
BasedOnStyles = Infrahub
;(import.*?\n) to ignore import statement in .mdx
;(```.*?```\n) to ignore code block in .mdx
BlockIgnores = (?s) *((import.*?\n)|(```.*?```\n))

[*]
BasedOnStyles = Infrahub
14 changes: 14 additions & 0 deletions .vale/styles/Infrahub/branded-terms-case-swap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
extends: substitution
message: Use '%s' instead of '%s'
level: error
ignorecase: false
action:
name: replace
swap:
(?i:[^/]Github): GitHub
(?i:gitpod): GitPod
(?i:[^/]Graphql): GraphQL
infrahub(?:\s|$): Infrahub
(?i:Openconfig): OpenConfig
opsmill(?:\s|$): OpsMill
8 changes: 8 additions & 0 deletions .vale/styles/Infrahub/colon-space.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
extends: substitution
message: "Use a space after a colon, but not before"
level: warning
ignorecase: true
nonword: true
swap:
'(?<=\s):(?=\s+)': ': '
12 changes: 12 additions & 0 deletions .vale/styles/Infrahub/eg-ie.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
extends: substitution
message: "Instead of %s, use ',i.e.,' or 'for example:'."
level: warning
ignorecase: true
nonword: true
action:
name: replace
swap:
- e\.g\.: i.e.
- e\. g\.: i.e.
- i\. e\.: i.e.
8 changes: 8 additions & 0 deletions .vale/styles/Infrahub/oxford-comma.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
extends: existence
message: "Use a comma before the last 'and' or 'or' in a list of items."
level: suggestion
scope: sentence
nonword: true
tokens:
- '(?:[^\s,]+,){1,} \w+ (?:and|or) \w+[.?!]'
78 changes: 78 additions & 0 deletions .vale/styles/Infrahub/sentence-case.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
extends: capitalization
message: "'%s' should use sentence case"
level: warning
scope:
- heading.h1
- heading.h2
- heading.h3
- heading.h4
- heading.h5
- heading.h6
match: $sentence
exceptions:
- Alpha
- Ansible
- API
- Attributes
- AWS S3
- Beta
- BGP
- CA certificates
- CI
- Codespaces
- Computed Attribute
- Computed Attributes
- CoreArtifactTarget
- CoreRepository
- CoreGroup
- Docker Compose
- E2E
- Generics
- Git
- GitHub
- GitHub Codespaces
- GitLab
- GitPod
- GraphQL
- GraphQLQuery
- include_in_menu & menu_placement
- Helm
- High Availability
- Human Friendly Identifier
- Infrahub
- infrahubctl
- IPHost
- IP
- IPAM
- IPNetwork
- IP Fabric
- JavaScript
- JetStream
- Jinja
- Jinja2
- JWT
- Namespace
- NATS
- Node
- OAuth2
- OIDC
- Open ID Connect
- OpsMill
- Pydantic
- Python
- RabbitMQ
- REST
- RFile
- SDK
- Single sign-on
- SSO
- TLS
- Tony Stark
- TransformPython
- Trusted Root Certificate Store
- UI
- Vale
- VS Code
- VS Code extensions
- WebUI
9 changes: 9 additions & 0 deletions .vale/styles/Infrahub/simple-easy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
extends: existence
message: "Remove %s and avoid words that minimize the effort level required."
level: warning
ignorecase: true
tokens:
- easy
- simple
- simply
9 changes: 9 additions & 0 deletions .vale/styles/Infrahub/spelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
extends: spelling
message: "Did you really mean '%s'?"
level: error
filters:
- '[pP]y.*\b'
- '\bimport_.*\b' # New filter to ignore variables starting with 'import_'
- '\w+__value' # New filter to skip Infrahub filters in documentation (name__value)
ignore: spelling-exceptions.txt
10 changes: 10 additions & 0 deletions .vale/styles/Infrahub/swap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
extends: substitution
message: "Use '%s' instead of '%s'"
level: error
ignorecase: true
action:
name: replace
swap:
config\b(?!\.\w): configuration
repo: repository
Loading

0 comments on commit 7868fd7

Please sign in to comment.