Skip to content

Commit

Permalink
res/build.sh: use lowdown instead of pandoc for mandoc output.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ericonr committed May 9, 2021
1 parent 65fe7f5 commit 689fb87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Void packages:

- `mdBook`
- `findutils`
- `pandoc`
- `lowdown` (version 0.8.1 or greater)
- `texlive`
- `perl`
- `perl-JSON`
Expand Down
19 changes: 16 additions & 3 deletions res/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 689fb87

Please sign in to comment.