Skip to content

Commit fb9c0fe

Browse files
committed
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 <[email protected]>
1 parent ef8e050 commit fb9c0fe

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

.github/workflows/devel.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ jobs:
2828
run: ./autogen.sh && CC=${{ matrix.compiler }} ./configure
2929
- name: Documentation
3030
run: make V=1 -C Documentation
31-
- name: Generate manual pages preview
31+
- name: Generate manual pages preview (html)
32+
if: ${{ matrix.compiler == 'gcc' }}
33+
env:
34+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
35+
run: |
36+
for file in ${ALL_CHANGED_FILES}; do
37+
echo "$file was changed, generate preview to summary"
38+
Documentation/html-preview.sh "$file" >> $GITHUB_STEP_SUMMARY
39+
done
40+
- run: echo '<hr>' >> $GITHUB_STEP_SUMMARY
41+
- name: Generate manual pages preview (man)
3242
if: ${{ matrix.compiler == 'gcc' }}
3343
env:
3444
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}

Documentation/html-preview.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
# Generate manual page preview as rendered by 'make html', removed some styling
3+
# so there can be visual artifacts, usable for CI summary
4+
5+
if ! [ -f "$1" ]; then
6+
exit 0
7+
fi
8+
9+
prefix=Documentation/
10+
here=$(pwd)
11+
12+
if [ "$(basename \"$here\")" = 'Documentation' ]; then
13+
prefix=
14+
fi
15+
16+
fn="$1"
17+
bn=$(basename "$fn" .rst)
18+
html=$(find "${prefix}"_build/html -name "$bn".'html')
19+
20+
if ! [ -f "$html" ]; then
21+
#echo "ERROR: cannot find html page '$html' from bn $bn fn $fn <br/>"
22+
exit 0
23+
fi
24+
25+
cat << EOF
26+
<details>
27+
<summary>$fn</summary>
28+
29+
EOF
30+
31+
# Up to <div itemprop="articleBody">, before that there's left bar navigation
32+
33+
cat "$html" | sed -e 's/^\s\+//' | awk '
34+
/^<div itemprop=.articleBody.>/ { doit=1; next; }
35+
/^<\/body>/ { doit=0; next; }
36+
doit==1 { print; }'
37+
38+
cat << EOF
39+
40+
</details>
41+
EOF

0 commit comments

Comments
 (0)