Skip to content

Instantly share code, notes, and snippets.

@d-amend
Forked from publicarray/make-doc
Last active May 19, 2021 11:34
Show Gist options
  • Save d-amend/361981bb081ef6868a22438b654a1bd5 to your computer and use it in GitHub Desktop.
Save d-amend/361981bb081ef6868a22438b654a1bd5 to your computer and use it in GitHub Desktop.
Make a FreeBSD Handbook docset for Dash
#!/bin/bash
# thank you publicarray for the main work - this script is just a minor adaption
set -e
if ! command -v dashing >/dev/null 2>&1; then
if command -v go >/dev/null; then
brew install dashing
else
echo "Missing go. Install golang first 'brew install golang'"
return 1
fi
fi
if ! command -v wget >/dev/null 2>&1; then
if command -v brew >/dev/null 2>&1; then
brew install wget
else
echo "Missing wget. Install wget first 'brew install wget'"
return 1
fi
fi
if ! command -v recode >/dev/null 2>&1; then
if command -v brew >/dev/null 2>&1; then
brew install recode
else
echo "Missing recode. Install recode first 'brew install recode'"
return 1
fi
fi
if [ ! -f 'book.html-split.tar.bz2' ]; then
wget https://download.freebsd.org/ftp/doc/en/books/handbook/book.html-split.tar.bz2
fi
if [ ! -d 'handbook' ]; then
mkdir handbook
fi
if [ ! -f 'handbook/index.html' ]; then
tar -xvf book.html-split.tar.bz2 -C handbook
recode iso-8859-1..utf8 -- handbook/*.html
fi
# remove archives before building
if [ -f 'freebsd.tgz' ]; then
rm -f freebsd.tgz
fi
dashing create
# Configure Dashing config
sed -i '' "s/Dashing/FreeBSD Handbook/" dashing.json
sed -i '' "s/dashing/freebsd/" dashing.json
if [ ! -f 'handbook/dashing.json' ]; then
cp dashing.json handbook/dashing.json
fi
# Icon needs to be placed beforehand in the script dir
if [ ! -f 'handbook/icon.png' ]; then
cp icon.png handbook/icon.png
fi
cd handbook || return 1
dashing build
cd .. || return 1
if [ -d 'freebsd.docset' ]; then
rm -rdfv freebsd.docset
fi
if [ -d 'handbook/freebsd.docset' ]; then
mv -v handbook/freebsd.docset freebsd.docset
fi
tar --exclude='.DS_Store' -cvzf freebsd.tgz freebsd.docset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment