diff options
author | Tim Harder <radhermit@gmail.com> | 2017-09-23 22:04:36 -0400 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2017-09-23 22:04:36 -0400 |
commit | d77d6a92c6bb3dd0989d69e05b959ded6702c33c (patch) | |
tree | 488f9a08245622067bb098fa92b668cc73bc3a10 | |
parent | travis-ci: use doc deps for building sdist for github deploy (diff) | |
download | pkgcore-d77d6a92c6bb3dd0989d69e05b959ded6702c33c.tar.gz pkgcore-d77d6a92c6bb3dd0989d69e05b959ded6702c33c.tar.bz2 pkgcore-d77d6a92c6bb3dd0989d69e05b959ded6702c33c.zip |
fix docs build on readthedocs
-rw-r--r-- | doc/Makefile | 6 | ||||
-rw-r--r-- | doc/conf.py | 12 | ||||
-rw-r--r-- | pkgdist.py | 32 | ||||
-rw-r--r-- | requirements/dev.txt | 2 |
4 files changed, 30 insertions, 22 deletions
diff --git a/doc/Makefile b/doc/Makefile index 4165254b..084798fe 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -9,6 +9,8 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = $(CURDIR)/_build +TOPDIR = .. +PACKAGEDIR = ../src # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 @@ -45,7 +47,7 @@ clean: -rm -rf $(BUILDDIR) api generated html: - $(PYTHON) -m snakeoil.dist.generate_docs --html ../ pkgcore + $(PYTHON) -m snakeoil.dist.generate_docs --html $(TOPDIR) $(PACKAGEDIR) pkgcore $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." @@ -118,7 +120,7 @@ text: @echo "Build finished. The text files are in $(BUILDDIR)/text." man: - $(PYTHON) -m snakeoil.dist.generate_docs --man ../ pkgcore + $(PYTHON) -m snakeoil.dist.generate_docs --man $(TOPDIR) $(PACKAGEDIR) pkgcore $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @for file in man/*; do \ [ -L "$${file}" ] && rm -f "$${file}" || continue; \ diff --git a/doc/conf.py b/doc/conf.py index c65adfc9..860871a0 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -22,9 +22,7 @@ libdir = os.path.abspath(os.path.join('..', 'build', 'lib')) if os.path.exists(libdir): sys.path.insert(0, libdir) sys.path.insert(1, os.path.abspath('..')) - -from pkgcore import __version__, const -from snakeoil.dist.generate_docs import generate_man, generate_html +import pkgdist on_rtd = os.environ.get('READTHEDOCS', None) == 'True' @@ -56,7 +54,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = 'pkgcore' +project = pkgdist.MODULE authors = '' copyright = '2006-2017, pkgcore contributors' @@ -65,7 +63,7 @@ copyright = '2006-2017, pkgcore contributors' # built documents. # # The short X.Y version. -version = __version__ +version = pkgdist.version() # The full version, including alpha/beta/rc tags. release = 'trunk' @@ -105,8 +103,8 @@ pygments_style = 'sphinx' # auto-generate required files for RTD build environment if on_rtd: - generate_man(project, const.DATA_PATH) - generate_html(project, const.DATA_PATH) + pkgdist.generate_man() + pkgdist.generate_html() # -- Options for HTML output --------------------------------------------------- @@ -97,7 +97,7 @@ def find_moduledir(searchdir=TOPDIR): # determine the main module we're being used to package MODULEDIR = find_moduledir() -MODULEDIRNAME = os.path.dirname(MODULEDIR) +PACKAGEDIR = os.path.dirname(MODULEDIR) MODULE = os.path.basename(MODULEDIR) @@ -145,8 +145,8 @@ def setup(): 'name': MODULE, 'version': version(), 'long_description': readme(), - 'packages': find_packages(MODULEDIRNAME), - 'package_dir': {'':os.path.basename(MODULEDIRNAME)}, + 'packages': find_packages(PACKAGEDIR), + 'package_dir': {'':os.path.basename(PACKAGEDIR)}, 'install_requires': install_requires(), } @@ -317,7 +317,7 @@ class sdist(dst_sdist.sdist): This is used by the --version option in interactive programs among other things. """ - with syspath(MODULEDIRNAME, MODULE == 'snakeoil'): + with syspath(PACKAGEDIR, MODULE == 'snakeoil'): from snakeoil.version import get_git_version log.info('generating _verinfo') data = get_git_version(base_dir) @@ -386,7 +386,7 @@ class build_py(dst_build_py.build_py): self.build_lib, (MODULE,), '_verinfo') # this should check mtime... if not os.path.exists(ver_path): - with syspath(MODULEDIRNAME, MODULE == 'snakeoil'): + with syspath(PACKAGEDIR, MODULE == 'snakeoil'): from snakeoil.version import get_git_version log.info('generating _verinfo') with open(ver_path, 'w') as f: @@ -431,7 +431,7 @@ class build_py2to3(build_py): def get_py2to3_converter(self, options=None, proc_count=0): from lib2to3 import refactor as ref_mod - with syspath(MODULEDIRNAME, MODULE == 'snakeoil'): + with syspath(PACKAGEDIR, MODULE == 'snakeoil'): from snakeoil.dist import caching_2to3 if proc_count == 0: @@ -514,6 +514,18 @@ class build_py3to2(build_py2to3): log.info("completed py2k conversions") +def generate_html(): + """Generate html docs for the project.""" + from snakeoil.dist.generate_docs import generate_html + generate_html(TOPDIR, PACKAGEDIR, MODULE) + + +def generate_man(): + """Generate man pages for the project.""" + from snakeoil.dist.generate_docs import generate_man + generate_man(TOPDIR, PACKAGEDIR, MODULE) + + class build_man(Command): """Build man pages. @@ -552,8 +564,7 @@ class build_man(Command): with syspath(os.path.abspath(build_py.build_lib)): # generate man page content for scripts we create if 'build_scripts' in self.distribution.cmdclass: - from snakeoil.dist.generate_docs import generate_man - generate_man(MODULE, TOPDIR) + generate_man() # generate man pages build_sphinx = self.reinitialize_command('build_sphinx') @@ -583,8 +594,7 @@ class build_docs(build_man): self.run_command('build_man') # generate API docs - from snakeoil.dist.generate_docs import generate_html - generate_html(MODULE, MODULEDIRNAME) + generate_html() # generate html docs -- allow build_sphinx cmd to run again build_sphinx = self.reinitialize_command('build_sphinx') @@ -1181,7 +1191,7 @@ class config(dst_config.config): return self.try_link("int main(int argc, char *argv[]) { return 0; }") def run(self): - with syspath(MODULEDIRNAME, MODULE == 'snakeoil'): + with syspath(PACKAGEDIR, MODULE == 'snakeoil'): from snakeoil.pickling import dump, load # try to load the cached results diff --git a/requirements/dev.txt b/requirements/dev.txt index e2a2181b..16a214b8 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,3 +1 @@ --r test.txt - https://github.com/pkgcore/snakeoil/archive/master.tar.gz#egg=snakeoil |