diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-10-26 13:14:07 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-10-26 15:33:40 -0700 |
| commit | 2ac45d7d78aec9a7387201a90fe4a9d11cd86df8 (patch) | |
| tree | d315a1a3f719f3878b257d454d92e5046ff71ff9 /docs/publish.sh | |
| parent | 46ca4756a09d015298b310cd482f2e39d9a034db (diff) | |
| download | nng-2ac45d7d78aec9a7387201a90fe4a9d11cd86df8.tar.gz nng-2ac45d7d78aec9a7387201a90fe4a9d11cd86df8.tar.bz2 nng-2ac45d7d78aec9a7387201a90fe4a9d11cd86df8.zip | |
Documentation updates.
This adds a few man pages, fixes the content and formatting on a few
others.
It also adds two utility scripts for me to use, publish.sh, which I
use to publish updates to the gh-pages branch, and preview.sh, which
I use to look at markup without cluttering my work directory.
Diffstat (limited to 'docs/publish.sh')
| -rwxr-xr-x | docs/publish.sh | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/docs/publish.sh b/docs/publish.sh new file mode 100755 index 00000000..b122838a --- /dev/null +++ b/docs/publish.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# +# Copyright 2017 Garrett D'Amore <garrett@damore.org> +# Copyright 2017 Capitar IT Group BV <info@capitar.com> +# This software is supplied under the terms of the MIT License, a +# copy of which should be located in the distribution where this +# file was obtained (LICENSE.txt). A copy of the license may also be +# found online at https://opensource.org/licenses/MIT. +# +# +# This program attempts to publish updated documentation to our gh-pages +# branch. +# +# We read the .version file from ../.version. +# +# The docs are published into the gh-pages branch, in a directory +# called man/v<version>. +# +# This script requires asciidoctor, pygments, git, and a UNIX shell. +# + +tmpdir=$(mktemp -d) +srcdir=$(dirname $0) +dstdir=${tmpdir}/pages +cd ${srcdir} +vers=$(cat ../.version) +dstman=${dstdir}/man/v${vers} +name=nng + +giturl="${GITURL:-git@github.com:nanomsg/nng}" + +cleanup() { + echo "DELETING ${tmpdir}" + rm -rf ${tmpdir} +} + +mkdir -p ${tmpdir} + +trap cleanup 0 + +echo git clone ${giturl} ${dstdir} || exit 1 +git clone ${giturl} ${dstdir} || exit 1 + +(cd ${dstdir}; git checkout gh-pages) + +[ -d ${dstman} ] || mkdir -p ${dstman} + +dirty= +for input in $(find . -name '*.adoc'); do + adoc=${input#./} + html=${adoc%.adoc}.html + output=${dstman}/${html} + + status=$(git status -s $input ) + when=$(git log -n1 --format='%ad' '--date=format-local:%s' $input ) + frontmatter="version: ${vers}\nlayout: default" + + echo "---" > ${output} + echo "$frontmatter" >> ${output} + echo "---" >> ${output} + + if [ -n "$when" ] + then + epoch="SOURCE_DATE_EPOCH=${when}" + else + epoch= + dirty=yes + fi + if [ -n "$status" ] + then + echo "File $adoc is not checked in!" + dirty=yes + fi + + + env ${epoch} asciidoctor \ + -aversion-label=${name} \ + -arevnumber=${vers} \ + -askip-front-matter \ + -bhtml5 \ + -o - ${adoc} >> ${output} + chmod 0644 ${output} + + if [ $? -ne 0 ] + then + echo "Failed to process $adoc !" + fails=yes + fi + + + (cd ${dstman}; git add ${html}) +done + +if [ -n "$dirty" ] +then + echo "Repository has uncommited documentation. Aborting." + exit 1 +fi + +if [ -n "$fails" ] +then + echo "Failures formatting documentation. Aborting." + exit 1 +fi + +(cd ${dstman}; git commit -m "man page updates for ${vers}"; git push origin gh-pages) |
