Skip to content

Commit

Permalink
add generate_docs.sh to reformat rst files, and generate pdf and html
Browse files Browse the repository at this point in the history
After universal-ctags#440
we cannot generate pdf and html documents directly,
This script make we can.
  • Loading branch information
cztchoice committed Jul 15, 2015
1 parent 44ace16 commit 09537af
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ pdf: universal-ctags.pdf
html: universal-ctags.html

universal-ctags.pdf: *.rst *.svg
rst2pdf universal-ctags.rst -e inkscape
./generate_docs.sh pdf
universal-ctags.html: *.rst *.svg
rst2html universal-ctags.rst > $@
./generate_docs.sh html
53 changes: 53 additions & 0 deletions docs/generate_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
#
# generate_docs.sh - Generate rst docs linked together to single pdf or html
#
# Copyright (C) 2015 Zhitao Chen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
FORMAT=$1
NAME=universal-ctags
#set -o errexit
set -o nounset

if [[ $# -ne 1 ]]; then
exit 1;
fi
CURDIR=`pwd`
TEMPDIR=`mktemp -d` || exit 1
cp * ${TEMPDIR}
pushd ${TEMPDIR}

#translate rst link to include
for rst_file in *.rst; do
sed -i 's/^`.*<\(.*.rst\)>`_$/.. include:: \1/g' ${rst_file}
done

#add raw::pdf and PageBreak oneColumn after each section
sed -i 's/\(.. include:: .*.rst\)/\1\n.. raw:: pdf\n\n PageBreak oneColumn/g' readme.rst

#add raw::pdf and PageBreak after content with a blank line
sed -i 's/\(.. section-numbering::\)/\1\n\n.. raw:: pdf\n\n PageBreak oneColumn/g' readme.rst

if [[ $FORMAT = "pdf" ]]; then
rst2pdf readme.rst ${NAME}.pdf -e inkscape
mv ${NAME}.pdf ${CURDIR}
elif [[ $FORMAT = "html" ]]; then
rst2html readme.rst ${NAME}.html
mv ${NAME}.html ${CURDIR}
fi

popd
rm -rf ${TEMPDIR}
3 changes: 0 additions & 3 deletions docs/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ Contents

.. section-numbering::

.. raw:: pdf
`Introduced changes <news.rst>`_

`Choosing a proper parser in ctags <guessing.rst>`_
Expand Down

0 comments on commit 09537af

Please sign in to comment.