Example #1
0
def migrate(options):
    "Copy old content into place to prepare for updating"
    args = getattr(options, 'args', [])
    options.order('update', 'sphinx', add_rest=True)
    module = _get_module(options)
    # The source module name might be different from the destination
    # module name, so look for an explicit argument for the source.
    source = module
    args = getattr(options, 'args', [])
    if args:
        source = args[0]
    dest = path('source/' + module)
    if dest.exists():
        raise ValueError('%s already exists' % dest)
    for src_path in options.migrate.old_locs:
        the_src = path(src_path + '/' + source)
        if not the_src.exists():
            print('did not find {}'.format(the_src))
            continue
        the_src.copytree(dest)
        break
    (dest + '/__init__.py').remove()
    if source != module:
        # Rename any modules that have the old source module name to
        # use the new source module name.
        for srcfile in dest.glob(source + '_*.py'):
            newname = srcfile.name.replace(source + '_', module + '_')
            srcfile.rename(dest + '/' + newname)
    sh('git add ' + dest)
    sh('git commit -m "%s: initial import"' % module)
    common_cleanups(options)
    sh('git add ' + dest)
    sh('git commit -m "%s: common cleanups"' % module)
    manual_review_cleanups(options)
Example #2
0
def blog(options):
    """Generate the blog post version of the HTML for the current module.

    The default behavior generates the post for the current module using
    its index.html file as input.

    To use a different file within the module directory, use the
    --in-file or -b option::

      paver blog -b communication.html

    To run against a directory other than a module, use the
    -s or --sourcedir option::

      paver blog -s PyMOTW/articles -b text_processing.html
    """
    options.order('blog', 'sphinx', add_rest=True)
    module = _get_module(options)

    # Create output directory
    out = path(options.outdir)
    if not out.exists():
        out.mkdir()

    blog_file = path(options.outdir) / module + '.html'
    title, body = dry(
        'building blog post body',
        gen_blog_post_from_page,
        input_file=path(options.builddir) / 'html' / module / options.in_file,
        module=module,
        url_base=options.url_base,
    )
    print('title {!r}'.format(title))
    post_draft(title, body)
    return
Example #3
0
def blog(options):
    """Generate the blog post version of the HTML for the current module.

    The default behavior generates the post for the current module using
    its index.html file as input.

    To use a different file within the module directory, use the
    --in-file or -b option::

      paver blog -b communication.html

    To run against a directory other than a module, use the
    -s or --sourcedir option::

      paver blog -s PyMOTW/articles -b text_processing.html
    """
    options.order('blog', 'sphinx', add_rest=True)
    module = _get_module(options)

    # Create output directory
    out = path(options.outdir)
    if not out.exists():
        out.mkdir()

    blog_file = path(options.outdir) / module + '.html'
    title, body = dry(
        'building blog post body',
        gen_blog_post_from_page,
        input_file=path(options.builddir) / 'html' / module / options.in_file,
        module=module,
        url_base=options.url_base,
    )
    print('title {!r}'.format(title))
    post_draft(title, body)
    return
Example #4
0
File: docs.py Project: ponty/paved
def pdf():
    """Build PDF documentation using Sphinx. This uses the following
    options in a "sphinx" section of the options.

    docroot
      the root under which Sphinx will be working. Default: docs
    builddir
      directory under the docroot where the resulting files are put.
      default: build
    sourcedir
      directory under the docroot for the source files
      default: (empty string)
      
    Code is based on paver.doctools.html
    """
    if not has_sphinx:
        raise BuildFailure('install sphinx to build html docs')
    options.order('sphinx', add_rest=True)
    paths = paver.doctools._get_paths()
    pdfdir = pdfdir_path()
    sphinxopts = ['', '-b', 'latex', '-d', paths.doctrees,
        paths.srcdir, pdfdir]
    dry("sphinx-build %s" % (" ".join(sphinxopts),), sphinx.main, sphinxopts)
    sh('make', cwd=pdfdir)

    # copy pdf into html directory
    paths.htmldir.makedirs_p()
    find_pdf_file().copy(paths.htmldir)
def pdf():
    """Generate the PDF book.
    """
    options.order('pdf', 'sphinx', add_rest=True)
    os.environ['_PYGMENTS_STYLE'] = options.pygments_style
    os.environ['_BUILDING_BOOK'] = 'True'
    paverutils.pdf(options)
    return
Example #6
0
def flake8(options):
    """Run flake8 against all of the input files"""
    options.order('flake8', 'sphinx', add_rest=True)
    module = _get_module(options)
    if module:
        module_dir = os.path.join(options.sphinx.sourcedir, module)
        _flake8(module_dir)
    else:
        _flake8(options.sphinx.sourcedir)
Example #7
0
def flake8(options):
    """Run flake8 against all of the input files"""
    options.order('flake8', 'sphinx', add_rest=True)
    module = _get_module(options)
    if module:
        module_dir = os.path.join(options.sphinx.sourcedir, module)
        _flake8(module_dir)
    else:
        _flake8(options.sphinx.sourcedir)
Example #8
0
def update(options):
    """Run cog against the named module, then re-build the HTML.

    Examples::

      $ paver update atexit
    """
    options.order('update', 'sphinx', add_rest=True)
    module = _get_module(options)
    module_dir = os.path.join(options.sphinx.sourcedir, module)
    if path(module_dir).isdir():
        _flake8(module_dir)
    options.order('cog', 'sphinx', add_rest=True)
    options.args = [module_dir]
    cog(options)
    html(options)
    return
Example #9
0
def update(options):
    """Run cog against the named module, then re-build the HTML.

    Examples::

      $ paver update atexit
    """
    options.order('update', 'sphinx', add_rest=True)
    module = _get_module(options)
    module_dir = os.path.join(options.sphinx.sourcedir, module)
    if path(module_dir).isdir():
        _flake8(module_dir)
    options.order('cog', 'sphinx', add_rest=True)
    options.args = [module_dir]
    cog(options)
    html(options)
    return
Example #10
0
def migrate(options):
    "Copy old content into place to prepare for updating"
    args = getattr(options, 'args', [])
    options.order('update', 'sphinx', add_rest=True)
    module = _get_module(options)
    # The source module name might be different from the destination
    # module name, so look for an explicit argument for the source.
    source = module
    args = getattr(options, 'args', [])
    if args:
        source = args[0]
    dest = path('source/' + module)
    if dest.exists():
        raise ValueError('%s already exists' % dest)
    path(options.migrate.old_loc + '/' + source).copytree(dest)
    (dest + '/__init__.py').remove()
    if source != module:
        # Rename any modules that have the old source module name to
        # use the new source module name.
        for srcfile in dest.glob(source + '_*.py'):
            newname = srcfile.name.replace(source + '_', module + '_')
            srcfile.rename(dest + '/' + newname)
Example #11
0
def gettext(options):
    "Collect all translatable strings from rst input."
    # Clean and recreate output directory
    remake_directories(options.gettext.outdir)
    # Choosing another doctree directory
    remake_directories(os.path.dirname(options.gettext.doctrees))
    # Set templates environment variable, used by sphinx/conf.py
    ##os.environ['TEMPLATES'] = options.gettext.templates
    if paverutils is None:
        raise RuntimeError(
            'Could not find sphinxcontrib.paverutils, will not be able to build text output.'
        )
    # Extract messages (POT)
    ##import dbg; dbg.set_trace()
    options.order('gettext', 'sphinx', add_rest=True)
    paverutils.run_sphinx(options, "gettext")
    # Update translations PO: TODO: read conf["locale_dirs"][0] & language (es)
    sh('sphinx-intl update -p "%s" --locale-dir locale -l es' %
       (options.gettext.outdir, ))
    # Remember to build the MO files once translated:
    sh('sphinx-intl build --locale-dir locale')
    return
Example #12
0
def pdf():
    """Generate the PDF book.
    """
    options.order('pdf', 'sphinx', add_rest=True)
    paverutils.pdf(options)
    return
def linkcheck():
    """Check outgoing links
    """
    options.order('linkcheck', 'sphinx', add_rest=True)
    paverutils.run_sphinx(options, 'linkcheck')
    return