From ead063e2792713c40c66f386fb84fdecc90adf89 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Wed, 22 Jul 2009 23:04:48 +0000 Subject: [PATCH] Add a 'build_docs' command to build the documentation --- setup.cfg | 4 ++-- setup.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 79cd25bc0..2b5e37b35 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ tag_build = -dev tag_svn_revision = false -[build_sphinx] +[build_docs] source-dir = docs/source build-dir = docs/build -all_files = 1 \ No newline at end of file +all_files = 1 diff --git a/setup.py b/setup.py index 2f1272679..6901f9380 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ from distutils import cmd, sysconfig from distutils.command.build import build as _build from distutils.command.clean import clean as _clean from setuptools.command.install import install as _install +from sphinx.setup_command import BuildDoc import msgfmt import os @@ -269,6 +270,38 @@ class build_plugins(cmd.Command): if os.path.exists(os.path.join(path, "setup.py")): os.system("cd " + path + "&& " + sys.executable + " setup.py bdist_egg -d ..") + +class build_docs(BuildDoc): + def finalize_options(self): + print self.user_options + print self.source_dir + BuildDoc.finalize_options(self) + def run(self): + print self.user_options + class FakeModule(object): + def __init__(self, *args, **kwargs): pass + + def __call__(self, *args, **kwargs): + return FakeModule() + + def __getattr__(self, key): + return FakeModule() + + def __setattr__(self, key, value): + self.__dict__[key] = value + + old_import = __builtins__.__import__ + def new_import(name, globals={}, locals={}, fromlist=[], level=-1): + try: + return old_import(name, globals, locals, fromlist, level) + except ImportError: + return FakeModule() + except: + raise + __builtins__.__import__ = new_import + + BuildDoc.run(self) + class build(_build): sub_commands = [('build_trans', None), ('build_plugins', None)] + _build.sub_commands def run(self): @@ -326,6 +359,7 @@ cmdclass = { 'build': build, 'build_trans': build_trans, 'build_plugins': build_plugins, + 'build_docs': build_docs, 'clean_plugins': clean_plugins, 'clean': clean, 'install': install