mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-25 04:02:28 +03:00
man.serenityos.org: Simplify local builds
I simply extracted the script from .github/workflows/manpages.yml, without significant modification.
This commit is contained in:
parent
5c04a2d4b3
commit
7e52b6fa24
Notes:
sideshowbarker
2024-07-18 02:03:17 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/7e52b6fa246 Pull-request: https://github.com/SerenityOS/serenity/pull/10549 Reviewed-by: https://github.com/IdanHo ✅
47
.github/workflows/manpages.yml
vendored
47
.github/workflows/manpages.yml
vendored
@ -6,9 +6,6 @@ on:
|
||||
- "Base/usr/share/man/**"
|
||||
- "Meta/Websites/man.serenityos.org/**"
|
||||
|
||||
env:
|
||||
MAN_DIR: ${{ github.workspace }}/Base/usr/share/man/
|
||||
|
||||
jobs:
|
||||
convert_using_pandoc:
|
||||
runs-on: ubuntu-20.04
|
||||
@ -18,48 +15,8 @@ jobs:
|
||||
- uses: r-lib/actions/setup-pandoc@v1
|
||||
with:
|
||||
pandoc-version: '2.13'
|
||||
- name: Prepare output directories
|
||||
run: |
|
||||
for d in $MAN_DIR*/; do
|
||||
dir_name=$(basename "$d")
|
||||
section="${dir_name/man}"
|
||||
mkdir -p "output/${section}"
|
||||
done
|
||||
- name: Convert markdown to html
|
||||
run: |
|
||||
cat << EOF > link-fixup.lua
|
||||
function Link(el)
|
||||
el.target = string.gsub(el.target, "%.md", ".html") -- fixup .md to .html links
|
||||
el.target = string.gsub(el.target, "man", "", 1) -- fixup man1/???.html to 1/???.html links
|
||||
return el
|
||||
end
|
||||
EOF
|
||||
find $MAN_DIR -iname '*.md' -type f -exec sh -c '\
|
||||
relative_path="$(realpath --relative-to=$MAN_DIR $0)" \
|
||||
&& stripped_path="${relative_path#man}" \
|
||||
&& section="${stripped_path%%/*}" \
|
||||
&& filename="${stripped_path#*/}" \
|
||||
&& name="${filename%.md}" \
|
||||
&& pandoc -f gfm -t html5 -s --lua-filter=link-fixup.lua --metadata title="${name}(${section}) - SerenityOS man pages" -o "output/${section}/${name}.html" "${0}" \
|
||||
' {} \;
|
||||
- name: Generate man page listings
|
||||
run: |
|
||||
for d in output/*/; do
|
||||
section=$(basename "$d")
|
||||
echo "<!DOCTYPE html><html><head><title>Section ${section} - SerenityOS man pages</title></head><body>" > "${d}/index.html"
|
||||
for f in $d/*; do
|
||||
filename=$(basename "$f")
|
||||
name="${filename%.html}"
|
||||
if [[ "$filename" == "index.html" ]]; then
|
||||
continue
|
||||
fi
|
||||
echo "<a href=\"${filename}\"><p>${name}(${section})</p></a>" >> "${d}/index.html"
|
||||
done
|
||||
echo "</body></html>" >> "$d/index.html"
|
||||
done
|
||||
- name: Copy pre-made files
|
||||
run: |
|
||||
cp -R Meta/Websites/man.serenityos.org/* output/
|
||||
- name: Actually build website
|
||||
run: ./Meta/build-manpages-website.sh
|
||||
- name: Deploy to GitHub pages
|
||||
uses: JamesIves/github-pages-deploy-action@4.1.1
|
||||
with:
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,6 +23,7 @@ compile_commands.json
|
||||
.clangd
|
||||
.idea/
|
||||
cmake-build-debug/
|
||||
output/
|
||||
run-local.sh
|
||||
sync-local.sh
|
||||
.vim/
|
||||
|
54
Meta/build-manpages-website.sh
Executable file
54
Meta/build-manpages-website.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1004 # literal backslash+linefeed is intended
|
||||
|
||||
set -e
|
||||
|
||||
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||
cd "${script_path}/.."
|
||||
|
||||
export LC_ALL=C # Make the directory order reproducible
|
||||
export MAN_DIR=Base/usr/share/man/
|
||||
|
||||
if [[ -e output ]]; then
|
||||
echo "Directory 'output/' already exists. Delete it first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prepare output directories
|
||||
for d in "${MAN_DIR}"*/; do
|
||||
dir_name=$(basename "$d")
|
||||
section="${dir_name/man}"
|
||||
mkdir -p "output/${section}"
|
||||
done
|
||||
|
||||
# Convert markdown to html
|
||||
|
||||
# If you're here because your local results are different from the website:
|
||||
# Check that your pandoc version matches the pandoc-version specified in manpages.yaml.
|
||||
|
||||
find "${MAN_DIR}" -iname '*.md' -type f -exec sh -c '\
|
||||
relative_path="$(realpath --relative-to="${MAN_DIR}" $0)" \
|
||||
&& stripped_path="${relative_path#man}" \
|
||||
&& section="${stripped_path%%/*}" \
|
||||
&& filename="${stripped_path#*/}" \
|
||||
&& name="${filename%.md}" \
|
||||
&& pandoc -f gfm -t html5 -s --lua-filter=Meta/convert-markdown-links.lua --metadata title="${name}(${section}) - SerenityOS man pages" -o "output/${section}/${name}.html" "${0}" \
|
||||
' {} \;
|
||||
|
||||
# Generate man page listings
|
||||
for d in output/*/; do
|
||||
section=$(basename "$d")
|
||||
echo "<!DOCTYPE html><html><head><title>Section ${section} - SerenityOS man pages</title></head><body>" > "${d}/index.html"
|
||||
for f in "$d"/*; do
|
||||
filename=$(basename "$f")
|
||||
name="${filename%.html}"
|
||||
if [[ "$filename" == "index.html" ]]; then
|
||||
continue
|
||||
fi
|
||||
echo "<a href=\"${filename}\"><p>${name}(${section})</p></a>" >> "${d}/index.html"
|
||||
done
|
||||
echo "</body></html>" >> "$d/index.html"
|
||||
done
|
||||
|
||||
# Copy pre-made files
|
||||
cp -R Meta/Websites/man.serenityos.org/* output/
|
5
Meta/convert-markdown-links.lua
Normal file
5
Meta/convert-markdown-links.lua
Normal file
@ -0,0 +1,5 @@
|
||||
function Link(el)
|
||||
el.target = string.gsub(el.target, "%.md", ".html") -- change .md to .html links
|
||||
el.target = string.gsub(el.target, "man", "", 1) -- change man1/???.html to 1/???.html links
|
||||
return el
|
||||
end
|
Loading…
Reference in New Issue
Block a user