How to use the sphinx.setup_command.BuildDoc function in Sphinx

To help you get started, we’ve selected a few Sphinx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rucio / rucio / setup_rucio.py View on Github external
"""    'final': False,\n"""
                       """    'version': '%s',\n"""
                       """    'branch_nick': '%s',\n"""
                       """    'revision_id': '%s',\n"""
                       """    'revno': %s\n"""
                       """}""" % (pkg_version, branch_nick, revid, revno))
    version_file.close()
else:
    pkg_version = version.version_string()

cmdclass = {}

try:
    from sphinx.setup_command import BuildDoc

    class local_BuildDoc(BuildDoc):
        def run(self):
            for builder in ['html']:   # 'man','latex'
                self.builder = builder
                self.finalize_options()
                BuildDoc.run(self)
    cmdclass['build_sphinx'] = local_BuildDoc
except:
    pass


def get_reqs_from_file(requirements_file):
    if os.path.exists(requirements_file):
        return open(requirements_file, 'r').read().split('\n')
    return []
github roskakori / cutplace / setup.py View on Github external
def run(self):
            self.set_version()
            if self.builder == "doctest":
                import sphinx.ext.doctest as doctest
                # Capture the DocTestBuilder class in order to return the total
                # number of failures when exiting
                ref = capture_objs(doctest.DocTestBuilder)
                BuildDoc.run(self)
                errno = ref[-1].total_failures
                sys.exit(errno)
            else:
                BuildDoc.run(self)
github scikit-umfpack / scikit-umfpack / setup.py View on Github external
def run(self):
                ret = subprocess.call([sys.executable, sys.argv[0], 'build_ext', '-i'])
                if ret != 0:
                    raise RuntimeError("Building failed!")
                SphinxBuildDoc.run(self)
        cmdclass['build_sphinx'] = BuildDoc
github openstack / neutron / quantum / openstack / common / setup.py View on Github external
def run(self):
                if not os.getenv('SPHINX_DEBUG'):
                    self.generate_autoindex()

                for builder in self.builders:
                    self.builder = builder
                    self.finalize_options()
                    self.project = self.distribution.get_name()
                    self.version = self.distribution.get_version()
                    self.release = self.distribution.get_version()
                    BuildDoc.run(self)
github zenoss / ZenPacks.zenoss.PostgreSQL / src / pg8000 / setup.py View on Github external
pg8000 is a Pure-Python interface to the PostgreSQL database engine.  It is \
one of many PostgreSQL interfaces for the Python programming language. pg8000 \
is somewhat distinctive in that it is written entirely in Python and does not \
rely on any external libraries (such as a compiled python module, or \
PostgreSQL's libpq library). pg8000 supports the standard Python DB-API \
version 2.0.

pg8000's name comes from the belief that it is probably about the 8000th \
PostgreSQL interface for Python."""

cmdclass = dict(versioneer.get_cmdclass())

try:
    from sphinx.setup_command import BuildDoc
    cmdclass['build_sphinx'] = BuildDoc
except ImportError:
    pass

version=versioneer.get_version()

setup(
        name="pg8000",
        version=version,
        cmdclass=cmdclass,
        description="PostgreSQL interface library",
        long_description=long_description,
        author="Mathieu Fenniak",
        author_email="biziqe@mathieu.fenniak.net",
        url="https://github.com/mfenniak/pg8000",
        classifiers = [
            "Development Status :: 4 - Beta",
github Arelle / Arelle / setup.py View on Github external
if sys.version_info[0] < 3:
    setup_requires.append('3to2')
    # cmdclass allows you to override the distutils commands that are 
    # run through 'python setup.py somecmd'. Under python 2.7 replace 
    # the 'build_py' with a custom subclass (build_py27) that invokes 
    # 3to2 refactoring on each python file as its copied to the build
    # directory.
    cmdclass['build_py'] = build_py27

# (Under python3 no commands are replaced, so the default command classes are used.)

try:
    # Under python2.7, run build before running build_sphinx
    import sphinx.setup_command

    class build_sphinx_py27(sphinx.setup_command.BuildDoc):
        def run(self):
            self.run_command('build_py')
            # Ensure sphinx looks at the "built" arelle libs that
            # have passed through the 3to2 refactorings
            # in `build_py27`.
            sys.path.insert(0, os.path.abspath("./build/lib"))
            sphinx.setup_command.BuildDoc.run(self)
                
    if sys.version_info[0] < 3:
        setup_requires.append('3to2')
        setup_requires.append('sphinx')
        # do a similar override of the 'build_sphinx' command to ensure 
        # that the 3to2-enabled build command runs before calling back to 
        # the default build_sphinx superclass. 
        cmdclass['build_sphinx'] = build_sphinx_py27
        # There is also a python 2.x conditional switch in 'apidocs/conf.py' 
github h3llrais3r / Auto-Subliminal / lib / pbr / builddoc.py View on Github external
.. automodule:: %(module)s
  :members:
  :undoc-members:
  :show-inheritance:
"""


def _find_modules(arg, dirname, files):
    for filename in files:
        if filename.endswith('.py') and filename != '__init__.py':
            arg["%s.%s" % (dirname.replace('/', '.'),
                           filename[:-3])] = True


class LocalBuildDoc(setup_command.BuildDoc):

    builders = ['html']
    command_name = 'build_sphinx'
    sphinx_initialized = False

    def _get_source_dir(self):
        option_dict = self.distribution.get_option_dict('build_sphinx')
        pbr_option_dict = self.distribution.get_option_dict('pbr')
        _, api_doc_dir = pbr_option_dict.get('api_doc_dir', (None, 'api'))
        if 'source_dir' in option_dict:
            source_dir = os.path.join(option_dict['source_dir'][1],
                                      api_doc_dir)
        else:
            source_dir = 'doc/source/' + api_doc_dir
        if not os.path.exists(source_dir):
            os.makedirs(source_dir)
github vasole / pymca / setup_new.py View on Github external
def run(self):

            # make sure the python path is pointing to the newly built
            # code so that the documentation is built on this and not a
            # previously installed version

            build = self.get_finalized_command('build')
            sys.path.insert(0, os.path.abspath(build.build_lib))

            # Build the Users Guide in HTML and TeX format
            for builder in ('html', 'latex'):
                self.builder = builder
                self.builder_target_dir = os.path.join(self.build_dir, builder)
                self.mkpath(self.builder_target_dir)
                builder_index = 'index_{0}.txt'.format(builder)
                BuildDoc.run(self)
            sys.path.pop(0)
    cmdclass['build_doc'] = build_doc
github asuni / wavelet_prosody_toolkit / setup.py View on Github external
]
}

NAME = 'wavelet-prosody-toolkit'
VERSION = '1.0b1'
RELEASE = '1.0'
AUTHOR = 'Antti Suni'
DESCRIPTION = 'Prosody wavelet analysis toolkit'
with open("README.rst", "r") as fh:
    LONG_DESCRIPTION = fh.read()


# If sphinx available, enable documentation building
try:
    from sphinx.setup_command import BuildDoc
    cmdclass = {'build_sphinx': BuildDoc}
    command_options = {
        'build_sphinx': {
            'project': ('setup.py', NAME),
            'version': ('setup.py', VERSION),
            'release': ('setup.py', RELEASE)
        }
    }
except Exception:
    cmdclass = {}
    command_options = {}

# The actual setup
setup(
    # Project info.
    name=NAME,
    version=RELEASE,
github openstack / python-novaclient / novaclient / openstack / common / setup.py View on Github external
def run(self):
                if not os.getenv('SPHINX_DEBUG'):
                    self.generate_autoindex()

                for builder in self.builders:
                    self.builder = builder
                    self.finalize_options()
                    self.project = self.distribution.get_name()
                    self.version = self.distribution.get_version()
                    self.release = self.distribution.get_version()
                    BuildDoc.run(self)