1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:57:45 +00:00

Meta: Make the manpage website build work with manpage subsection

For now, we create simple but complete indices and actually generate the
HTML for the manpages in subsections. For these purposes, switch to
using "find" as a file finding tool everywhere, instead of the very
limited globs from before.
This commit is contained in:
kleines Filmröllchen 2023-01-02 16:20:31 +01:00 committed by Jelle Raaijmakers
parent 69e5645955
commit 3affa922e3

View file

@ -14,6 +14,9 @@ if [[ -e output ]]; then
exit 1 exit 1
fi fi
# Use case-insensitive sorting, which will lead to more intuitive index pages.
SORT="sort -f"
# Prepare output directories # Prepare output directories
for d in "${MAN_DIR}"*/; do for d in "${MAN_DIR}"*/; do
dir_name=$(basename "$d") dir_name=$(basename "$d")
@ -26,23 +29,26 @@ done
# If you're here because your local results are different from the website: # 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. # Check that your pandoc version matches the pandoc-version specified in manpages.yaml.
for md_file in "${MAN_DIR}"*/*.md; do for md_file in $(find "${MAN_DIR}" -iname '*.md' | ${SORT}); do
relative_path="$(realpath --relative-to="${MAN_DIR}" "${md_file}")" relative_path="$(realpath --relative-to="${MAN_DIR}" "${md_file}")"
section="${relative_path%%/*}" section="${relative_path%%/*}"
section_number="${section#man}" section_number="${section#man}"
filename="${relative_path#*/}" filename="${relative_path#*/}"
name="${filename%.md}" name="${filename%.md}"
output_file="output/${section}/${name}.html"
mkdir -p "$(dirname "${output_file}")"
pandoc -f gfm -t html5 -s \ pandoc -f gfm -t html5 -s \
-B Meta/Websites/man.serenityos.org/banner-preamble.inc \ -B Meta/Websites/man.serenityos.org/banner-preamble.inc \
--lua-filter=Meta/convert-markdown-links.lua \ --lua-filter=Meta/convert-markdown-links.lua \
--metadata title="${name}(${section_number}) - SerenityOS man pages" \ --metadata title="${name}(${section_number}) - SerenityOS man pages" \
-o "output/${section}/${name}.html" \ -o "${output_file}" \
"${md_file}" "${md_file}"
done done
# Generate man page listings through pandoc # Generate man page listings through pandoc
for d in output/*/; do for section_directory in output/*/; do
section=$(basename "$d") section=$(basename "${section_directory}")
section_number="${section#man}" section_number="${section#man}"
case "${section_number}" in case "${section_number}" in
1) section_title="User Programs";; 1) section_title="User Programs";;
@ -50,18 +56,19 @@ for d in output/*/; do
3) section_title="Library Functions";; 3) section_title="Library Functions";;
4) section_title="Special Files";; 4) section_title="Special Files";;
5) section_title="File Formats";; 5) section_title="File Formats";;
6) section_title="Games";; # TODO: Populate this section 6) section_title="Games";;
7) section_title="Miscellanea";; 7) section_title="Miscellanea";;
8) section_title="Sysadmin Tools";; 8) section_title="Sysadmin Tools";;
*) section_title="SerenityOS man pages"; echo "WARNING: Unrecognized section ${section_number}?!";; *) section_title="SerenityOS man pages"; echo "WARNING: Unrecognized section ${section_number}?!";;
esac esac
output="output/${section}/index.html"
pandoc -f gfm -t html5 -s \ pandoc -f gfm -t html5 -s \
-B Meta/Websites/man.serenityos.org/banner-preamble.inc \ -B Meta/Websites/man.serenityos.org/banner-preamble.inc \
--metadata title="Section ${section_number} - ${section_title}" \ --metadata title="Section ${section_number} - ${section_title}" \
-o "output/${section}/index.html" \ -o "${output}" \
<( <(
for f in "$d"/*; do for f in $(find "${section_directory}" -iname '*.html' | ${SORT}); do
filename=$(basename "$f") filename=$(realpath --relative-to="${section_directory}" "$f")
name="${filename%.html}" name="${filename%.html}"
if [[ "$filename" == "index.html" ]]; then if [[ "$filename" == "index.html" ]]; then
continue continue