Skip to content

Commit 6fc0639

Browse files
authored
Allow to pass --squash-hierarchy to 'antsibull-docs sphinx-init' (#58)
* Allow to pass --squash-hierarchy to 'antsibull-docs sphinx-init'. * Improve/fix tests. * TMP debug * Fix bug in tests. * Revert "TMP debug" This reverts commit 54713f1.
1 parent 541c358 commit 6fc0639

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

.github/workflows/_shared-docs-build-pr.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ on:
115115
`https://server/path`.
116116
required: false
117117
type: string
118+
squash-hierarchy:
119+
description: |
120+
If 'true', the collection documentation will be created at top-level and not in a subdirectory `namespace/collection_name/`.
121+
Has no effect if init-dest-dir is supplied.
122+
required: false
123+
default: 'false'
118124

119125
outputs:
120126
artifact-name:
@@ -242,6 +248,7 @@ jobs:
242248
fail-on-error: false
243249
provide-link-targets: ${{ inputs.provide-link-targets }}
244250
intersphinx-links: ${{ inputs.intersphinx-links }}
251+
squash-hierarchy: ${{ input.squash-hierarchy }}
245252

246253
- name: Build BASE
247254
id: build-base
@@ -276,6 +283,7 @@ jobs:
276283
fail-on-error: ${{ inputs.init-fail-on-error }}
277284
provide-link-targets: ${{ inputs.provide-link-targets }}
278285
intersphinx-links: ${{ inputs.intersphinx-links }}
286+
squash-hierarchy: ${{ input.squash-hierarchy }}
279287

280288
- name: Build HEAD
281289
id: build-head

.github/workflows/_shared-docs-build-push.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ on:
7373
`https://server/path`.
7474
required: false
7575
type: string
76+
squash-hierarchy:
77+
description: |
78+
If 'true', the collection documentation will be created at top-level and not in a subdirectory `namespace/collection_name/`.
79+
Has no effect if init-dest-dir is supplied.
80+
required: false
81+
default: 'false'
7682

7783
outputs:
7884
artifact-name:
@@ -160,6 +166,7 @@ jobs:
160166
fail-on-error: ${{ inputs.init-fail-on-error }}
161167
provide-link-targets: ${{ inputs.provide-link-targets }}
162168
intersphinx-links: ${{ inputs.intersphinx-links }}
169+
squash-hierarchy: ${{ input.squash-hierarchy }}
163170

164171
- name: Build
165172
id: build

.github/workflows/test-action-build-init.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717

1818
jobs:
1919
tests:
20-
name: Init [ver=${{ matrix.antsibull-docs-version }}, skip=${{ matrix.skip-init }}, lenient=${{ matrix.lenient }}, fail-on-error=${{ matrix.fail-on-error }}, dest=${{ matrix.dest }}, collections=${{ matrix.collections }}, link-targets=${{ matrix.provide-link-targets != '' }}], intersphinx-links=${{ matrix.intersphinx-links }}
20+
name: Init [ver=${{ matrix.antsibull-docs-version }}, skip=${{ matrix.skip-init }}, lenient=${{ matrix.lenient }}, fail-on-error=${{ matrix.fail-on-error }}, dest=${{ matrix.dest }}, collections=${{ matrix.collections }}, link-targets=${{ matrix.provide-link-targets != '' }}], intersphinx-links=${{ matrix.intersphinx-links }}, squash-hierarchy=${{ matrix.squash-hierarchy }}
2121
runs-on: ubuntu-latest
2222
strategy:
2323
fail-fast: false
@@ -44,19 +44,29 @@ jobs:
4444
outside_reference_1
4545
outside_reference_2
4646
intersphinx-links: ['']
47+
squash-hierarchy:
48+
- false
4749
include:
4850
- skip-init: true
4951
dest: .test/simple-build
5052
lenient: false # unused but needs a value
5153
fail-on-error: false # unused but needs a value
5254
provide-link-targets: ''
55+
squash-hierarchy: false
5356
- skip-init: false
5457
dest: ''
5558
lenient: false
5659
fail-on-error: true
5760
intersphinx-links: |
5861
amazon_aws:https://ansible-collections.github.io/amazon.aws/branch/main/
5962
ansible_devel:https://docs.ansible.com/ansible-core/devel/
63+
squash-hierarchy: false
64+
- skip-init: false
65+
collections: foo.bar
66+
dest: ''
67+
lenient: false
68+
fail-on-error: true
69+
squash-hierarchy: true
6070

6171
steps:
6272
- name: Checkout
@@ -76,7 +86,7 @@ jobs:
7686
id: init
7787
uses: ./actions/ansible-docs-build-init
7888
with:
79-
collections: ${{ matrix.collection }}
89+
collections: ${{ matrix.collections }}
8090
# combining runner.temp and /docsbuild copies the default from the action
8191
# please keep in sync!
8292
dest-dir: ${{ matrix.dest || format('{0}/{1}', runner.temp, '/docsbuild') }}
@@ -85,12 +95,15 @@ jobs:
8595
lenient: ${{ matrix.lenient }}
8696
provide-link-targets: ${{ matrix.provide-link-targets }}
8797
intersphinx-links: ${{ matrix.intersphinx-links }}
98+
squash-hierarchy: ${{ matrix.squash-hierarchy }}
8899

89100
- name: assert
90101
env:
91102
output_build_script: ${{ steps.init.outputs.build-script }}
92103
output_build_html: ${{ steps.init.outputs.build-html }}
93104
run: |
105+
set -x
106+
94107
# check that the build script exists
95108
[ -f "$output_build_script" ] || exit 1
96109
@@ -137,6 +150,9 @@ jobs:
137150
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'amazon_aws' conf.py || exit 1
138151
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'https://ansible-collections.github.io/amazon.aws/branch/main/' conf.py || exit 1
139152
153+
# Check that the squash hierarchy flag was added
154+
${{ matrix.squash-hierarchy }} && (grep -q -- ' --squash-hierarchy ' build.sh || exit 1)
155+
140156
# check if provide-link-targets was not used when being empty
141157
# short circuit if skip-init is 'true' or matrix.provide-link-targets is not empty
142158
${{ matrix.skip-init }} || ${{ matrix.provide-link-targets != '' }} || ! test -e rst/_targets.rst || exit 1

actions/ansible-docs-build-init/action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ inputs:
4747
`https://server/path`.
4848
required: false
4949
type: string
50+
squash-hierarchy:
51+
description: |
52+
If 'true', the collection documentation will be created at top-level and not in a subdirectory `namespace/collection_name/`.
53+
This is only possible if 'collections' contains exactly one collection.
54+
required: false
55+
default: 'false'
5056
outputs:
5157
build-script:
5258
description: The path of the build script to execute.
@@ -94,7 +100,7 @@ runs:
94100
fi
95101
96102
echo "::group::Initialize Sphinx"
97-
antsibull-docs sphinx-init --use-current ${{ fromJSON(inputs.fail-on-error) && '--fail-on-error' || '' }} ${{ fromJSON(inputs.lenient) && '--lenient' || '' }} --dest-dir "${{ inputs.dest-dir }}" ${{ inputs.collections }} ${INTERSPHINX_ARGS[@]}
103+
antsibull-docs sphinx-init --use-current ${{ fromJSON(inputs.fail-on-error) && '--fail-on-error' || '' }} ${{ fromJSON(inputs.lenient) && '--lenient' || '' }} ${{ fromJSON(inputs.squash-hierarchy) && '--squash-hierarchy' || '' }} --dest-dir "${{ inputs.dest-dir }}" ${{ inputs.collections }} ${INTERSPHINX_ARGS[@]}
98104
echo "::endgroup::"
99105
fi
100106

0 commit comments

Comments
 (0)