From fb9c0feec8e588df454254c201e262584534d14e Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 3 Jul 2024 02:59:54 +0200 Subject: [PATCH] btrfs-progs: ci: build html manual page previews if source changed Similar to the manual page on terminal preview, also do the html output that will be on the RTD page. Due to the way how it's displayed in the CI action summary the CSS is missing and there are some visual artifacts, e.g. in the option lists or special characters. Issue: #824 Signed-off-by: David Sterba --- .github/workflows/devel.yml | 12 +++++++++- Documentation/html-preview.sh | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 Documentation/html-preview.sh diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 0cae4492..b6091913 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -28,7 +28,17 @@ jobs: run: ./autogen.sh && CC=${{ matrix.compiler }} ./configure - name: Documentation run: make V=1 -C Documentation - - name: Generate manual pages preview + - name: Generate manual pages preview (html) + if: ${{ matrix.compiler == 'gcc' }} + env: + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + run: | + for file in ${ALL_CHANGED_FILES}; do + echo "$file was changed, generate preview to summary" + Documentation/html-preview.sh "$file" >> $GITHUB_STEP_SUMMARY + done + - run: echo '
' >> $GITHUB_STEP_SUMMARY + - name: Generate manual pages preview (man) if: ${{ matrix.compiler == 'gcc' }} env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} diff --git a/Documentation/html-preview.sh b/Documentation/html-preview.sh new file mode 100755 index 00000000..372f6873 --- /dev/null +++ b/Documentation/html-preview.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Generate manual page preview as rendered by 'make html', removed some styling +# so there can be visual artifacts, usable for CI summary + +if ! [ -f "$1" ]; then + exit 0 +fi + +prefix=Documentation/ +here=$(pwd) + +if [ "$(basename \"$here\")" = 'Documentation' ]; then + prefix= +fi + +fn="$1" +bn=$(basename "$fn" .rst) +html=$(find "${prefix}"_build/html -name "$bn".'html') + +if ! [ -f "$html" ]; then + #echo "ERROR: cannot find html page '$html' from bn $bn fn $fn
" + exit 0 +fi + +cat << EOF +
+$fn + +EOF + +# Up to
, before that there's left bar navigation + +cat "$html" | sed -e 's/^\s\+//' | awk ' +/^
/ { doit=1; next; } +/^<\/body>/ { doit=0; next; } +doit==1 { print; }' + +cat << EOF + +
+EOF