[pypy-commit] benchmarks chameleon: update sphinx to 1.8.5
mattip
pypy.commits at gmail.com
Mon Jan 6 15:26:39 EST 2020
Author: Matti Picus <matti.picus at gmail.com>
Branch: chameleon
Changeset: r418:ab6c3e5c29b6
Date: 2020-01-06 14:05 +0200
http://bitbucket.org/pypy/benchmarks/changeset/ab6c3e5c29b6/
Log: update sphinx to 1.8.5
diff too long, truncating to 2000 out of 230237 lines
diff --git a/lib/cpython-doc/conf.py b/lib/cpython-doc/conf.py
--- a/lib/cpython-doc/conf.py
+++ b/lib/cpython-doc/conf.py
@@ -12,7 +12,7 @@
# General configuration
# ---------------------
-extensions = ['sphinx.ext.refcounting', 'sphinx.ext.coverage',
+extensions = ['sphinx.ext.coverage',
'sphinx.ext.doctest', 'pyspecific']
templates_path = ['tools/sphinxext']
diff --git a/lib/cpython-doc/tools/docutils2/__init__.py b/lib/cpython-doc/tools/docutils2/__init__.py
new file mode 100644
--- /dev/null
+++ b/lib/cpython-doc/tools/docutils2/__init__.py
@@ -0,0 +1,232 @@
+# $Id: __init__.py 8304 2019-07-30 09:51:07Z grubert $
+# Author: David Goodger <goodger at python.org>
+# Copyright: This module has been placed in the public domain.
+
+"""
+This is the Docutils (Python Documentation Utilities) package.
+
+Package Structure
+=================
+
+Modules:
+
+- __init__.py: Contains component base classes, exception classes, and
+ Docutils version information.
+
+- core.py: Contains the ``Publisher`` class and ``publish_*()`` convenience
+ functions.
+
+- frontend.py: Runtime settings (command-line interface, configuration files)
+ processing, for Docutils front-ends.
+
+- io.py: Provides a uniform API for low-level input and output.
+
+- nodes.py: Docutils document tree (doctree) node class library.
+
+- statemachine.py: A finite state machine specialized for
+ regular-expression-based text filters.
+
+Subpackages:
+
+- languages: Language-specific mappings of terms.
+
+- parsers: Syntax-specific input parser modules or packages.
+
+- readers: Context-specific input handlers which understand the data
+ source and manage a parser.
+
+- transforms: Modules used by readers and writers to modify DPS
+ doctrees.
+
+- utils: Contains the ``Reporter`` system warning class and miscellaneous
+ utilities used by readers, writers, and transforms.
+
+ utils/urischemes.py: Contains a complete mapping of known URI addressing
+ scheme names to descriptions.
+
+- utils/math: Contains functions for conversion of mathematical notation
+ between different formats (LaTeX, MathML, text, ...).
+
+- writers: Format-specific output translators.
+"""
+
+import sys
+from collections import namedtuple
+
+
+__docformat__ = 'reStructuredText'
+
+__version__ = '0.15.2'
+"""Docutils version identifier (complies with PEP 440)::
+
+ major.minor[.micro][releaselevel[serial]][.dev]
+
+For version comparison operations, use `__version_info__` (which see, below)
+rather than parsing the text of `__version__`.
+
+See 'Version Numbering' in docs/dev/policies.txt.
+"""
+
+VersionInfo = namedtuple(
+ 'VersionInfo', 'major minor micro releaselevel serial release')
+
+__version_info__ = VersionInfo(
+ major=0,
+ minor=15,
+ micro=2,
+ releaselevel='final', # one of 'alpha', 'beta', 'candidate', 'final'
+ # pre-release serial number (0 for final releases and active development):
+ serial=0,
+ release=True # True for official releases and pre-releases
+ )
+"""Comprehensive version information tuple. See 'Version Numbering' in
+docs/dev/policies.txt."""
+
+__version_details__ = 'release'
+"""Optional extra version details (e.g. 'snapshot 2005-05-29, r3410').
+(For development and release status see `__version_info__`.)
+"""
+
+
+class ApplicationError(StandardError): pass
+class DataError(ApplicationError): pass
+
+
+class SettingsSpec:
+
+ """
+ Runtime setting specification base class.
+
+ SettingsSpec subclass objects used by `docutils.frontend.OptionParser`.
+ """
+
+ settings_spec = ()
+ """Runtime settings specification. Override in subclasses.
+
+ Defines runtime settings and associated command-line options, as used by
+ `docutils.frontend.OptionParser`. This is a tuple of:
+
+ - Option group title (string or `None` which implies no group, just a list
+ of single options).
+
+ - Description (string or `None`).
+
+ - A sequence of option tuples. Each consists of:
+
+ - Help text (string)
+
+ - List of option strings (e.g. ``['-Q', '--quux']``).
+
+ - Dictionary of keyword arguments sent to the OptionParser/OptionGroup
+ ``add_option`` method.
+
+ Runtime setting names are derived implicitly from long option names
+ ('--a-setting' becomes ``settings.a_setting``) or explicitly from the
+ 'dest' keyword argument.
+
+ Most settings will also have a 'validator' keyword & function. The
+ validator function validates setting values (from configuration files
+ and command-line option arguments) and converts them to appropriate
+ types. For example, the ``docutils.frontend.validate_boolean``
+ function, **required by all boolean settings**, converts true values
+ ('1', 'on', 'yes', and 'true') to 1 and false values ('0', 'off',
+ 'no', 'false', and '') to 0. Validators need only be set once per
+ setting. See the `docutils.frontend.validate_*` functions.
+
+ See the optparse docs for more details.
+
+ - More triples of group title, description, options, as many times as
+ needed. Thus, `settings_spec` tuples can be simply concatenated.
+ """
+
+ settings_defaults = None
+ """A dictionary of defaults for settings not in `settings_spec` (internal
+ settings, intended to be inaccessible by command-line and config file).
+ Override in subclasses."""
+
+ settings_default_overrides = None
+ """A dictionary of auxiliary defaults, to override defaults for settings
+ defined in other components. Override in subclasses."""
+
+ relative_path_settings = ()
+ """Settings containing filesystem paths. Override in subclasses.
+ Settings listed here are to be interpreted relative to the current working
+ directory."""
+
+ config_section = None
+ """The name of the config file section specific to this component
+ (lowercase, no brackets). Override in subclasses."""
+
+ config_section_dependencies = None
+ """A list of names of config file sections that are to be applied before
+ `config_section`, in order (from general to specific). In other words,
+ the settings in `config_section` are to be overlaid on top of the settings
+ from these sections. The "general" section is assumed implicitly.
+ Override in subclasses."""
+
+
+class TransformSpec:
+
+ """
+ Runtime transform specification base class.
+
+ TransformSpec subclass objects used by `docutils.transforms.Transformer`.
+ """
+
+ def get_transforms(self):
+ """Transforms required by this class. Override in subclasses."""
+ if self.default_transforms != ():
+ import warnings
+ warnings.warn('default_transforms attribute deprecated.\n'
+ 'Use get_transforms() method instead.',
+ DeprecationWarning)
+ return list(self.default_transforms)
+ return []
+
+ # Deprecated; for compatibility.
+ default_transforms = ()
+
+ unknown_reference_resolvers = ()
+ """List of functions to try to resolve unknown references. Unknown
+ references have a 'refname' attribute which doesn't correspond to any
+ target in the document. Called when the transforms in
+ `docutils.tranforms.references` are unable to find a correct target. The
+ list should contain functions which will try to resolve unknown
+ references, with the following signature::
+
+ def reference_resolver(node):
+ '''Returns boolean: true if resolved, false if not.'''
+
+ If the function is able to resolve the reference, it should also remove
+ the 'refname' attribute and mark the node as resolved::
+
+ del node['refname']
+ node.resolved = 1
+
+ Each function must have a "priority" attribute which will affect the order
+ the unknown_reference_resolvers are run::
+
+ reference_resolver.priority = 100
+
+ Override in subclasses."""
+
+
+class Component(SettingsSpec, TransformSpec):
+
+ """Base class for Docutils components."""
+
+ component_type = None
+ """Name of the component type ('reader', 'parser', 'writer'). Override in
+ subclasses."""
+
+ supported = ()
+ """Names for this component. Override in subclasses."""
+
+ def supports(self, format):
+ """
+ Is `format` supported by this component?
+
+ To be used by transforms to ask the dependent component if it supports
+ a certain input context or output format.
+ """
+ return format in self.supported
diff --git a/lib/cpython-doc/tools/docutils2/_compat.py b/lib/cpython-doc/tools/docutils2/_compat.py
new file mode 100644
--- /dev/null
+++ b/lib/cpython-doc/tools/docutils2/_compat.py
@@ -0,0 +1,24 @@
+# $Id: _compat.py 8164 2017-08-14 11:28:48Z milde $
+# Author: Georg Brandl <georg at python.org>
+# Copyright: This module has been placed in the public domain.
+
+"""
+Python 2/3 compatibility definitions.
+
+This module currently provides the following helper symbols:
+
+* u_prefix (unicode repr prefix: 'u' in 2.x, '' in 3.x)
+ (Required in docutils/test/test_publisher.py)
+* BytesIO (a StringIO class that works with bytestrings)
+"""
+
+import sys
+
+if sys.version_info < (3,0):
+ u_prefix = 'u'
+ from StringIO import StringIO as BytesIO
+else:
+ u_prefix = b''
+ # using this hack since 2to3 "fixes" the relative import
+ # when using ``from io import BytesIO``
+ BytesIO = __import__('io').BytesIO
diff --git a/lib/cpython-doc/tools/sphinx/.svn/all-wcprops b/lib/cpython-doc/tools/sphinx/.svn/all-wcprops
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/all-wcprops
+++ /dev/null
@@ -1,89 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 53
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx
-END
-jinja2glue.py
-K 25
-svn:wc:ra_dav:version-url
-V 67
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/jinja2glue.py
-END
-quickstart.py
-K 25
-svn:wc:ra_dav:version-url
-V 67
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/quickstart.py
-END
-theming.py
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/theming.py
-END
-cmdline.py
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/cmdline.py
-END
-errors.py
-K 25
-svn:wc:ra_dav:version-url
-V 63
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/errors.py
-END
-setup_command.py
-K 25
-svn:wc:ra_dav:version-url
-V 70
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/setup_command.py
-END
-__init__.py
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/__init__.py
-END
-addnodes.py
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/addnodes.py
-END
-application.py
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/application.py
-END
-environment.py
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/environment.py
-END
-roles.py
-K 25
-svn:wc:ra_dav:version-url
-V 62
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/roles.py
-END
-search.py
-K 25
-svn:wc:ra_dav:version-url
-V 63
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/search.py
-END
-config.py
-K 25
-svn:wc:ra_dav:version-url
-V 63
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/config.py
-END
-highlighting.py
-K 25
-svn:wc:ra_dav:version-url
-V 69
-/projects/!svn/ver/88027/external/Sphinx-1.0.7/sphinx/highlighting.py
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/entries b/lib/cpython-doc/tools/sphinx/.svn/entries
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/entries
+++ /dev/null
@@ -1,534 +0,0 @@
-10
-
-dir
-88932
-http://svn.python.org/projects/external/Sphinx-1.0.7/sphinx
-http://svn.python.org/projects
-
-
-
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6015fed2-1504-0410-9fe1-9d1591cc4771
-
-quickstart.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-d7c91cdacec0106e76d874f562939174
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-29708
-
-jinja2glue.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-47f79fb76a46774c34205cae39337c5f
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4454
-
-theming.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-a1c91f90f4d31230d983821ca21ec6e3
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5423
-
-pycode
-dir
-
-setup_command.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-8742cba4b23f0eb46667c0177da85b56
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5355
-
-themes
-dir
-
-__init__.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-1867303de7d72852f4d3ae99cf56dba1
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2325
-
-domains
-dir
-
-application.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-78f02f7c2e70f5aa02eb7e7736e77316
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-21050
-
-environment.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-120b253cf657c4b44c5d7ac3be9ac592
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-66470
-
-search.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-836a76934df5c092c5f92aaf624fb69b
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7044
-
-config.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-e90651ee3fe91dd2e771c4f9723720f9
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8226
-
-highlighting.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-0cd36e41a90a343db97699f6758ef0db
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8763
-
-locale
-dir
-
-writers
-dir
-
-ext
-dir
-
-directives
-dir
-
-cmdline.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-49a8eaf743a36296914543171787a28f
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8389
-
-texinputs
-dir
-
-errors.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-a724584f62d8db56edb41295b5689edc
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1711
-
-addnodes.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-f17229746029988096a052176f37cd7d
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3783
-
-builders
-dir
-
-roles.py
-file
-
-
-
-
-2012-01-17T08:33:36.552225Z
-001dca9185373835c7d8c1a8658e5047
-2011-01-15T16:44:52.424301Z
-88027
-georg.brandl
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-10885
-
-util
-dir
-
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/__init__.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/__init__.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/__init__.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/addnodes.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/addnodes.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/addnodes.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/application.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/application.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/application.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/cmdline.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/cmdline.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/cmdline.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/config.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/config.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/config.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/environment.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/environment.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/environment.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/errors.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/errors.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/errors.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/highlighting.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/highlighting.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/highlighting.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/jinja2glue.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/jinja2glue.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/jinja2glue.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/quickstart.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/quickstart.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/quickstart.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/roles.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/roles.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/roles.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/search.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/search.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/search.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/setup_command.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/setup_command.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/setup_command.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/prop-base/theming.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/prop-base/theming.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/prop-base/theming.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 12
-svn:keywords
-V 2
-Id
-END
diff --git a/lib/cpython-doc/tools/sphinx/.svn/text-base/__init__.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/text-base/__init__.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/text-base/__init__.py.svn-base
+++ /dev/null
@@ -1,71 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- Sphinx
- ~~~~~~
-
- The Sphinx documentation toolchain.
-
- :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-import sys
-from os import path
-
-__version__ = '1.0.7'
-__released__ = '1.0.7' # used when Sphinx builds its own docs
-
-package_dir = path.abspath(path.dirname(__file__))
-
-if '+' in __version__ or 'pre' in __version__:
- # try to find out the changeset hash if checked out from hg, and append
- # it to __version__ (since we use this value from setup.py, it gets
- # automatically propagated to an installed copy as well)
- try:
- import subprocess
- p = subprocess.Popen(['hg', 'id', '-i', '-R',
- path.join(package_dir, '..')],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- if out:
- __version__ += '/' + out.strip()
- except Exception:
- pass
-
-
-def main(argv=sys.argv):
- if sys.version_info[:3] < (2, 4, 0):
- print >>sys.stderr, \
- 'Error: Sphinx requires at least Python 2.4 to run.'
- return 1
-
- 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 = '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.')
- 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))
diff --git a/lib/cpython-doc/tools/sphinx/.svn/text-base/addnodes.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/text-base/addnodes.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/text-base/addnodes.py.svn-base
+++ /dev/null
@@ -1,113 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- sphinx.addnodes
- ~~~~~~~~~~~~~~~
-
- Additional docutils nodes.
-
- :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-from docutils import nodes
-
-# index markup
-class index(nodes.Invisible, nodes.Inline, nodes.TextElement): pass
-
-# domain-specific object descriptions (class, function etc.)
-
-# parent node for signature and content
-class desc(nodes.Admonition, nodes.Element): pass
-
-# additional name parts (module name, class name)
-class desc_addname(nodes.Part, nodes.Inline, nodes.TextElement): pass
-# compatibility alias
-desc_classname = desc_addname
-# return type (C); object type
-class desc_type(nodes.Part, nodes.Inline, nodes.TextElement): pass
-# -> annotation (Python)
-class desc_returns(desc_type):
- def astext(self):
- return ' -> ' + nodes.TextElement.astext(self)
-# main name of object
-class desc_name(nodes.Part, nodes.Inline, nodes.TextElement): pass
-# argument list
-class desc_signature(nodes.Part, nodes.Inline, nodes.TextElement): pass
-class desc_parameterlist(nodes.Part, nodes.Inline, nodes.TextElement):
- child_text_separator = ', '
-class desc_parameter(nodes.Part, nodes.Inline, nodes.TextElement): pass
-class desc_optional(nodes.Part, nodes.Inline, nodes.TextElement):
- child_text_separator = ', '
- def astext(self):
- return '[' + nodes.TextElement.astext(self) + ']'
-# annotation (not Python 3-style annotations)
-class desc_annotation(nodes.Part, nodes.Inline, nodes.TextElement): pass
-
-# node for content
-class desc_content(nodes.General, nodes.Element): pass
-
-# \versionadded, \versionchanged, \deprecated
-class versionmodified(nodes.Admonition, nodes.TextElement): pass
-
-# seealso
-class seealso(nodes.Admonition, nodes.Element): pass
-
-# productionlist
-class productionlist(nodes.Admonition, nodes.Element): pass
-class production(nodes.Part, nodes.Inline, nodes.TextElement): pass
-
-# toc tree
-class toctree(nodes.General, nodes.Element): pass
-
-# centered
-class centered(nodes.Part, nodes.Element): pass
-
-# pending xref
-class pending_xref(nodes.Inline, nodes.Element): pass
-
-# compact paragraph -- never makes a <p>
-class compact_paragraph(nodes.paragraph): pass
-
-# reference to a file to download
-class download_reference(nodes.reference): pass
-
-# for the ACKS list
-class acks(nodes.Element): pass
-
-# for horizontal lists
-class hlist(nodes.Element): pass
-class hlistcol(nodes.Element): pass
-
-# sets the highlighting language for literal blocks
-class highlightlang(nodes.Element): pass
-
-# like emphasis, but doesn't apply further text processors, e.g. smartypants
-class literal_emphasis(nodes.emphasis): pass
-
-# for abbreviations (with explanations)
-class abbreviation(nodes.Inline, nodes.TextElement): pass
-
-# glossary
-class glossary(nodes.Element): pass
-
-# start of a file, used in the LaTeX builder only
-class start_of_file(nodes.Element): pass
-
-# tabular column specification, used for the LaTeX writer
-class tabular_col_spec(nodes.Element): pass
-
-# only (in/exclusion based on tags)
-class only(nodes.Element): pass
-
-# meta directive -- same as docutils' standard meta node, but pickleable
-class meta(nodes.Special, nodes.PreBibliographic, nodes.Element): pass
-
-# make them known to docutils. this is needed, because the HTML writer
-# will choke at some point if these are not added
-nodes._add_node_class_names("""index desc desc_content desc_signature
- desc_type desc_returns desc_addname desc_name desc_parameterlist
- desc_parameter desc_optional download_reference hlist hlistcol
- centered versionmodified seealso productionlist production toctree
- pending_xref compact_paragraph highlightlang literal_emphasis
- abbreviation glossary acks module start_of_file tabular_col_spec
- meta""".split())
diff --git a/lib/cpython-doc/tools/sphinx/.svn/text-base/application.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/text-base/application.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/text-base/application.py.svn-base
+++ /dev/null
@@ -1,532 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- sphinx.application
- ~~~~~~~~~~~~~~~~~~
-
- Sphinx application object.
-
- Gracefully adapted from the TextPress system by Armin.
-
- :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-import sys
-import types
-import posixpath
-from os import path
-from cStringIO import StringIO
-
-from docutils import nodes
-from docutils.parsers.rst import convert_directive_function, \
- directives, roles
-
-import sphinx
-from sphinx import package_dir, locale
-from sphinx.roles import XRefRole
-from sphinx.config import Config
-from sphinx.errors import SphinxError, SphinxWarning, ExtensionError, \
- VersionRequirementError
-from sphinx.domains import ObjType, BUILTIN_DOMAINS
-from sphinx.domains.std import GenericObject, Target, StandardDomain
-from sphinx.builders import BUILTIN_BUILDERS
-from sphinx.environment import BuildEnvironment, SphinxStandaloneReader
-from sphinx.util import pycompat # imported for side-effects
-from sphinx.util.tags import Tags
-from sphinx.util.osutil import ENOENT
-from sphinx.util.console import bold
-
-
-# Directive is either new-style or old-style
-clstypes = (type, types.ClassType)
-
-# List of all known core events. Maps name to arguments description.
-events = {
- 'builder-inited': '',
- 'env-purge-doc': 'env, docname',
- 'source-read': 'docname, source text',
- 'doctree-read': 'the doctree before being pickled',
- 'missing-reference': 'env, node, contnode',
- 'doctree-resolved': 'doctree, docname',
- 'env-updated': 'env',
- 'html-collect-pages': 'builder',
- 'html-page-context': 'pagename, context, doctree or None',
- 'build-finished': 'exception',
-}
-
-CONFIG_FILENAME = 'conf.py'
-ENV_PICKLE_FILENAME = 'environment.pickle'
-
-
-class Sphinx(object):
-
- def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
- confoverrides=None, status=sys.stdout, warning=sys.stderr,
- freshenv=False, warningiserror=False, tags=None):
- self.next_listener_id = 0
- self._extensions = {}
- self._listeners = {}
- self.domains = BUILTIN_DOMAINS.copy()
- self.builderclasses = BUILTIN_BUILDERS.copy()
- self.builder = None
- self.env = None
-
- self.srcdir = srcdir
- self.confdir = confdir
- self.outdir = outdir
- self.doctreedir = doctreedir
-
- if status is None:
- self._status = StringIO()
- self.quiet = True
- else:
- self._status = status
- self.quiet = False
-
- if warning is None:
- self._warning = StringIO()
- else:
- self._warning = warning
- self._warncount = 0
- self.warningiserror = warningiserror
-
- self._events = events.copy()
-
- # say hello to the world
- self.info(bold('Running Sphinx v%s' % sphinx.__version__))
-
- # status code for command-line application
- self.statuscode = 0
-
- # read config
- self.tags = Tags(tags)
- self.config = Config(confdir, CONFIG_FILENAME,
- confoverrides or {}, self.tags)
- self.config.check_unicode(self.warn)
-
- # set confdir to srcdir if -C given (!= no confdir); a few pieces
- # of code expect a confdir to be set
- if self.confdir is None:
- self.confdir = self.srcdir
-
- # backwards compatibility: activate old C markup
- self.setup_extension('sphinx.ext.oldcmarkup')
- # load all user-given extension modules
- for extension in self.config.extensions:
- self.setup_extension(extension)
- # the config file itself can be an extension
- if self.config.setup:
- self.config.setup(self)
-
- # now that we know all config values, collect them from conf.py
- self.config.init_values()
-
- # check the Sphinx version if requested
- if self.config.needs_sphinx and \
- self.config.needs_sphinx > sphinx.__version__[:3]:
- raise VersionRequirementError(
- 'This project needs at least Sphinx v%s and therefore cannot '
- 'be built with this version.' % self.config.needs_sphinx)
-
- # set up translation infrastructure
- self._init_i18n()
- # set up the build environment
- self._init_env(freshenv)
- # set up the builder
- self._init_builder(buildername)
-
- def _init_i18n(self):
- """
- Load translated strings from the configured localedirs if
- enabled in the configuration.
- """
- if self.config.language is not None:
- self.info(bold('loading translations [%s]... ' %
- self.config.language), nonl=True)
- locale_dirs = [None, path.join(package_dir, 'locale')] + \
- [path.join(self.srcdir, x) for x in self.config.locale_dirs]
- else:
- locale_dirs = []
- self.translator, has_translation = locale.init(locale_dirs,
- self.config.language)
- if self.config.language is not None:
- if has_translation:
- self.info('done')
- else:
- self.info('locale not available')
-
- def _init_env(self, freshenv):
- if freshenv:
- self.env = BuildEnvironment(self.srcdir, self.doctreedir,
- self.config)
- self.env.find_files(self.config)
- for domain in self.domains.keys():
- self.env.domains[domain] = self.domains[domain](self.env)
- else:
- try:
- self.info(bold('loading pickled environment... '), nonl=True)
- self.env = BuildEnvironment.frompickle(self.config,
- path.join(self.doctreedir, ENV_PICKLE_FILENAME))
- self.env.domains = {}
- for domain in self.domains.keys():
- # this can raise if the data version doesn't fit
- self.env.domains[domain] = self.domains[domain](self.env)
- self.info('done')
- except Exception, err:
- if type(err) is IOError and err.errno == ENOENT:
- self.info('not yet created')
- else:
- self.info('failed: %s' % err)
- return self._init_env(freshenv=True)
-
- self.env.set_warnfunc(self.warn)
-
- def _init_builder(self, buildername):
- if buildername is None:
- print >>self._status, 'No builder selected, using default: html'
- buildername = 'html'
- if buildername not in self.builderclasses:
- raise SphinxError('Builder name %s not registered' % buildername)
-
- builderclass = self.builderclasses[buildername]
- if isinstance(builderclass, tuple):
- # builtin builder
- mod, cls = builderclass
- builderclass = getattr(
- __import__('sphinx.builders.' + mod, None, None, [cls]), cls)
- self.builder = builderclass(self)
- self.emit('builder-inited')
-
- def build(self, force_all=False, filenames=None):
- try:
- if force_all:
- self.builder.build_all()
- elif filenames:
- self.builder.build_specific(filenames)
- else:
- self.builder.build_update()
- except Exception, err:
- self.emit('build-finished', err)
- raise
- else:
- self.emit('build-finished', None)
- self.builder.cleanup()
-
- def warn(self, message, location=None, prefix='WARNING: '):
- if isinstance(location, tuple):
- docname, lineno = location
- if docname:
- location = '%s:%s' % (self.env.doc2path(docname), lineno or '')
- else:
- location = None
- warntext = location and '%s: %s%s\n' % (location, prefix, message) or \
- '%s%s\n' % (prefix, message)
- if self.warningiserror:
- raise SphinxWarning(warntext)
- self._warncount += 1
- try:
- self._warning.write(warntext)
- except UnicodeEncodeError:
- encoding = getattr(self._warning, 'encoding', 'ascii') or 'ascii'
- self._warning.write(warntext.encode(encoding, 'replace'))
-
- def info(self, message='', nonl=False):
- try:
- self._status.write(message)
- except UnicodeEncodeError:
- encoding = getattr(self._status, 'encoding', 'ascii') or 'ascii'
- self._status.write(message.encode(encoding, 'replace'))
- if not nonl:
- self._status.write('\n')
- self._status.flush()
-
- # general extensibility interface
-
- def setup_extension(self, extension):
- """Import and setup a Sphinx extension module. No-op if called twice."""
- if extension in self._extensions:
- return
- try:
- mod = __import__(extension, None, None, ['setup'])
- except ImportError, err:
- raise ExtensionError('Could not import extension %s' % extension,
- err)
- if not hasattr(mod, 'setup'):
- self.warn('extension %r has no setup() function; is it really '
- 'a Sphinx extension module?' % extension)
- else:
- try:
- mod.setup(self)
- except VersionRequirementError, err:
- # add the extension name to the version required
- raise VersionRequirementError(
- 'The %s extension used by this project needs at least '
- 'Sphinx v%s; it therefore cannot be built with this '
- 'version.' % (extension, err))
- self._extensions[extension] = mod
-
- def require_sphinx(self, version):
- # check the Sphinx version if requested
- if version > sphinx.__version__[:3]:
- raise VersionRequirementError(version)
-
- def import_object(self, objname, source=None):
- """Import an object from a 'module.name' string."""
- try:
- module, name = objname.rsplit('.', 1)
- except ValueError, err:
- raise ExtensionError('Invalid full object name %s' % objname +
- (source and ' (needed for %s)' % source or ''),
- err)
- try:
- return getattr(__import__(module, None, None, [name]), name)
- except ImportError, err:
- raise ExtensionError('Could not import %s' % module +
- (source and ' (needed for %s)' % source or ''),
- err)
- except AttributeError, err:
- raise ExtensionError('Could not find %s' % objname +
- (source and ' (needed for %s)' % source or ''),
- err)
-
- # event interface
-
- def _validate_event(self, event):
- event = intern(event)
- if event not in self._events:
- raise ExtensionError('Unknown event name: %s' % event)
-
- def connect(self, event, callback):
- self._validate_event(event)
- listener_id = self.next_listener_id
- if event not in self._listeners:
- self._listeners[event] = {listener_id: callback}
- else:
- self._listeners[event][listener_id] = callback
- self.next_listener_id += 1
- return listener_id
-
- def disconnect(self, listener_id):
- for event in self._listeners.itervalues():
- event.pop(listener_id, None)
-
- def emit(self, event, *args):
- results = []
- if event in self._listeners:
- for _, callback in self._listeners[event].iteritems():
- results.append(callback(self, *args))
- return results
-
- def emit_firstresult(self, event, *args):
- for result in self.emit(event, *args):
- if result is not None:
- return result
- return None
-
- # registering addon parts
-
- def add_builder(self, builder):
- if not hasattr(builder, 'name'):
- raise ExtensionError('Builder class %s has no "name" attribute'
- % builder)
- if builder.name in self.builderclasses:
- if isinstance(self.builderclasses[builder.name], tuple):
- raise ExtensionError('Builder %r is a builtin builder' %
- builder.name)
- else:
- raise ExtensionError(
- 'Builder %r already exists (in module %s)' % (
- builder.name, self.builderclasses[builder.name].__module__))
- self.builderclasses[builder.name] = builder
-
- def add_config_value(self, name, default, rebuild):
- if name in self.config.values:
- raise ExtensionError('Config value %r already present' % name)
- if rebuild in (False, True):
- rebuild = rebuild and 'env' or ''
- self.config.values[name] = (default, rebuild)
-
- def add_event(self, name):
- if name in self._events:
- raise ExtensionError('Event %r already present' % name)
- self._events[name] = ''
-
- def add_node(self, node, **kwds):
- nodes._add_node_class_names([node.__name__])
- for key, val in kwds.iteritems():
- try:
- visit, depart = val
- except ValueError:
- raise ExtensionError('Value for key %r must be a '
- '(visit, depart) function tuple' % key)
- if key == 'html':
- from sphinx.writers.html import HTMLTranslator as translator
- elif key == 'latex':
- from sphinx.writers.latex import LaTeXTranslator as translator
- elif key == 'text':
- from sphinx.writers.text import TextTranslator as translator
- elif key == 'man':
- from sphinx.writers.manpage import ManualPageTranslator \
- as translator
- else:
- # ignore invalid keys for compatibility
- continue
- setattr(translator, 'visit_'+node.__name__, visit)
- if depart:
- setattr(translator, 'depart_'+node.__name__, depart)
-
- def _directive_helper(self, obj, content=None, arguments=None, **options):
- if isinstance(obj, (types.FunctionType, types.MethodType)):
- obj.content = content
- obj.arguments = arguments or (0, 0, False)
- obj.options = options
- return convert_directive_function(obj)
- else:
- if content or arguments or options:
- raise ExtensionError('when adding directive classes, no '
- 'additional arguments may be given')
- return obj
-
- def add_directive(self, name, obj, content=None, arguments=None, **options):
- directives.register_directive(
- name, self._directive_helper(obj, content, arguments, **options))
-
- def add_role(self, name, role):
- roles.register_local_role(name, role)
-
- def add_generic_role(self, name, nodeclass):
- # don't use roles.register_generic_role because it uses
- # register_canonical_role
- role = roles.GenericRole(name, nodeclass)
- roles.register_local_role(name, role)
-
- def add_domain(self, domain):
- if domain.name in self.domains:
- raise ExtensionError('domain %s already registered' % domain.name)
- self.domains[domain.name] = domain
-
- def override_domain(self, domain):
- if domain.name not in self.domains:
- raise ExtensionError('domain %s not yet registered' % domain.name)
- if not issubclass(domain, self.domains[domain.name]):
- raise ExtensionError('new domain not a subclass of registered '
- 'domain' % domain.name)
- self.domains[domain.name] = domain
-
- def add_directive_to_domain(self, domain, name, obj,
- content=None, arguments=None, **options):
- if domain not in self.domains:
- raise ExtensionError('domain %s not yet registered' % domain)
- self.domains[domain].directives[name] = \
- self._directive_helper(obj, content, arguments, **options)
-
- def add_role_to_domain(self, domain, name, role):
- if domain not in self.domains:
- raise ExtensionError('domain %s not yet registered' % domain)
- self.domains[domain].roles[name] = role
-
- def add_index_to_domain(self, domain, name, localname, shortname, func):
- if domain not in self.domains:
- raise ExtensionError('domain %s not yet registered' % domain)
- self.domains[domain].indices.append((name, localname, shortname))
- setattr(self.domains[domain], 'get_%s_index' % name, func)
-
- def add_object_type(self, directivename, rolename, indextemplate='',
- parse_node=None, ref_nodeclass=None, objname='',
- doc_field_types=[]):
- StandardDomain.object_types[directivename] = \
- ObjType(objname or directivename, rolename)
- # create a subclass of GenericObject as the new directive
- new_directive = type(directivename, (GenericObject, object),
- {'indextemplate': indextemplate,
- 'parse_node': staticmethod(parse_node),
- 'doc_field_types': doc_field_types})
- StandardDomain.directives[directivename] = new_directive
- # XXX support more options?
- StandardDomain.roles[rolename] = XRefRole(innernodeclass=ref_nodeclass)
-
- # backwards compatible alias
- add_description_unit = add_object_type
-
- def add_crossref_type(self, directivename, rolename, indextemplate='',
- ref_nodeclass=None, objname=''):
- StandardDomain.object_types[directivename] = \
- ObjType(objname or directivename, rolename)
- # create a subclass of Target as the new directive
- new_directive = type(directivename, (Target, object),
- {'indextemplate': indextemplate})
- StandardDomain.directives[directivename] = new_directive
- # XXX support more options?
- StandardDomain.roles[rolename] = XRefRole(innernodeclass=ref_nodeclass)
-
- def add_transform(self, transform):
- SphinxStandaloneReader.transforms.append(transform)
-
- def add_javascript(self, filename):
- from sphinx.builders.html import StandaloneHTMLBuilder
- if '://' in filename:
- StandaloneHTMLBuilder.script_files.append(filename)
- else:
- StandaloneHTMLBuilder.script_files.append(
- posixpath.join('_static', filename))
-
- def add_stylesheet(self, filename):
- from sphinx.builders.html import StandaloneHTMLBuilder
- StandaloneHTMLBuilder.css_files.append(
- posixpath.join('_static', filename))
-
- def add_lexer(self, alias, lexer):
- from sphinx.highlighting import lexers
- if lexers is None:
- return
- lexers[alias] = lexer
-
- def add_autodocumenter(self, cls):
- from sphinx.ext import autodoc
- autodoc.add_documenter(cls)
- self.add_directive('auto' + cls.objtype, autodoc.AutoDirective)
-
- def add_autodoc_attrgetter(self, type, getter):
- from sphinx.ext import autodoc
- autodoc.AutoDirective._special_attrgetters[type] = getter
-
-
-class TemplateBridge(object):
- """
- This class defines the interface for a "template bridge", that is, a class
- that renders templates given a template name and a context.
- """
-
- def init(self, builder, theme=None, dirs=None):
- """
- Called by the builder to initialize the template system.
-
- *builder* is the builder object; you'll probably want to look at the
- value of ``builder.config.templates_path``.
-
- *theme* is a :class:`sphinx.theming.Theme` object or None; in the latter
- case, *dirs* can be list of fixed directories to look for templates.
- """
- raise NotImplementedError('must be implemented in subclasses')
-
- def newest_template_mtime(self):
- """
- Called by the builder to determine if output files are outdated
- because of template changes. Return the mtime of the newest template
- file that was changed. The default implementation returns ``0``.
- """
- return 0
-
- def render(self, template, context):
- """
- Called by the builder to render a template given as a filename with a
- specified context (a Python dictionary).
- """
- raise NotImplementedError('must be implemented in subclasses')
-
- def render_string(self, template, context):
- """
- Called by the builder to render a template given as a string with a
- specified context (a Python dictionary).
- """
- raise NotImplementedError('must be implemented in subclasses')
diff --git a/lib/cpython-doc/tools/sphinx/.svn/text-base/cmdline.py.svn-base b/lib/cpython-doc/tools/sphinx/.svn/text-base/cmdline.py.svn-base
deleted file mode 100644
--- a/lib/cpython-doc/tools/sphinx/.svn/text-base/cmdline.py.svn-base
+++ /dev/null
@@ -1,228 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- sphinx.cmdline
- ~~~~~~~~~~~~~~
-
- sphinx-build command-line handling.
-
- :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-import os
-import sys
-import getopt
-import traceback
-from os import path
-
-from docutils.utils import SystemMessage
-
-from sphinx import __version__
-from sphinx.errors import SphinxError
-from sphinx.application import Sphinx
-from sphinx.util import Tee, format_exception_cut_frames, save_traceback
-from sphinx.util.console import red, nocolor, color_terminal
-
-
-def usage(argv, msg=None):
- if msg:
- print >>sys.stderr, msg
- print >>sys.stderr
- print >>sys.stderr, """\
-Sphinx v%s
-Usage: %s [options] sourcedir outdir [filenames...]
-Options: -b <builder> -- builder to use; default is html
- -a -- write all files; default is to only write \
-new and changed files
- -E -- don't use a saved environment, always read all files
- -t <tag> -- include "only" blocks with <tag>
- -d <path> -- path for the cached environment and doctree files
- (default: outdir/.doctrees)
- -c <path> -- path where configuration file (conf.py) is located
- (default: same as sourcedir)
- -C -- use no config file at all, only -D options
- -D <setting=value> -- override a setting in configuration
- -A <name=value> -- pass a value into the templates, for HTML builder
- -n -- nit-picky mode, warn about all missing references
- -N -- do not do colored output
- -q -- no output on stdout, just warnings on stderr
- -Q -- no output at all, not even warnings
- -w <file> -- write warnings (and errors) to given file
- -W -- turn warnings into errors
- -P -- run Pdb on exception
-Modi:
-* without -a and without filenames, write new and changed files.
-* with -a, write all files.
-* with filenames, write these.""" % (__version__, argv[0])
-
-
-def main(argv):
- if not color_terminal():
- # Windows' poor cmd box doesn't understand ANSI sequences
- nocolor()
-
- try:
- opts, args = getopt.getopt(argv[1:], 'ab:t:d:c:CD:A:ng:NEqQWw:P')
- allopts = set(opt[0] for opt in opts)
- srcdir = confdir = path.abspath(args[0])
- if not path.isdir(srcdir):
- print >>sys.stderr, 'Error: Cannot find source directory.'
- return 1
- if not path.isfile(path.join(srcdir, 'conf.py')) and \
- '-c' not in allopts and '-C' not in allopts:
- print >>sys.stderr, ('Error: Source directory doesn\'t '
- 'contain conf.py file.')
- return 1
- outdir = path.abspath(args[1])
- if not path.isdir(outdir):
- print >>sys.stderr, 'Making output directory...'
- os.makedirs(outdir)
- except (IndexError, getopt.error):
- usage(argv)
- return 1
-
- filenames = args[2:]
- err = 0
- for filename in filenames:
- if not path.isfile(filename):
- print >>sys.stderr, 'Cannot find file %r.' % filename
- err = 1
- if err:
- return 1
-
- # likely encoding used for command-line arguments
- try:
- locale = __import__('locale') # due to submodule of the same name
- likely_encoding = locale.getpreferredencoding()
- except Exception:
- likely_encoding = None
-
- buildername = None
- force_all = freshenv = warningiserror = use_pdb = False
- status = sys.stdout
- warning = sys.stderr
- error = sys.stderr
- warnfile = None
- confoverrides = {}
- tags = []
- doctreedir = path.join(outdir, '.doctrees')
- for opt, val in opts:
- if opt == '-b':
- buildername = val
- elif opt == '-a':
- if filenames:
- usage(argv, 'Cannot combine -a option and filenames.')
- return 1
- force_all = True
- elif opt == '-t':
- tags.append(val)
- elif opt == '-d':
- doctreedir = path.abspath(val)
- elif opt == '-c':
- confdir = path.abspath(val)
- if not path.isfile(path.join(confdir, 'conf.py')):
- print >>sys.stderr, ('Error: Configuration directory '
- 'doesn\'t contain conf.py file.')
- return 1
- elif opt == '-C':
- confdir = None
- elif opt == '-D':
- try:
- key, val = val.split('=')
- except ValueError:
- print >>sys.stderr, ('Error: -D option argument must be '
- 'in the form name=value.')
- return 1
- try:
- val = int(val)
- except ValueError:
- if likely_encoding:
- try:
- val = val.decode(likely_encoding)
- except UnicodeError:
- pass
- confoverrides[key] = val
- elif opt == '-A':
- try:
- key, val = val.split('=')
- except ValueError:
- print >>sys.stderr, ('Error: -A option argument must be '
- 'in the form name=value.')
- return 1
- try:
- val = int(val)
- except ValueError:
- if likely_encoding:
- try:
- val = val.decode(likely_encoding)
- except UnicodeError:
- pass
- confoverrides['html_context.%s' % key] = val
- elif opt == '-n':
- confoverrides['nitpicky'] = True
- elif opt == '-N':
- nocolor()
- elif opt == '-E':
- freshenv = True
- elif opt == '-q':
- status = None
- elif opt == '-Q':
- status = None
- warning = None
- elif opt == '-W':
- warningiserror = True
- elif opt == '-w':
- warnfile = val
- elif opt == '-P':
- use_pdb = True
-
- if warning and warnfile:
- warnfp = open(warnfile, 'w')
- warning = Tee(warning, warnfp)
- error = warning
-
- try:
- app = Sphinx(srcdir, confdir, outdir, doctreedir, buildername,
- confoverrides, status, warning, freshenv,
- warningiserror, tags)
- app.build(force_all, filenames)
More information about the pypy-commit
mailing list