From 689fb8773baf627b1efddb4bb3744e445f630818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Wed, 10 Feb 2021 14:59:33 -0300 Subject: [PATCH] res/build.sh: use lowdown instead of pandoc for mandoc output. Given that pandoc is a haskell program, depending on it is bad due to bootstrap and general platform compatibility concerns. Lowdown output looks just as good if not better. The ideal build will have the git repository available to it; builds without the git repo will use SOURCE_DATE_EPOCH from the environment. --- README.md | 2 +- res/build.sh | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9e7e612f..ec578dc6 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Void packages: - `mdBook` - `findutils` -- `pandoc` +- `lowdown` (version 0.8.1 or greater) - `texlive` - `perl` - `perl-JSON` diff --git a/res/build.sh b/res/build.sh index af813385..22f3a757 100755 --- a/res/build.sh +++ b/res/build.sh @@ -6,20 +6,33 @@ set -e PATH="$PWD/res:$PATH" +if [ -z "$SOURCE_DATE_EPOCH" ]; then + export SOURCE_DATE_EPOCH=$(git log --pretty='%ct' -1) + if [ -z "$SOURCE_DATE_EPOCH" -a "$BUILD_MANPAGES" = 1 ]; then + echo "git or SOURCE_DATE_EPOCH are needed to build man pages!" + exit 1 + fi +fi + # Build HTML mdbook echo "Building mdBook" mdbook build - if [ "$BUILD_MANPAGES" = "1" ]; then # Build mandoc version echo "Building man pages" - mkdir -p mandoc cd src find . -type d -exec mkdir -p "../mandoc/{}" \; + find . -type f -name "*.md" -exec sh -c \ - 'file="{}"; filew="${file%.md}"; pandoc -V "title=${filew##*/}" -V section=7 -V "header=Void Docs" -s -o "../mandoc/${filew}.7" "$file"' \; + 'file="{}"; filew="${file%.md}"; \ + man_date="$(git log --pretty=%cs -1 "$file" 2>/dev/null || date -d "@$SOURCE_DATE_EPOCH" +%F)"; + lowdown -Tman \ + ${man_date:+-m "date: $man_date"} \ + -m "title: ${filew##*/}" \ + -m "section: 7" -m "source: Void Docs" -m "volume: Void Docs" \ + -s -o "../mandoc/${filew}.7" "$file"' \; cd - fi