Skip to content

Commit f54aca1

Browse files
authored
Allow to append something to conf.py. (#73)
1 parent 3f0de33 commit f54aca1

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ on:
9999
`conf.py` in `html_theme_options`
100100
required: false
101101
type: string
102+
init-append-conf-py:
103+
description: |
104+
If provided, this text will be appended to the generated `conf.py` as-is.
105+
required: false
106+
type: string
102107
artifact-name:
103108
description: The name of the artifact to upload.
104109
required: false
@@ -312,6 +317,7 @@ jobs:
312317
extra-conf: ${{ inputs.init-extra-conf }}
313318
extra-html-context: ${{ inputs.init-extra-html-context }}
314319
extra-html-theme-options: ${{ inputs.init-extra-html-theme-options }}
320+
append-conf-py: ${{ inputs.init-append-conf-py }}
315321

316322
- name: Build BASE
317323
id: build-base
@@ -356,6 +362,7 @@ jobs:
356362
extra-conf: ${{ inputs.init-extra-conf }}
357363
extra-html-context: ${{ inputs.init-extra-html-context }}
358364
extra-html-theme-options: ${{ inputs.init-extra-html-theme-options }}
365+
append-conf-py: ${{ inputs.init-append-conf-py }}
359366

360367
- name: Build HEAD
361368
id: build-head

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ on:
101101
`conf.py` in `html_theme_options`
102102
required: false
103103
type: string
104+
init-append-conf-py:
105+
description: |
106+
If provided, this text will be appended to the generated `conf.py` as-is.
107+
required: false
108+
type: string
104109
artifact-upload:
105110
description: Whether or not to upload the build as an artifact.
106111
type: boolean
@@ -230,6 +235,7 @@ jobs:
230235
extra-conf: ${{ inputs.init-extra-conf }}
231236
extra-html-context: ${{ inputs.init-extra-html-context }}
232237
extra-html-theme-options: ${{ inputs.init-extra-html-theme-options }}
238+
append-conf-py: ${{ inputs.init-append-conf-py }}
233239

234240
- name: Build
235241
id: build

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ jobs:
5959
- ''
6060
extra-html-theme-options:
6161
- ''
62+
append-conf-py:
63+
- ''
6264
intersphinx-links: ['']
6365
squash-hierarchy:
6466
- false
@@ -100,6 +102,9 @@ jobs:
100102
extra-html-theme-options: |
101103
foo=baz
102104
long=Yet "another" long 'quotes' text
105+
append-conf-py: |
106+
# This is a special comment.
107+
# FOO BAR 1234
103108
104109
steps:
105110
- name: Checkout
@@ -137,6 +142,7 @@ jobs:
137142
extra-conf: ${{ matrix.extra-conf }}
138143
extra-html-context: ${{ matrix.extra-html-context }}
139144
extra-html-theme-options: ${{ matrix.extra-html-theme-options }}
145+
append-conf-py: ${{ matrix.append-conf-py }}
140146

141147
- name: assert
142148
env:
@@ -233,5 +239,8 @@ jobs:
233239
# TODO Check extra-html-context
234240
# TODO Check extra-html-theme-options
235241
242+
${{ matrix.append-conf-py && 'true' || 'false' }} && (grep -E '^# This is a special comment\.$' conf.py || exit 1)
243+
${{ matrix.append-conf-py && 'true' || 'false' }} && (grep -E '^# FOO BAR 1234$' conf.py || exit 1)
244+
236245
# This must be the last line
237246
exit 0

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ inputs:
9797
A newline separated list of `key=value` entries that will be added to the generated
9898
`conf.py` in `html_theme_options`
9999
required: false
100+
append-conf-py:
101+
description: |
102+
If provided, this text will be appended to the generated `conf.py` as-is.
103+
required: false
100104
outputs:
101105
build-script:
102106
description: The path of the build script to execute.
@@ -121,6 +125,7 @@ runs:
121125
_INPUT_EXTRA_CONF: ${{ inputs.extra-conf }}
122126
_INPUT_EXTRA_HTML_CONTEXT: ${{ inputs.extra-html-context }}
123127
_INPUT_EXTRA_HTML_THEME_OPTIONS: ${{ inputs.extra-html-theme-options }}
128+
_INPUT_APPEND_CONF_PY: ${{ inputs.append-conf-py }}
124129
shell: bash
125130
run: |
126131
echo "::group::Installing antsibull-docs"
@@ -229,6 +234,15 @@ runs:
229234
echo "::endgroup::"
230235
fi
231236
237+
if [[ "${_INPUT_APPEND_CONF_PY}" != "" ]]; then
238+
echo "::group::Appending to conf.py"
239+
echo "${_INPUT_APPEND_CONF_PY}" >> "${{ inputs.dest-dir }}/conf.py"
240+
echo "Content of ${{ inputs.dest-dir }}/conf.py:"
241+
echo ""
242+
cat "${{ inputs.dest-dir }}/conf.py"
243+
echo "::endgroup::"
244+
fi
245+
232246
echo "::group::Install additional requirements"
233247
pip install -r "${{ inputs.dest-dir }}/requirements.txt"
234248
echo "::endgroup::"

0 commit comments

Comments
 (0)