From dad47a3dd1a978bcd78907508a0c0a8515bccd84 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Wed, 20 Oct 2021 21:52:34 +0200 Subject: [PATCH] man.serenityos.org: Use pandoc for listings and landing page This makes all pages look and feel the same, because they all use the default CSS generated by pandoc. Also, it inserts the banner everywhere at the top, not only into the top-level index.html. Credit to @xSlendiX for suggesting that `-B` works here. --- .../man.serenityos.org/banner-preamble.inc | 1 + Meta/Websites/man.serenityos.org/index.html | 17 ----- Meta/Websites/man.serenityos.org/index.md | 7 +++ Meta/build-manpages-website.sh | 62 +++++++++++++++---- Userland/Utilities/markdown-check.cpp | 10 ++- 5 files changed, 66 insertions(+), 31 deletions(-) create mode 100644 Meta/Websites/man.serenityos.org/banner-preamble.inc delete mode 100644 Meta/Websites/man.serenityos.org/index.html create mode 100644 Meta/Websites/man.serenityos.org/index.md diff --git a/Meta/Websites/man.serenityos.org/banner-preamble.inc b/Meta/Websites/man.serenityos.org/banner-preamble.inc new file mode 100644 index 0000000000..c727b209ba --- /dev/null +++ b/Meta/Websites/man.serenityos.org/banner-preamble.inc @@ -0,0 +1 @@ + diff --git a/Meta/Websites/man.serenityos.org/index.html b/Meta/Websites/man.serenityos.org/index.html deleted file mode 100644 index 7f8ff11118..0000000000 --- a/Meta/Websites/man.serenityos.org/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - SerenityOS man pages - - -SerenityOS -

SerenityOS man pages

-

Section 1: User programs (applets, applications, utilities, etc.)

-

Section 2: System calls (getuid, mount, pledge, sendfd, etc.)

-

Section 3: Library functions (basename, isatty, POSIX functions, etc.)

-

Section 4: Special Files (audio, mem, etc.)

-

Section 5: File formats (getopt convention, Shell, SystemServer)

-

Section 7: Miscellanea (mitigations, sys filesystem, SystemServer, etc.)

-

Section 8: Sysadmin tools (dmesg, pls, sysctl, useradd, etc.)

- - diff --git a/Meta/Websites/man.serenityos.org/index.md b/Meta/Websites/man.serenityos.org/index.md new file mode 100644 index 0000000000..c3b8f14375 --- /dev/null +++ b/Meta/Websites/man.serenityos.org/index.md @@ -0,0 +1,7 @@ +- [Section 1: User programs (applets, applications, utilities, etc.)](man1/index.html) +- [Section 2: System calls (getuid, mount, pledge, sendfd, etc.)](man2/index.html) +- [Section 3: Library functions (basename, isatty, POSIX functions, etc.)](man3/index.html) +- [Section 4: Special Files (audio, mem, etc.)](man4/index.html) +- [Section 5: File formats (getopt convention, Shell, SystemServer)](man5/index.html) +- [Section 7: Miscellanea (mitigations, sys filesystem, SystemServer, etc.)](man7/index.html) +- [Section 8: Sysadmin tools (dmesg, pls, sysctl, useradd, etc.)](man8/index.html) diff --git a/Meta/build-manpages-website.sh b/Meta/build-manpages-website.sh index 56b4a1806c..9df5beb89b 100755 --- a/Meta/build-manpages-website.sh +++ b/Meta/build-manpages-website.sh @@ -32,24 +32,60 @@ for md_file in "${MAN_DIR}"*/*.md; do section_number="${section#man}" filename="${relative_path#*/}" name="${filename%.md}" - pandoc -f gfm -t html5 -s --lua-filter=Meta/convert-markdown-links.lua --metadata title="${name}(${section_number}) - SerenityOS man pages" -o "output/${section}/${name}.html" "${md_file}" + pandoc -f gfm -t html5 -s \ + -B Meta/Websites/man.serenityos.org/banner-preamble.inc \ + --lua-filter=Meta/convert-markdown-links.lua \ + --metadata title="${name}(${section_number}) - SerenityOS man pages" \ + -o "output/${section}/${name}.html" \ + "${md_file}" done -# Generate man page listings +# Generate man page listings through pandoc for d in output/*/; do section=$(basename "$d") section_number="${section#man}" - echo "Section ${section_number} - SerenityOS man pages" > "${d}/index.html" - for f in "$d"/*; do - filename=$(basename "$f") - name="${filename%.html}" - if [[ "$filename" == "index.html" ]]; then - continue - fi - echo "

${name}(${section_number})

" >> "${d}/index.html" - done - echo "" >> "$d/index.html" + pandoc -f gfm -t html5 -s \ + -B Meta/Websites/man.serenityos.org/banner-preamble.inc \ + --metadata title="Section ${section_number} - SerenityOS man pages" \ + -o "output/${section}/index.html" \ + <( + for f in "$d"/*; do + filename=$(basename "$f") + name="${filename%.html}" + if [[ "$filename" == "index.html" ]]; then + continue + fi + echo "- [${name}](${filename})" + done + ) done +# Generate man page listings through pandoc +for d in output/*/; do + section=$(basename "$d") + section_number="${section#man}" + pandoc -f gfm -t html5 -s \ + -B Meta/Websites/man.serenityos.org/banner-preamble.inc \ + --metadata title="Section ${section_number} - SerenityOS man pages" \ + -o "output/${section}/index.html" \ + <( + for f in "$d"/*; do + filename=$(basename "$f") + name="${filename%.html}" + if [[ "$filename" == "index.html" ]]; then + continue + fi + echo "- [${name}](${filename})" + done + ) +done + +# Generate main landing page listings through pandoc +pandoc -f gfm -t html5 -s \ + -B Meta/Websites/man.serenityos.org/banner-preamble.inc \ + --metadata title="SerenityOS man pages" \ + -o output/index.html \ + Meta/Websites/man.serenityos.org/index.md + # Copy pre-made files -cp -R Meta/Websites/man.serenityos.org/* output/ +cp Meta/Websites/man.serenityos.org/banner.png output/ diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp index 3746e9e090..633c555ff6 100644 --- a/Userland/Utilities/markdown-check.cpp +++ b/Userland/Utilities/markdown-check.cpp @@ -37,8 +37,16 @@ static bool is_missing_file_acceptable(String const& filename) "/usr/share/man/man2/open.md", "/usr/share/man/man2/ptrace.md", "/usr/share/man/man5/perfcore.md", - // This one is okay: + // These ones are okay: "/home/anon/js-tests/test-common.js", + "/man1/index.html", + "/man2/index.html", + "/man3/index.html", + "/man4/index.html", + "/man5/index.html", + "/man6/index.html", + "/man7/index.html", + "/man8/index.html", }; for (auto const& suffix : acceptable_missing_files) { if (filename.ends_with(suffix))