From 7468078b719fb51f12f6c5f9741b18a4421eb5b0 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 27 Nov 2016 17:04:12 +0000 Subject: [PATCH] [Setup] Add a CleanDocs class --- setup.py | 21 +++++++++++++++++++++ tox.ini | 4 +--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 4ba76264f..a98b2cb29 100755 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ from distutils import cmd from distutils.command.build import build as _build from distutils.command.clean import clean as _clean from distutils.command.install_data import install_data as _install_data +from shutil import rmtree from setuptools import find_packages, setup from setuptools.command.test import test as _test @@ -70,6 +71,25 @@ class BuildDocs(BuildDoc): BuildDoc.run(self) +class CleanDocs(cmd.Command): + description = 'Clean the documentation build and rst files' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + for docs_dir in ('docs/build', 'docs/source/modules'): + try: + print('Deleting {}'.format(docs_dir)) + rmtree(docs_dir) + except OSError: + pass + + class BuildWebUI(cmd.Command): description = 'Minify WebUI files' @@ -324,6 +344,7 @@ cmdclass = { 'build_docs': BuildDocs, 'install_data': InstallData, 'clean_plugins': CleanPlugins, + 'clean_docs': CleanDocs, 'clean': Clean, 'egg_info_plugins': EggInfoPlugins, 'test': PyTest, diff --git a/tox.ini b/tox.ini index 6972cda84..3634ee633 100644 --- a/tox.ini +++ b/tox.ini @@ -178,10 +178,8 @@ whitelist_externals = [testenv:docs] sitepackages = {[docsbase]sitepackages} deps = {[docsbase]deps} -whitelist_externals = - bash commands = - bash -c 'rm -f docs/source/modules/*.rst' + python setup.py clean_docs python -c "print '> sphinx-apidoc --force -o docs/source/modules/ deluge deluge/plugins\n'\ '> sphinx-build -v -E -T -b html -d docs/build/doctrees docs/source docs/build/html';\ import subprocess, sys; proc = subprocess.Popen(\