Esempio n. 1
0
    def build(self):
        from sphinx import main
        from sphinx import cmdline
        cmdline.main(['', '--version'])
        cmdline.main(
            ['', '-b', 'html', self.rstdir, self.rstdir + '/_build/html'])

        #publish_cmdline(writer_name='html', argv=["--stylesheet",self.csspath,self.rstpath,self.htmlpath])
        #subprocess.call(["sphinx-build","-b","html",self.pypath,self.pypath+"/templates"])
        print "build now."
Esempio n. 2
0
def main(argv=sys.argv):
    """Sphinx build "main" command-line entry."""
    if sys.version_info[:3] < (2, 4, 0):
        sys.stderr.write('Error: Sphinx requires at least '
                         'Python 2.4 to run.\n')
        return 1

    try:
        from sphinx import cmdline
    except ImportError:
        err = sys.exc_info()[1]
        errstr = str(err)
        if errstr.lower().startswith('no module named'):
            whichmod = errstr[16:]
            hint = ''
            if whichmod.startswith('docutils'):
                whichmod = 'Docutils library'
            elif whichmod.startswith('jinja'):
                whichmod = 'Jinja2 library'
            elif whichmod == 'roman':
                whichmod = 'roman module (which is distributed with Docutils)'
                hint = ('This can happen if you upgraded docutils using\n'
                        'easy_install without uninstalling the old version'
                        'first.\n')
            else:
                whichmod += ' module'
            sys.stderr.write('Error: The %s cannot be found. '
                             'Did you install Sphinx and its dependencies '
                             'correctly?\n' % whichmod)
            if hint:
                sys.stderr.write(hint)
            return 1
        raise
    return cmdline.main(argv)
Esempio n. 3
0
def main(argv=sys.argv):
    """Sphinx build "main" command-line entry."""
    if sys.version_info[:3] < (2, 4, 0):
        sys.stderr.write('Error: Sphinx requires at least '
                         'Python 2.4 to run.\n')
        return 1

    try:
        from sphinx import cmdline
    except ImportError:
        err = sys.exc_info()[1]
        errstr = str(err)
        if errstr.lower().startswith('no module named'):
            whichmod = errstr[16:]
            hint = ''
            if whichmod.startswith('docutils'):
                whichmod = 'Docutils library'
            elif whichmod.startswith('jinja'):
                whichmod = 'Jinja2 library'
            elif whichmod == 'roman':
                whichmod = 'roman module (which is distributed with Docutils)'
                hint = ('This can happen if you upgraded docutils using\n'
                        'easy_install without uninstalling the old version'
                        'first.\n')
            else:
                whichmod += ' module'
            sys.stderr.write('Error: The %s cannot be found. '
                             'Did you install Sphinx and its dependencies '
                             'correctly?\n' % whichmod)
            if hint:
                sys.stderr.write(hint)
            return 1
        raise
    return cmdline.main(argv)
Esempio n. 4
0
def _build_docs(source_dir: str, output_dir: str, format: str) -> int:
    """
    Build html sphinx documentation.

    :param source_dir: The input directory to build docs from
    :param output_dir: The place to output docs to
    :return: integer number of warnings issued during docs build
    """

    assert format in ["html", "pdf"]
    with TemporaryDirectory() as td:
        warnings_file = os.path.join(td, "docs_warnings.txt")
        cmdline.main(["-w", warnings_file, "-b", format, source_dir, output_dir])

        warns = open(warnings_file).readlines()
        for w in warns:
            warnings.warn(w.rstrip())

    return len(warns)
Esempio n. 5
0
    def test_1_build(self):
        cache['old_pwd'] = os.getcwd() 
        path = os.path.dirname(os.path.realpath(__file__))
        os.chdir(os.path.join(path, "testprj"))
        cache['tmp_file'] = tempfile.mkdtemp()

        args = ['sphinx-build', '-b', 'html', '-d', 
                cache['tmp_file'] + '/doctrees', 'source', 
                cache['tmp_file'] + '/build/html']
        with mock.patch('sys.stdout', new=StringIO()) as fake_out: 
            retv = cmdline.main(args)
        self.assertEqual(retv, 0)
Esempio n. 6
0
    def run_generic_build(self, builder, doctreedir=None):
        # compatibility with old Makefile
        papersize = os.getenv('PAPER', '')
        opts = self.opts
        if papersize in ('a4', 'letter'):
            opts.extend(['-D', 'latex_paper_size=' + papersize])
        if doctreedir is None:
            doctreedir = self.builddir_join('doctrees')

        args = [
            sys.argv[0], '-b', builder, '-d', doctreedir, self.srcdir,
            self.builddir_join(builder)
        ]
        return cmdline.main(args + opts)
Esempio n. 7
0
    def run_generic_build(self, builder, doctreedir=None):
        # type: (unicode, unicode) -> int
        # compatibility with old Makefile
        papersize = os.getenv('PAPER', '')
        opts = self.opts
        if papersize in ('a4', 'letter'):
            opts.extend(['-D', 'latex_elements.papersize=' + papersize])
        if doctreedir is None:
            doctreedir = self.builddir_join('doctrees')

        args = ['-b', builder,
                '-d', doctreedir,
                self.srcdir,
                self.builddir_join(builder)]
        return cmdline.main(args + opts)
Esempio n. 8
0
    def run_generic_build(self, builder, doctreedir=None):
        # type: (unicode, unicode) -> int
        # compatibility with old Makefile
        papersize = os.getenv('PAPER', '')
        opts = self.opts
        if papersize in ('a4', 'letter'):
            opts.extend(
                ['-D', 'latex_elements.papersize=' + papersize + 'paper'])
        if doctreedir is None:
            doctreedir = self.builddir_join('doctrees')

        args = [
            '-b', builder, '-d', doctreedir, self.srcdir,
            self.builddir_join(builder)
        ]
        return cmdline.main(args + opts)
Esempio n. 9
0
def main(argv=sys.argv):
    """Sphinx build "main" command-line entry."""
    if sys.version_info[:3] < (2, 5, 0):
        sys.stderr.write("Error: Sphinx requires at least " "Python 2.5 to run.\n")
        return 1
    if sys.version_info[:3] >= (3, 3, 0):
        try:
            import docutils

            x, y = docutils.__version__.split(".")[:2]
            if (int(x), int(y)) < (0, 10):
                sys.stderr.write("Error: Sphinx requires at least " "Docutils 0.10 for Python 3.3 and above.\n")
                return 1
        except Exception:
            pass
    try:
        from sphinx import cmdline
    except ImportError:
        err = sys.exc_info()[1]
        errstr = str(err)
        if errstr.lower().startswith("no module named"):
            whichmod = errstr[16:]
            hint = ""
            if whichmod.startswith("docutils"):
                whichmod = "Docutils library"
            elif whichmod.startswith("jinja"):
                whichmod = "Jinja2 library"
            elif whichmod == "roman":
                whichmod = "roman module (which is distributed with Docutils)"
                hint = (
                    "This can happen if you upgraded docutils using\n"
                    "easy_install without uninstalling the old version"
                    "first.\n"
                )
            else:
                whichmod += " module"
            sys.stderr.write(
                "Error: The %s cannot be found. "
                "Did you install Sphinx and its dependencies "
                "correctly?\n" % whichmod
            )
            if hint:
                sys.stderr.write(hint)
            return 1
        raise
    return cmdline.main(argv)
Esempio n. 10
0
def build_main(argv=sys.argv):
    """Sphinx build "main" command-line entry."""
    if sys.version_info[:3] < (2, 7, 0) or (3, 0, 0) <= sys.version_info[:3] < (3, 4, 0):
        sys.stderr.write("Error: Sphinx requires at least Python 2.7 or 3.4 to run.\n")
        return 1
    try:
        from sphinx import cmdline
    except ImportError:
        err = sys.exc_info()[1]
        errstr = str(err)
        if errstr.lower().startswith("no module named"):
            whichmod = errstr[16:]
            hint = ""
            if whichmod.startswith("docutils"):
                whichmod = "Docutils library"
            elif whichmod.startswith("jinja"):
                whichmod = "Jinja2 library"
            elif whichmod == "roman":
                whichmod = "roman module (which is distributed with Docutils)"
                hint = (
                    "This can happen if you upgraded docutils using\n"
                    "easy_install without uninstalling the old version"
                    "first.\n"
                )
            else:
                whichmod += " module"
            sys.stderr.write(
                "Error: The %s cannot be found. "
                "Did you install Sphinx and its dependencies "
                "correctly?\n" % whichmod
            )
            if hint:
                sys.stderr.write(hint)
            return 1
        raise

    from sphinx.util.compat import docutils_version

    if docutils_version < (0, 10):
        sys.stderr.write("Error: Sphinx requires at least Docutils 0.10 to " "run.\n")
        return 1
    return cmdline.main(argv)
Esempio n. 11
0
def build_main(argv=sys.argv[1:]):
    # type: (List[str]) -> int
    """Sphinx build "main" command-line entry."""
    from sphinx import cmdline
    return cmdline.main(argv)  # type: ignore
Esempio n. 12
0
from sphinx.cmdline import main
import sys
sys.exit(main(sys.argv))
Esempio n. 13
0
from sphinx.cmdline import main
from maya import standalone

print("Initializing Maya..")
standalone.initialize()

# Build with Sphinx
main(["docs/source", "docs", "-E", "-v"])
Esempio n. 14
0
from java.lang import System
from sphinx import cmdline
import os

sourceDir = System.getProperty('sphinx.sourceDir')
buildDir = System.getProperty('sphinx.buildDir')

# HTML
cmdline.main(['sphinx-build', '-b', 'html', sourceDir, buildDir + '/html'])

# Latex
cmdline.main(['sphinx-build', '-b', 'latex', sourceDir, buildDir + '/latex'])

# PDF
os.system('make -C ' + buildDir + '/latex all-pdf')
Esempio n. 15
0
from sphinx.cmdline import main
from maya import standalone

print("Initializing Maya..")
standalone.initialize()

# Build with Sphinx
main([
    "docs/source",
    "build/html",
    "-E",
    "-v"
])
Esempio n. 16
0
        from sphinx import cmdline
    except ImportError, err:
        errstr = str(err)
        if errstr.lower().startswith('no module named'):
            whichmod = errstr[16:]
            hint = ''
            if whichmod.startswith('docutils'):
                whichmod = 'Docutils library'
            elif whichmod.startswith('jinja'):
                whichmod = 'Jinja library'
            elif whichmod == 'roman':
                whichmod = 'roman module (which is distributed with Docutils)'
                hint = ('This can happen if you upgraded docutils using\n'
                        'easy_install without uninstalling the old version'
                        'first.')
            else:
                whichmod += ' module'
            print >> sys.stderr, (
                'Error: The %s cannot be found. '
                'Did you install Sphinx and its dependencies '
                'correctly?' % whichmod)
            if hint:
                print >> sys.stderr, hint
            return 1
        raise
    return cmdline.main(argv)


if __name__ == '__main__':
    sys.exit(main(sys.argv))
Esempio n. 17
0
from sphinx.cmdline import main
import sys

sys.exit(main(sys.argv))
Esempio n. 18
0
File: build.py Progetto: LFYG/sphinx
def build_main(argv=sys.argv[1:]):
    # type: (List[str]) -> int
    """Sphinx build "main" command-line entry."""
    from sphinx import cmdline
    return cmdline.main(argv)  # type: ignore
Esempio n. 19
0
def build_file(fname):
    print("Building {}".format(fname))
    doc_dir = os.getcwd()
    src_dir = os.path.join(doc_dir, "")
    html_dir = os.path.join(doc_dir, "build/html")
    cmdline.main([src_dir, html_dir, fname])
Esempio n. 20
0
    try:
        from sphinx import cmdline
    except ImportError, err:
        errstr = str(err)
        if errstr.lower().startswith('no module named'):
            whichmod = errstr[16:]
            hint = ''
            if whichmod.startswith('docutils'):
                whichmod = 'Docutils library'
            elif whichmod.startswith('jinja'):
                whichmod = 'Jinja library'
            elif whichmod == 'roman':
                whichmod = 'roman module (which is distributed with Docutils)'
                hint = ('This can happen if you upgraded docutils using\n'
                        'easy_install without uninstalling the old version'
                        'first.')
            else:
                whichmod += ' module'
            print >>sys.stderr, ('Error: The %s cannot be found. '
                                 'Did you install Sphinx and its dependencies '
                                 'correctly?' % whichmod)
            if hint:
                print >> sys.stderr, hint
            return 1
        raise
    return cmdline.main(argv)


if __name__ == '__main__':
    sys.exit(main(sys.argv))
Esempio n. 21
0
__author__ = 'catherine'

if __name__ == "__main__":
  try:
    from sphinx import cmdline
  except:
    raise NameError("Cannot find sphinx in selected interpreter.")

  import sys
  cmdline.main(sys.argv)
Esempio n. 22
0
from sphinx import cmdline
import sys

cmdline.main(sys.argv)
Esempio n. 23
0
def main(argv):
    current_branch = get_current_branch()
    atexit.register(restore_original_branch, current_branch)

    args = get_args(argv)

    # ensure have committed any changes first
    print(
        "If the following command fails you need to check in your changes first!"
    )
    run_command(['git', 'status', '--porcelain'])

    # ensure are in sync
    print('Fetching current state of remote repository')
    run_command(['git', 'fetch'])

    # checkout designated branch
    print('Checking out branch that has updated code/docs for web (' +
          args.branch + '; override with -r <branch_name>)')
    run_command(['git', 'checkout', args.branch])

    # check all required sphinx dirs
    for dir in [args.docs, args.source, args.build, args.html]:
        if not os.path.isdir(dir):
            print(' directory ' + dir + ' not found!')
            fatal()

    # run sphinx and build the html from the docs rst etc files, and push the update
    task = 'Building and pushing docs'
    print(task)
    try:
        from sphinx import cmdline
    except:
        raise NameError('Cannot find sphinx in selected interpreter.')
    # create the html pages from the rst docs in current branch
    # make clean -- sphinx-build will recreate the dirs
    print(
        "removing any .doctrees toplevel dir, as well as all of the build, and html dirs"
    )
    run_command(['rm', '-rf', '.doctrees'])
    run_command(['rm', '-rf', args.build])
    run_command(['rm', '-rf', args.html])
    # make html
    print("generating the HTML via sphinx-build...")
    cmdline.main(['sphinx-build', '-b', 'html', '-aE', args.source, args.html])
    # commit all changes to current branch + push changes
    print("adding and committing all changes to the docs")
    run_command(['git', 'add', '-A'])
    # Don't exit on error because if there's nothing to commit
    # (all up to date) an error is returned, but want to go to next step
    run_command(['git', 'commit', '-m', task], exitOnError=False)
    run_command(['git', 'push', 'origin', args.branch])

    # now checkout gh-pages, wipe it, put in all generated pages, and push
    task = 'Publishing updated docs'
    print(task)
    url = get_remote_url()
    username = get_username(url)
    entity = username

    try:
        sync_ghpages(entity, args.html)
        # can do same with upstream org if requested
        entity = args.org
        if args.orgpush: sync_ghpages(entity, args.html)
    except:
        print('error trying to push gh-pages for ' + entity)