app-vim/zenburn: Stable for amd64. Mark stable for the remaining arches using the...
[gentoo.git] / dev-python / docutils / docutils-0.9.1-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6 PYTHON_COMPAT=( python2_7 )
7
8 inherit distutils-r1
9
10 DESCRIPTION="Python Documentation Utilities"
11 HOMEPAGE="http://docutils.sourceforge.net/ https://pypi.python.org/pypi/docutils"
12 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
13 SRC_URI+=" glep? ( mirror://gentoo/glep-0.4-r1.tbz2 )"
14
15 LICENSE="BSD-2 GPL-3 public-domain"
16 SLOT="0"
17 KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
18 IUSE="glep"
19
20 RDEPEND="dev-python/pygments[${PYTHON_USEDEP}]"
21 DEPEND="${RDEPEND}"
22
23 GLEP_SRC="${WORKDIR}/glep-0.4-r1"
24
25 python_prepare_all() {
26         # It's easier to move them around now.
27         # TODO: add python_newmodule?
28         if use glep; then
29                 mkdir "${GLEP_SRC}"/{read,trans} || die
30                 mv "${GLEP_SRC}"/{glepread,read/glep}.py || die
31                 mv "${GLEP_SRC}"/{glepstrans,trans/gleps}.py || die
32         fi
33
34         distutils-r1_python_prepare_all
35 }
36
37 python_compile_all() {
38         # Generate html docs from reStructured text sources.
39
40         # Place html4css1.css in base directory to ensure that the generated reference to it is correct.
41         cp docutils/writers/html4css1/html4css1.css . || die
42
43         cd tools || die
44         "${PYTHON}" buildhtml.py --input-encoding=utf-8 \
45                 --stylesheet-path=../html4css1.css --traceback ../docs || die
46 }
47
48 python_test() {
49         local tests=test
50         [[ ${EPYTHON} == python3* ]] && tests=test3
51
52         cp -r -l ${tests} "${BUILD_DIR}"/test || die
53         ln -s "${S}"/docs "${BUILD_DIR}"/ || die
54         "${PYTHON}" "${BUILD_DIR}"/test/alltests.py || die "Tests fail with ${EPYTHON}"
55 }
56
57 python_install() {
58         distutils-r1_python_install
59
60         # Install tools.
61         python_doscript tools/{buildhtml,quicktest}.py
62
63         # Install Gentoo GLEP tools.
64         if use glep; then
65                 python_doscript "${GLEP_SRC}"/glep.py
66
67                 python_moduleinto docutils/readers
68                 python_domodule "${GLEP_SRC}"/read/glep.py
69                 python_moduleinto docutils/transforms
70                 python_domodule "${GLEP_SRC}"/trans/gleps.py
71                 python_moduleinto docutils/writers
72                 python_domodule "${GLEP_SRC}"/glep_html
73         fi
74 }
75
76 install_txt_doc() {
77         local doc="${1}"
78         local dir="txt/$(dirname ${doc})"
79         docinto "${dir}"
80         dodoc "${doc}"
81 }
82
83 python_install_all() {
84         local DOCS=( *.txt )
85         local HTML_DOCS=( docs tools docutils/writers/html4css1/html4css1.css )
86
87         distutils-r1_python_install_all
88
89         local doc
90         while IFS= read -r -d '' doc; do
91                 install_txt_doc "${doc}"
92         done < <(find docs tools -name '*.txt' -print0)
93 }