Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support adding intersphinx links #54

Merged
merged 2 commits into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/_shared-docs-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ on:
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.
required: false
type: string
intersphinx-links:
description: |
A newline separated list of entries to add to the intersphinx_mapping in the generated conf.py.
Use the syntax `identifier:https://server/path` to add the identifier `identifier` with URL
`https://server/path`.
required: false
type: string

outputs:
artifact-name:
Expand Down Expand Up @@ -234,6 +241,7 @@ jobs:
lenient: true
fail-on-error: false
provide-link-targets: ${{ inputs.provide-link-targets }}
intersphinx-links: ${{ inputs.intersphinx-links }}

- name: Build BASE
id: build-base
Expand Down Expand Up @@ -267,6 +275,7 @@ jobs:
lenient: ${{ inputs.init-lenient }}
fail-on-error: ${{ inputs.init-fail-on-error }}
provide-link-targets: ${{ inputs.provide-link-targets }}
intersphinx-links: ${{ inputs.intersphinx-links }}

- name: Build HEAD
id: build-head
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/_shared-docs-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ on:
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.
required: false
type: string
intersphinx-links:
description: |
A newline separated list of entries to add to the intersphinx_mapping in the generated conf.py.
Use the syntax `identifier:https://server/path` to add the identifier `identifier` with URL
`https://server/path`.
required: false
type: string

outputs:
artifact-name:
Expand Down Expand Up @@ -152,6 +159,7 @@ jobs:
lenient: ${{ inputs.init-lenient }}
fail-on-error: ${{ inputs.init-fail-on-error }}
provide-link-targets: ${{ inputs.provide-link-targets }}
intersphinx-links: ${{ inputs.intersphinx-links }}

- name: Build
id: build
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/test-action-build-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

jobs:
tests:
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 != '' }}]
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 }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -40,12 +40,20 @@ jobs:
- |
outside_reference_1
outside_reference_2
intersphinx-links: ['']
include:
- skip-init: true
dest: .test/simple-build
lenient: false # unused but needs a value
fail-on-error: false # unused but needs a value
provide-link-targets: ''
- skip-init: false
dest: ''
lenient: false
fail-on-error: true
intersphinx-links: |
amazon_aws:https://ansible-collections.github.io/amazon.aws/branch/main/
ansible_devel:https://docs.ansible.com/ansible-core/devel/

steps:
- name: Checkout
Expand Down Expand Up @@ -73,6 +81,7 @@ jobs:
antsibull-docs-version: ${{ matrix.antsibull-docs-version }}
lenient: ${{ matrix.lenient }}
provide-link-targets: ${{ matrix.provide-link-targets }}
intersphinx-links: ${{ matrix.intersphinx-links }}

- name: assert
env:
Expand Down Expand Up @@ -118,6 +127,13 @@ jobs:
${{ matrix.skip-init }} || ${{ matrix.provide-link-targets == '' }} || grep -- '^.. _outside_reference_2:$' rst/_targets.rst || exit 1
${{ matrix.skip-init }} || ${{ matrix.provide-link-targets == '' }} || (pip install rstcheck && rstcheck --report warning rst/_targets.rst) || exit 1

# Check that intersphinx config was added to conf.py
# These end up wrapped in python formatting, so stick to a naive test.
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'ansible_devel' conf.py || exit 1
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'https://docs.ansible.com/ansible-core/devel/' conf.py || exit 1
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'amazon_aws' conf.py || exit 1
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'https://ansible-collections.github.io/amazon.aws/branch/main/' conf.py || exit 1

# check if provide-link-targets was not used when being empty
# short circuit if skip-init is 'true' or matrix.provide-link-targets is not empty
${{ matrix.skip-init }} || ${{ matrix.provide-link-targets != '' }} || ! test -e rst/_targets.rst || exit 1
23 changes: 22 additions & 1 deletion actions/ansible-docs-build-init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ inputs:
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.
required: false
type: string
intersphinx-links:
description: |
A newline separated list of entries to add to the intersphinx_mapping in the generated conf.py.
Use the syntax `identifier:https://server/path` to add the identifier `identifier` with URL
`https://server/path`.
required: false
type: string
outputs:
build-script:
description: The path of the build script to execute.
Expand All @@ -56,6 +63,7 @@ runs:
env:
PIP_DISABLE_PIP_VERSION_CHECK: '1'
_INPUT_PROVIDE_LINK_TARGETS: ${{ inputs.provide-link-targets }}
_INPUT_INTERSPHINX_LINKS: ${{ inputs.intersphinx-links }}
shell: bash
run: |
echo "::group::Installing antsibull-docs"
Expand All @@ -72,8 +80,21 @@ runs:
mkdir -p "${{ inputs.dest-dir }}"
echo "::endgroup::"

INTERSPHINX_ARGS=()

if [[ "${_INPUT_INTERSPHINX_LINKS}" != "" ]]; then
echo "::group::Building list of intersphinx links"
while read -r line; do
if [ "${line}" != "" ]; then
INTERSPHINX_ARGS+=("--intersphinx" "${line}")
fi
done <<< "${_INPUT_INTERSPHINX_LINKS}"
echo "Intersphinx args: ${INTERSPHINX_ARGS[@]}"
echo "::endgroup::"
fi

echo "::group::Initialize Sphinx"
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 }}
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[@]}
echo "::endgroup::"
fi

Expand Down