sphinxcontrib-paverutils


Namesphinxcontrib-paverutils JSON
Version 1.18.1 PyPI version JSON
download
home_pageNone
SummarySphinx/Paver integration
upload_time2025-08-05 22:32:22
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords documentation sphinx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ########################
sphinxcontrib.paverutils
########################

This module provides an alternative integration of Sphinx and
Paver_. It supports calling Sphinx from within Paver using multiple
configurations, and does not assume you only want to build HTML
output.

Basic Usage
===========

To use this module, import it in your pavement.py file as ``from
sphinxcontrib import paverutils``, then define option Bundles for
"html" and/or "pdf" output using the options described in the task
help.

For example::

    import paver
    import paver.misctasks
    from paver.path import path
    from paver.easy import *
    import paver.setuputils
    paver.setuputils.install_distutils_tasks()
    try:
        from sphinxcontrib import paverutils
    except:
        import warnings
        warnings.warn('sphinxcontrib.paverutils was not found, you will not be able to produce documentation')

    options(
        setup=Bunch(
            name = 'MyProject',
            version = '1.0',

            # ... more options here ...
            ),

        # Defaults for sphinxcontrib.paverutils
        sphinx = Bunch(
            docroot='.',
            sourcedir='docsource',
            builder='html',
        ),

        # One configuration to build HTML for the package
        html=Bunch(
            builddir='docs',
            confdir='sphinx/pkg',
        ),

        # Another configuration with different templates
        # to build HTML to upload to the website
        website=Bunch(
            builddir = 'web',
            confdir='sphinx/web',
        ),

        # We also want a PDF file for the website,
        # so the instructions are included in the web
        # configuration directory.
        pdf=Bunch(
            builddir='web',
            builder='latex',
            confdir='sphinx/web',
        ),

    )

Tasks
=====

After you have imported ``sphinxcontrib.paverutils`` in your
``pavement.py`` file, Paver will show two additional tasks.  ``html``
takes the place of the task defined in ``paver.doctools`` and can be
used to build HTML output.  ``pdf`` uses the LaTeX builder and an
external toolset such as TeXLive_ to create a PDF manual.

Configuration Parameters
========================

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)

doctrees
  the location of the cached doctrees

  default: ``$builddir/doctrees``

confdir
  the location of the sphinx conf.py

  default: ``$sourcedir``

outdir
  the location of the generated output files

  default: ``$builddir/$builder``

builder
  the name of the sphinx builder to use

  default: ``html``

template_args
  dictionary of values to be passed as name-value pairs to the HTML
  builder

  default: ``{}``


Advanced Usage
==============

You can also develop your own tasks by calling ``run_sphinx()`` directly::

    @task
    @needs(['cog'])
    @cmdopts([
        ('in-file=', 'b', 'Blog input filename'),
        ('out-file=', 'B', 'Blog output filename'),
    ])
    def blog(options):
        """Generate the blog post version of the HTML for the current module.
        """
        # Generate html from sphinx
        paverutils.run_sphinx(options, 'blog')

        blog_file = path(options.blog.outdir) / options.blog.out_file
        dry("Write blog post body to %s" % blog_file,
            gen_blog_post,
            outdir=options.blog.outdir,
            input_base=options.blog.in_file,
            blog_base=options.blog.out_file,
            )

        if 'EDITOR' in os.environ:
            sh('$EDITOR %s' % blog_file)
        return


Cog Extensions
==============

In addition to the ``html`` and ``pdf`` tasks, the package includes the function ``run_script()`` to be used with cog to insert the output of a command line program in your documentation.

This example of reStructuredText source using ``run_script()``::

    .. {{{cog
    .. cog.out(run_script(cog.inFile, 'anydbm_whichdb.py'))
    .. }}}
    .. {{{end}}}

renders to::

    .. {{{cog
    .. cog.out(run_script(cog.inFile, 'anydbm_whichdb.py'))
    .. }}}

    ::

    	$ python anydbm_whichdb.py
    	dbhash

    .. {{{end}}}

The lines prefixed with ``..`` are comments, and do not appear in the
final HTML or PDF output.

Arguments:

input_file
  The name of the file being processed by cog.  Usually passed as cog.inFile.

script_name
  The name of the Python script living in the same directory as input_file to be run.
  If not using an interpreter, this can be a complete command line.  If using an
  alternate interpreter, it can be some other type of file.

interpreter='python'
  The external interpreter to use for the program.  Specify 'python',
  'python3', 'jython', etc.

include_prefix=True
  Boolean controlling whether the ``::`` prefix is included. When chaining multiple
  commands together, the first instance would typically use the default and subsequent
  calls would use False.

ignore_error=False
  Boolean controlling whether errors are ignored.  If not ignored, the error
  is printed to stdout and then the command is run *again* with errors ignored
  so that the output ends up in the cogged file.

trailing_newlines=True
  Boolean controlling whether the trailing newlines are added to the output.
  If False, the output is passed to rstrip() then one newline is added.  If
  True, newlines are added to the output until it ends in 2.

break_lines_at=0
  Integer indicating the length where lines should be broken and
  continued on the next line.  Defaults to 0, meaning no special
  handling should be done.

line_break_mode='break'
  Mode to control how the line breaks are inserted.  Options are:

    'break'
      Insert the newline.
    'wrap'
      Use the textwrap module to wrap each line individually to the
      specified width.
    'fill'
      Use the textwrap module to wrap each line individually,
      inserting an appropriate amount of whitespace to keep the left
      edge of the lines aligned.
    'continue'
      Insert a backslash (``\``) and then a newline to break the line.
    'truncate'
      Break the line at the indicated location and discard the
      remainder.


.. note::

    PyMOTW_ makes heavy use of this function, with several variations in arguments, so
    refer to the source there for more examples if you need them.

Users
=====

PyMOTW_
    The Python Module of the Week package is built using Paver and
    Sphinx, including three forms of HTML and a PDF.

virtualenvwrapper_
    The documentation for virtualenvwrapper includes the packaged HTML
    and a website using alternate templates.

.. _Paver: http://www.blueskyonmars.com/projects/paver/

.. _PyMOTW: http://www.doughellmann.com/PyMOTW/

.. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/

.. _TeXLive: http://tug.org/texlive/


History
=======

1.6
---

* include tox.ini in source dist
* adjust interpreter for python3
* redefine cog to allow it to run on specific input file(s)
* compatibility with paver 1.2, and add support force a full build

1.5
---

Misc.

1.4
---

- Add different modes for breaking lines in the output of ``run_script()``.  

- Incorporate a fix from Maciek Starzyk for issue #6 so docroot can be
  set to something other than ``.``.

1.3
---

Added simple line-splitting to ``run_script()``.

1.2
---

Modified ``run_script()`` so that if *ignore_error* is False any
exception caused by the external application is re-raised.  This
"breaks" a build if there is a problem generating the cog output in an
rst file, and makes it easier to spot problems with the cog
instructions.

1.1
---

Updated to include ``run_script()`` function.

1.0
---

First public release based on the versions of these functions
developed for PyMOTW_.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sphinxcontrib-paverutils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "documentation, sphinx",
    "author": null,
    "author_email": "Doug Hellmann <doug@doughellmann.com>",
    "download_url": "https://files.pythonhosted.org/packages/6d/1b/0c73648b511389b68cd2c561b0372b652f7377101c77022d75c8810299ca/sphinxcontrib_paverutils-1.18.1.tar.gz",
    "platform": null,
    "description": "########################\nsphinxcontrib.paverutils\n########################\n\nThis module provides an alternative integration of Sphinx and\nPaver_. It supports calling Sphinx from within Paver using multiple\nconfigurations, and does not assume you only want to build HTML\noutput.\n\nBasic Usage\n===========\n\nTo use this module, import it in your pavement.py file as ``from\nsphinxcontrib import paverutils``, then define option Bundles for\n\"html\" and/or \"pdf\" output using the options described in the task\nhelp.\n\nFor example::\n\n    import paver\n    import paver.misctasks\n    from paver.path import path\n    from paver.easy import *\n    import paver.setuputils\n    paver.setuputils.install_distutils_tasks()\n    try:\n        from sphinxcontrib import paverutils\n    except:\n        import warnings\n        warnings.warn('sphinxcontrib.paverutils was not found, you will not be able to produce documentation')\n\n    options(\n        setup=Bunch(\n            name = 'MyProject',\n            version = '1.0',\n\n            # ... more options here ...\n            ),\n\n        # Defaults for sphinxcontrib.paverutils\n        sphinx = Bunch(\n            docroot='.',\n            sourcedir='docsource',\n            builder='html',\n        ),\n\n        # One configuration to build HTML for the package\n        html=Bunch(\n            builddir='docs',\n            confdir='sphinx/pkg',\n        ),\n\n        # Another configuration with different templates\n        # to build HTML to upload to the website\n        website=Bunch(\n            builddir = 'web',\n            confdir='sphinx/web',\n        ),\n\n        # We also want a PDF file for the website,\n        # so the instructions are included in the web\n        # configuration directory.\n        pdf=Bunch(\n            builddir='web',\n            builder='latex',\n            confdir='sphinx/web',\n        ),\n\n    )\n\nTasks\n=====\n\nAfter you have imported ``sphinxcontrib.paverutils`` in your\n``pavement.py`` file, Paver will show two additional tasks.  ``html``\ntakes the place of the task defined in ``paver.doctools`` and can be\nused to build HTML output.  ``pdf`` uses the LaTeX builder and an\nexternal toolset such as TeXLive_ to create a PDF manual.\n\nConfiguration Parameters\n========================\n\ndocroot\n  the root under which Sphinx will be working.\n  \n  default: ``docs``\n\nbuilddir\n  directory under the docroot where the resulting files are put.\n\n  default: ``build``\n\nsourcedir\n  directory under the docroot for the source files\n\n  default: ``\"\"`` (empty string)\n\ndoctrees\n  the location of the cached doctrees\n\n  default: ``$builddir/doctrees``\n\nconfdir\n  the location of the sphinx conf.py\n\n  default: ``$sourcedir``\n\noutdir\n  the location of the generated output files\n\n  default: ``$builddir/$builder``\n\nbuilder\n  the name of the sphinx builder to use\n\n  default: ``html``\n\ntemplate_args\n  dictionary of values to be passed as name-value pairs to the HTML\n  builder\n\n  default: ``{}``\n\n\nAdvanced Usage\n==============\n\nYou can also develop your own tasks by calling ``run_sphinx()`` directly::\n\n    @task\n    @needs(['cog'])\n    @cmdopts([\n        ('in-file=', 'b', 'Blog input filename'),\n        ('out-file=', 'B', 'Blog output filename'),\n    ])\n    def blog(options):\n        \"\"\"Generate the blog post version of the HTML for the current module.\n        \"\"\"\n        # Generate html from sphinx\n        paverutils.run_sphinx(options, 'blog')\n\n        blog_file = path(options.blog.outdir) / options.blog.out_file\n        dry(\"Write blog post body to %s\" % blog_file,\n            gen_blog_post,\n            outdir=options.blog.outdir,\n            input_base=options.blog.in_file,\n            blog_base=options.blog.out_file,\n            )\n\n        if 'EDITOR' in os.environ:\n            sh('$EDITOR %s' % blog_file)\n        return\n\n\nCog Extensions\n==============\n\nIn addition to the ``html`` and ``pdf`` tasks, the package includes the function ``run_script()`` to be used with cog to insert the output of a command line program in your documentation.\n\nThis example of reStructuredText source using ``run_script()``::\n\n    .. {{{cog\n    .. cog.out(run_script(cog.inFile, 'anydbm_whichdb.py'))\n    .. }}}\n    .. {{{end}}}\n\nrenders to::\n\n    .. {{{cog\n    .. cog.out(run_script(cog.inFile, 'anydbm_whichdb.py'))\n    .. }}}\n\n    ::\n\n    \t$ python anydbm_whichdb.py\n    \tdbhash\n\n    .. {{{end}}}\n\nThe lines prefixed with ``..`` are comments, and do not appear in the\nfinal HTML or PDF output.\n\nArguments:\n\ninput_file\n  The name of the file being processed by cog.  Usually passed as cog.inFile.\n\nscript_name\n  The name of the Python script living in the same directory as input_file to be run.\n  If not using an interpreter, this can be a complete command line.  If using an\n  alternate interpreter, it can be some other type of file.\n\ninterpreter='python'\n  The external interpreter to use for the program.  Specify 'python',\n  'python3', 'jython', etc.\n\ninclude_prefix=True\n  Boolean controlling whether the ``::`` prefix is included. When chaining multiple\n  commands together, the first instance would typically use the default and subsequent\n  calls would use False.\n\nignore_error=False\n  Boolean controlling whether errors are ignored.  If not ignored, the error\n  is printed to stdout and then the command is run *again* with errors ignored\n  so that the output ends up in the cogged file.\n\ntrailing_newlines=True\n  Boolean controlling whether the trailing newlines are added to the output.\n  If False, the output is passed to rstrip() then one newline is added.  If\n  True, newlines are added to the output until it ends in 2.\n\nbreak_lines_at=0\n  Integer indicating the length where lines should be broken and\n  continued on the next line.  Defaults to 0, meaning no special\n  handling should be done.\n\nline_break_mode='break'\n  Mode to control how the line breaks are inserted.  Options are:\n\n    'break'\n      Insert the newline.\n    'wrap'\n      Use the textwrap module to wrap each line individually to the\n      specified width.\n    'fill'\n      Use the textwrap module to wrap each line individually,\n      inserting an appropriate amount of whitespace to keep the left\n      edge of the lines aligned.\n    'continue'\n      Insert a backslash (``\\``) and then a newline to break the line.\n    'truncate'\n      Break the line at the indicated location and discard the\n      remainder.\n\n\n.. note::\n\n    PyMOTW_ makes heavy use of this function, with several variations in arguments, so\n    refer to the source there for more examples if you need them.\n\nUsers\n=====\n\nPyMOTW_\n    The Python Module of the Week package is built using Paver and\n    Sphinx, including three forms of HTML and a PDF.\n\nvirtualenvwrapper_\n    The documentation for virtualenvwrapper includes the packaged HTML\n    and a website using alternate templates.\n\n.. _Paver: http://www.blueskyonmars.com/projects/paver/\n\n.. _PyMOTW: http://www.doughellmann.com/PyMOTW/\n\n.. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/\n\n.. _TeXLive: http://tug.org/texlive/\n\n\nHistory\n=======\n\n1.6\n---\n\n* include tox.ini in source dist\n* adjust interpreter for python3\n* redefine cog to allow it to run on specific input file(s)\n* compatibility with paver 1.2, and add support force a full build\n\n1.5\n---\n\nMisc.\n\n1.4\n---\n\n- Add different modes for breaking lines in the output of ``run_script()``.  \n\n- Incorporate a fix from Maciek Starzyk for issue #6 so docroot can be\n  set to something other than ``.``.\n\n1.3\n---\n\nAdded simple line-splitting to ``run_script()``.\n\n1.2\n---\n\nModified ``run_script()`` so that if *ignore_error* is False any\nexception caused by the external application is re-raised.  This\n\"breaks\" a build if there is a problem generating the cog output in an\nrst file, and makes it easier to spot problems with the cog\ninstructions.\n\n1.1\n---\n\nUpdated to include ``run_script()`` function.\n\n1.0\n---\n\nFirst public release based on the versions of these functions\ndeveloped for PyMOTW_.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Sphinx/Paver integration",
    "version": "1.18.1",
    "project_urls": {
        "Homepage": "https://bitbucket.org/dhellmann/sphinxcontrib-paverutils/"
    },
    "split_keywords": [
        "documentation",
        " sphinx"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c4f1f441ce823ce7d4442f0ad19d5498992538ea24c9899a73effd927ab04f0f",
                "md5": "db924fc6a67002af301362dbed1a6904",
                "sha256": "c0851ae12a1915f11a895186073b403ba0a0402a05bd89db69e7dc7206f96822"
            },
            "downloads": -1,
            "filename": "sphinxcontrib_paverutils-1.18.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db924fc6a67002af301362dbed1a6904",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 10337,
            "upload_time": "2025-08-05T22:32:21",
            "upload_time_iso_8601": "2025-08-05T22:32:21.239366Z",
            "url": "https://files.pythonhosted.org/packages/c4/f1/f441ce823ce7d4442f0ad19d5498992538ea24c9899a73effd927ab04f0f/sphinxcontrib_paverutils-1.18.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6d1b0c73648b511389b68cd2c561b0372b652f7377101c77022d75c8810299ca",
                "md5": "00189cd00adeb4ff81290ee844e708b9",
                "sha256": "8abaed9b77cf1e477c647193d2eb876947dc8313ee2b6439d6fc0ffcb0552953"
            },
            "downloads": -1,
            "filename": "sphinxcontrib_paverutils-1.18.1.tar.gz",
            "has_sig": false,
            "md5_digest": "00189cd00adeb4ff81290ee844e708b9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9459,
            "upload_time": "2025-08-05T22:32:22",
            "upload_time_iso_8601": "2025-08-05T22:32:22.356948Z",
            "url": "https://files.pythonhosted.org/packages/6d/1b/0c73648b511389b68cd2c561b0372b652f7377101c77022d75c8810299ca/sphinxcontrib_paverutils-1.18.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-05 22:32:22",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "dhellmann",
    "bitbucket_project": "sphinxcontrib-paverutils",
    "lcname": "sphinxcontrib-paverutils"
}
        
Elapsed time: 0.93658s