Last active
December 25, 2015 05:49
-
-
Save AlainODea/6927841 to your computer and use it in GitHub Desktop.
Use man2html to generate entire hyperlinked documentation from man pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
#sudo apt-get -y install realpath man2html-base | |
#gem install ronn | |
#git clone [email protected]:joyent/illumos-joyent.git | |
#git clone [email protected]:joyent/smartos-live.git | |
pushd illumos-joyent | |
git pull | |
popd | |
pushd smartos-live | |
git pull | |
popd | |
manroots='illumos-joyent/usr/src/man smartos-live/man/man' | |
manroot='build/manpages' | |
destination='build/man2html' | |
mkdir -p $manroot | |
mkdir -p $destination | |
manroot=$(realpath $manroot) | |
destination=$(realpath $destination) | |
for path in $manroots | |
do | |
cp -Rf $path/* $manroot | |
done | |
pushd smartos-live/man/src | |
find -name '*.md' | | |
cut -c3- | | |
while read mdmanfile | |
do | |
name=$(echo $mdmanfile | sed -r 's/\.[^.]*\.[^.]*$//') | |
manual=$(echo $mdmanfile | sed -r 's/\.[^.]*$//' | sed -r 's/^[^.]*\.//') | |
cat $mdmanfile | ronn --pipe > $manroot/man$manual/$name.$manual | |
done | |
popd | |
pushd $manroot | |
find -type f | | |
grep -v '/.*/.*/' | | |
grep '\.[1-9][^.]*$' | | |
while read manpage | |
do | |
mandir=man$(dirname $manpage | cut -c6- | tr '[:lower:]' '[:upper:]') | |
pagename=$(basename $manpage | sed -r 's/([^.]*)$/\U\1/') | |
mkdir -p $destination/$mandir && | |
cat $manpage | | |
man2html -r | | |
tail -n+3 > $destination/$mandir/$pagename.html | |
done | |
popd | |
pushd $destination | |
echo '<!DOCTYPE html>' > index.html | |
echo '<html><head><title>SmartOS Man Pages</title></head><body><h1>SmartOS Man Pages</h1><ul>' >> index.html | |
find -type f | | |
cut -c3- | | |
while read manpage | |
do | |
echo "<li><a href=\"$manpage\">$manpage</a></li>" >> index.html | |
done | |
echo "</ul><p>Last Updated: $(date -u +"%Y-%m-%dT%H:%M:%SZ")</p></body></html>" >> index.html | |
find -type d | | |
cut -c3- | | |
xargs -P 100 -n1 -i{} env MANTA_USER=smartosman mmkdir -p /smartosman/public/{} | |
find -type f | | |
cut -c3- | | |
xargs -P 100 -n1 -i{} env MANTA_USER=smartosman mput -f {} /smartosman/public/{} -H'Content-Type: text/html; charset=utf-8' -H'Content-Language: en' | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment