Skip to content

Commit a30f749

Browse files
authored
Support adding intersphinx links (#54)
* Support adding intersphinx links * Add basic test
1 parent 366f697 commit a30f749

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ on:
108108
description: A newline separated list of link targets that should not cause reference errors. A small RST file will be created during the build which contains these labels.
109109
required: false
110110
type: string
111+
intersphinx-links:
112+
description: |
113+
A newline separated list of entries to add to the intersphinx_mapping in the generated conf.py.
114+
Use the syntax `identifier:https://server/path` to add the identifier `identifier` with URL
115+
`https://server/path`.
116+
required: false
117+
type: string
111118

112119
outputs:
113120
artifact-name:
@@ -234,6 +241,7 @@ jobs:
234241
lenient: true
235242
fail-on-error: false
236243
provide-link-targets: ${{ inputs.provide-link-targets }}
244+
intersphinx-links: ${{ inputs.intersphinx-links }}
237245

238246
- name: Build BASE
239247
id: build-base
@@ -267,6 +275,7 @@ jobs:
267275
lenient: ${{ inputs.init-lenient }}
268276
fail-on-error: ${{ inputs.init-fail-on-error }}
269277
provide-link-targets: ${{ inputs.provide-link-targets }}
278+
intersphinx-links: ${{ inputs.intersphinx-links }}
270279

271280
- name: Build HEAD
272281
id: build-head

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ on:
6666
description: A newline separated list of link targets that should not cause reference errors. A small RST file will be created during the build which contains these labels.
6767
required: false
6868
type: string
69+
intersphinx-links:
70+
description: |
71+
A newline separated list of entries to add to the intersphinx_mapping in the generated conf.py.
72+
Use the syntax `identifier:https://server/path` to add the identifier `identifier` with URL
73+
`https://server/path`.
74+
required: false
75+
type: string
6976

7077
outputs:
7178
artifact-name:
@@ -152,6 +159,7 @@ jobs:
152159
lenient: ${{ inputs.init-lenient }}
153160
fail-on-error: ${{ inputs.init-fail-on-error }}
154161
provide-link-targets: ${{ inputs.provide-link-targets }}
162+
intersphinx-links: ${{ inputs.intersphinx-links }}
155163

156164
- name: Build
157165
id: build

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

Lines changed: 17 additions & 1 deletion
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 != '' }}]
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 }}
2121
runs-on: ubuntu-latest
2222
strategy:
2323
fail-fast: false
@@ -43,12 +43,20 @@ jobs:
4343
- |
4444
outside_reference_1
4545
outside_reference_2
46+
intersphinx-links: ['']
4647
include:
4748
- skip-init: true
4849
dest: .test/simple-build
4950
lenient: false # unused but needs a value
5051
fail-on-error: false # unused but needs a value
5152
provide-link-targets: ''
53+
- skip-init: false
54+
dest: ''
55+
lenient: false
56+
fail-on-error: true
57+
intersphinx-links: |
58+
amazon_aws:https://ansible-collections.github.io/amazon.aws/branch/main/
59+
ansible_devel:https://docs.ansible.com/ansible-core/devel/
5260
5361
steps:
5462
- name: Checkout
@@ -76,6 +84,7 @@ jobs:
7684
antsibull-docs-version: ${{ matrix.antsibull-docs-version }}
7785
lenient: ${{ matrix.lenient }}
7886
provide-link-targets: ${{ matrix.provide-link-targets }}
87+
intersphinx-links: ${{ matrix.intersphinx-links }}
7988

8089
- name: assert
8190
env:
@@ -121,6 +130,13 @@ jobs:
121130
${{ matrix.skip-init }} || ${{ matrix.provide-link-targets == '' }} || grep -- '^.. _outside_reference_2:$' rst/_targets.rst || exit 1
122131
${{ matrix.skip-init }} || ${{ matrix.provide-link-targets == '' }} || (pip install --upgrade rstcheck && rstcheck --report-level warning rst/_targets.rst) || exit 1
123132
133+
# Check that intersphinx config was added to conf.py
134+
# These end up wrapped in python formatting, so stick to a naive test.
135+
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'ansible_devel' conf.py || exit 1
136+
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'https://docs.ansible.com/ansible-core/devel/' conf.py || exit 1
137+
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'amazon_aws' conf.py || exit 1
138+
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'https://ansible-collections.github.io/amazon.aws/branch/main/' conf.py || exit 1
139+
124140
# check if provide-link-targets was not used when being empty
125141
# short circuit if skip-init is 'true' or matrix.provide-link-targets is not empty
126142
${{ matrix.skip-init }} || ${{ matrix.provide-link-targets != '' }} || ! test -e rst/_targets.rst || exit 1

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ inputs:
4040
description: A newline separated list of link targets that should not cause reference errors. A small RST file will be created during the build which contains these labels.
4141
required: false
4242
type: string
43+
intersphinx-links:
44+
description: |
45+
A newline separated list of entries to add to the intersphinx_mapping in the generated conf.py.
46+
Use the syntax `identifier:https://server/path` to add the identifier `identifier` with URL
47+
`https://server/path`.
48+
required: false
49+
type: string
4350
outputs:
4451
build-script:
4552
description: The path of the build script to execute.
@@ -56,6 +63,7 @@ runs:
5663
env:
5764
PIP_DISABLE_PIP_VERSION_CHECK: '1'
5865
_INPUT_PROVIDE_LINK_TARGETS: ${{ inputs.provide-link-targets }}
66+
_INPUT_INTERSPHINX_LINKS: ${{ inputs.intersphinx-links }}
5967
shell: bash
6068
run: |
6169
echo "::group::Installing antsibull-docs"
@@ -72,8 +80,21 @@ runs:
7280
mkdir -p "${{ inputs.dest-dir }}"
7381
echo "::endgroup::"
7482
83+
INTERSPHINX_ARGS=()
84+
85+
if [[ "${_INPUT_INTERSPHINX_LINKS}" != "" ]]; then
86+
echo "::group::Building list of intersphinx links"
87+
while read -r line; do
88+
if [ "${line}" != "" ]; then
89+
INTERSPHINX_ARGS+=("--intersphinx" "${line}")
90+
fi
91+
done <<< "${_INPUT_INTERSPHINX_LINKS}"
92+
echo "Intersphinx args: ${INTERSPHINX_ARGS[@]}"
93+
echo "::endgroup::"
94+
fi
95+
7596
echo "::group::Initialize Sphinx"
76-
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 }}
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[@]}
7798
echo "::endgroup::"
7899
fi
79100

0 commit comments

Comments
 (0)