Skip to content

Commit cb7f606

Browse files
Fix make gendocs error; temporarily pin CI to Python 3.13; parallelize documentation generation (#726)
* Fix make gendocs error; parallelize documentation generation * Bump docs workflow to 3.13 * oops * Pin versions
1 parent bf8a8fa commit cb7f606

File tree

11 files changed

+55
-29
lines changed

11 files changed

+55
-29
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Run Documentation Validation
33
on: pull_request
44

55
env:
6-
DEFAULT_PYTHON_VERSION: "3.10"
6+
DEFAULT_PYTHON_VERSION: "3.13"
77

88
jobs:
99
test-templated-docs:

.github/workflows/integration-tests-pr.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ jobs:
4242
- name: setup python 3
4343
uses: actions/setup-python@v6
4444
with:
45-
python-version: '3.x'
45+
# TODO: Unpin minor version after `ansible` package v13.0.0 releases.
46+
python-version: '3.13'
4647

4748
- name: install ansible dependencies
4849
run: ansible-galaxy collection install amazon.aws:==9.5.0
@@ -146,7 +147,8 @@ jobs:
146147
- name: Set up Python
147148
uses: actions/setup-python@v6
148149
with:
149-
python-version: '3.x'
150+
# TODO: Unpin minor version after `ansible` package v13.0.0 releases.
151+
python-version: '3.13'
150152

151153
- name: Install Linode CLI
152154
run: |

.github/workflows/integration-tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ jobs:
9191
- name: Set up Python
9292
uses: actions/setup-python@v6
9393
with:
94-
python-version: '3.x'
94+
# TODO: Unpin minor version after `ansible` package v13.0.0 releases.
95+
python-version: '3.13'
9596

9697
- name: Install Python dependencies
9798
run: pip3 install requests wheel boto3==1.35.99
@@ -176,7 +177,8 @@ jobs:
176177
- name: Set up Python
177178
uses: actions/setup-python@v6
178179
with:
179-
python-version: '3.x'
180+
# TODO: Unpin minor version after `ansible` package v13.0.0 releases.
181+
python-version: '3.13'
180182

181183
- name: Install Linode CLI
182184
run: |

.github/workflows/lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ jobs:
1212
- name: setup python 3
1313
uses: actions/setup-python@v6
1414
with:
15-
python-version: '3.x'
15+
# TODO: Unpin minor version after `ansible` package v13.0.0 releases.
16+
python-version: '3.13'
1617

1718
- name: install dependencies
1819
run: make deps

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
- name: setup python 3
2222
uses: actions/setup-python@v6
2323
with:
24-
python-version: '3.x'
24+
# TODO: Unpin minor version after `ansible` package v13.0.0 releases.
25+
python-version: '3.13'
2526

2627
- name: install dependencies
2728
run: make deps

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [ '3.9','3.10','3.11', '3.12' ]
13+
python-version: [ '3.10','3.11', '3.12', '3.13' ]
1414
defaults:
1515
run:
1616
working-directory: .ansible/collections/ansible_collections/linode/cloud

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ gendocs:
5656
mkdir -p $(DOCS_PATH)/modules $(DOCS_PATH)/inventory
5757

5858
DOCS_PATH=$(DOCS_PATH) ./scripts/specdoc_generate.sh
59-
ansible-doc-extractor --template=template/module.rst.j2 $(DOCS_PATH)/inventory plugins/inventory/*.py
59+
ansible-doc-extractor --template=template/module.rst.j2 $(DOCS_PATH)/inventory $(abspath plugins/inventory/*.py)
6060
python3 scripts/render_readme.py $(COLLECTION_VERSION)
6161

6262
# if want to add all the test add the tag --tags never at the end
@@ -126,11 +126,14 @@ endif
126126
@echo "api_version: $${LINODE_API_VERSION:-$${TEST_API_VERSION:-v4beta}}" >> $(INTEGRATION_CONFIG)
127127
@echo "ca_file: $${LINODE_CA:-$${TEST_API_CA}}" >> $(INTEGRATION_CONFIG)
128128

129+
129130
inject:
130131
@echo "Injecting documentation into source files"
131-
for f in `ls ./plugins/modules/*.py`; do echo "$$f" && ansible-specdoc -j -i $$f; done
132-
ansible-test sanity --test ansible-doc
132+
find ./plugins/modules -maxdepth 1 -name '*.py' -print0 | \
133+
xargs -I {} -0 -P 5 bash -c 'export TARGET="{}"; echo "$$TARGET" && ansible-specdoc -j -i "$$TARGET";'
133134

134135
inject-clean:
135136
@echo "Removing injected documentation from source files"
136-
for f in `ls ./plugins/modules/*.py`; do echo "$$f" && ansible-specdoc -jc -i $$f; done
137+
find ./plugins/modules -maxdepth 1 -name '*.py' -print0 | \
138+
xargs -I {} -0 -P 5 bash -c 'export TARGET="{}"; echo "$$TARGET" && ansible-specdoc -jc -i "$$TARGET";'
139+

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ Use-case examples for this collection can be found [here](./examples/README.md).
199199
200200
The following section outlines various information relating to the development of this collection.
201201
202+
### Generating Documentation
203+
204+
This collection's documentation is generated dynamically from the specification defined in each module using
205+
[ansible-specdoc](https://github.com/linode/ansible-specdoc).
206+
202207
### Attaching a Debugger
203208
204209
To quickly and easily attach a debugger to a running module in this collection,

docs/inventory/instance.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,29 @@ Parameters
7676

7777

7878
**parent_group (type=str):**
79-
\• parent group for keyed group
79+
\• parent group for keyed group.
8080

8181

8282
**prefix (type=str):**
83-
\• A keyed group name will start with this prefix
83+
\• A keyed group name will start with this prefix.
8484

8585

8686
**separator (type=str, default=_):**
87-
\• separator used to build the keyed group name
87+
\• separator used to build the keyed group name.
8888

8989

9090
**key (type=str):**
91-
\• The key from input dictionary used to generate groups
91+
\• The key from input dictionary used to generate groups.
9292

9393

9494
**default_value (type=str):**
95-
\• The default value when the host variable's value is an empty string.
95+
\• The default value when the host variable's value is :literal:`None` or an empty string.
9696

9797
\• This option is mutually exclusive with :literal:`keyed\_groups[].trailing\_separator`.
9898

9999

100100
**trailing_separator (type=bool, default=True):**
101-
\• Set this option to :literal:`False` to omit the :literal:`keyed\_groups[].separator` after the host variable when the value is an empty string.
101+
\• Set this option to :literal:`false` to omit the :literal:`keyed\_groups[].separator` after the host variable when the value is :literal:`None` or an empty string.
102102

103103
\• This option is mutually exclusive with :literal:`keyed\_groups[].default\_value`.
104104

@@ -109,13 +109,13 @@ Parameters
109109

110110

111111
**leading_separator (type=boolean, default=True):**
112-
\• Use in conjunction with keyed\_groups.
112+
\• Use in conjunction with :literal:`keyed\_groups`.
113113

114114
\• By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore.
115115

116-
\• This is because the default prefix is "" and the default separator is "\_".
116+
\• This is because the default prefix is :literal:`""` and the default separator is :literal:`"\_"`.
117117

118-
\• Set this option to False to omit the leading underscore (or other separator) if no prefix is given.
118+
\• Set this option to :literal:`false` to omit the leading underscore (or other separator) if no prefix is given.
119119

120120
\• If the group name is derived from a mapping the separator is still used to concatenate the items.
121121

scripts/specdoc_generate.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#!/bin/bash
22

3-
DPATH="${DOCS_PATH:="docs"}"
4-
5-
for f in plugins/modules/*.py
6-
do
7-
echo "$f"
8-
MODULE_NAME="$(basename "$f" .py)"
9-
PYTHONWARNINGS="ignore" ansible-specdoc -i "$f" -f jinja2 -t template/module.md.j2 -o $DPATH/modules/"$MODULE_NAME".md; #> /dev/null || exit 1;
10-
done
3+
DOCS_PATH="${DOCS_PATH:="docs"}"
4+
5+
export PYTHONWARNINGS="ignore"
6+
7+
render_module_doc() {
8+
MODULE_NAME="$(basename "$1" .py)"
9+
10+
echo "Rendering: $MODULE_NAME"
11+
12+
ansible-specdoc -i "$1" -f jinja2 -t template/module.md.j2 -o "$DOCS_PATH/modules/$MODULE_NAME.md"
13+
}
14+
15+
export -f render_module_doc
16+
17+
find plugins/modules -maxdepth 1 -name '*.py' -print0 | xargs -I {} -0 -P 5 bash -c 'render_module_doc {}'

0 commit comments

Comments
 (0)