merge with trunk

This commit is contained in:
Jacob Mason
2010-07-27 16:16:40 -05:00
32 changed files with 1172 additions and 255 deletions

View File

@@ -2,6 +2,7 @@
.*\.egg
.*\.so
.dir-locals.el
^\.tox
\.DS_Store$
^build/
^dist/

28
CHANGES
View File

@@ -1,6 +1,32 @@
Release 1.0 (in development)
Release 1.1 (in development)
============================
Release 1.0.2 (in development)
==============================
Release 1.0.1 (Jul 27, 2010)
============================
* #470: Fix generated target names for reST domain objects; they
are not in the same namespace.
* #266: Add Bengali language.
* #473: Fix a bug in parsing JavaScript object names.
* #474: Fix building with SingleHTMLBuilder when there is no toctree.
* Fix display names for objects linked to by intersphinx with
explicit targets.
* Fix building with the JSON builder.
* Fix hyperrefs in object descriptions for LaTeX.
Release 1.0 (Jul 23, 2010)
==========================
Incompatible changes
--------------------

View File

@@ -12,7 +12,7 @@ interesting examples.
Documentation using the default theme
-------------------------------------
* APSW: http://apsw.googlecode.com/svn/publish/index.html
* APSW: http://apidoc.apsw.googlecode.com/hg/index.html
* ASE: https://wiki.fysik.dtu.dk/ase/
* boostmpi: http://documen.tician.de/boostmpi/
* Calibre: http://calibre.kovidgoyal.net/user_manual/

View File

@@ -9,7 +9,8 @@ all: clean-pyc check test
check:
@$(PYTHON) utils/check_sources.py -i build -i dist -i sphinx/style/jquery.js \
-i sphinx/pycode/pgen2 -i sphinx/util/smartypants.py -i .ropeproject \
-i doc/_build -i ez_setup.py -i tests/path.py -i tests/coverage.py -i env .
-i doc/_build -i ez_setup.py -i tests/path.py -i tests/coverage.py \
-i env -i .tox .
clean: clean-pyc clean-patchfiles

View File

@@ -283,6 +283,7 @@ Project information
Currently supported languages are:
* ``bn`` -- Bengali
* ``ca`` -- Catalan
* ``cs`` -- Czech
* ``da`` -- Danish
@@ -782,6 +783,12 @@ the `Dublin Core metadata <http://dublincore.org/>`_.
be an integer greater than zero. The default value is 3. Note: A deeply
nested table of contents may be difficult to navigate.
.. confval:: epub_tocdup
This flag determines if a toc entry is inserted again at the beginning of
it's nested toc listing. This allows easier navitation to the top of
a chapter, but can be confusing because it mixes entries of differnet
depth in one list. The default value is ``True``.
.. _latex-options:

View File

@@ -178,6 +178,7 @@ setup(
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Topic :: Documentation',
'Topic :: Text Processing',
'Topic :: Utilities',

View File

@@ -12,8 +12,8 @@
import sys
from os import path
__version__ = '1.0b2+'
__released__ = '1.0b2' # used when Sphinx builds its own docs
__version__ = '1.1pre'
__released__ = '1.1 (hg)' # used when Sphinx builds its own docs
package_dir = path.abspath(path.dirname(__file__))

View File

@@ -11,13 +11,14 @@
"""
import os
import re
import codecs
from os import path
import zipfile
from os import path
from docutils import nodes
from docutils.transforms import Transform
from sphinx import addnodes
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.util.osutil import EEXIST
from sphinx.util.smartypants import sphinx_smarty_pants as ssp
@@ -120,29 +121,10 @@ _media_types = {
'.ttf': 'application/x-font-ttf',
}
# The transform to show link targets
class VisibleLinksTransform(Transform):
"""
Add the link target of references to the text, unless it is already
present in the description.
"""
# This transform must run after the references transforms
default_priority = 680
def apply(self):
for ref in self.document.traverse(nodes.reference):
uri = ref.get('refuri', '')
if ( uri.startswith('http:') or uri.startswith('https:') or \
uri.startswith('ftp:') ) and uri not in ref.astext():
uri = _link_target_template % {'uri': uri}
if uri:
idx = ref.parent.index(ref) + 1
link = nodes.inline(uri, uri)
link['classes'].append(_css_link_target_class)
ref.parent.insert(idx, link)
# Regular expression to match colons only in local fragment identifiers.
# If the URI contains a colon before the #,
# it is an external link that should not change.
_refuri_re = re.compile("([^#:]*#)(.*)")
# The epub publisher
@@ -171,10 +153,6 @@ class EpubBuilder(StandaloneHTMLBuilder):
# the output files for epub must be .html only
self.out_suffix = '.html'
self.playorder = 0
# Disable transform until the issue with cached doctrees is solved.
# Building the html file after the epub file shows the
# visible links also in the HTML output.
#self.app.add_transform(VisibleLinksTransform)
def get_theme_config(self):
return self.config.epub_theme, {}
@@ -198,7 +176,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
"""Collect section titles, their depth in the toc and the refuri."""
# XXX: is there a better way than checking the attribute
# toctree-l[1-8] on the parent node?
if isinstance(doctree, nodes.reference) and hasattr(doctree, 'refuri'):
if isinstance(doctree, nodes.reference) and doctree.has_key('refuri'):
refuri = doctree['refuri']
if refuri.startswith('http://') or refuri.startswith('https://') \
or refuri.startswith('irc:') or refuri.startswith('mailto:'):
@@ -243,6 +221,81 @@ class EpubBuilder(StandaloneHTMLBuilder):
'text': ssp(self.esc(text))
})
def fix_fragment(self, match):
"""Return a href attribute with colons replaced by hyphens.
"""
return match.group(1) + match.group(2).replace(':', '-')
def fix_ids(self, tree):
"""Replace colons with hyphens in href and id attributes.
Some readers crash because they interpret the part as a
transport protocol specification.
"""
for node in tree.traverse(nodes.reference):
if 'refuri' in node:
m = _refuri_re.match(node['refuri'])
if m:
node['refuri'] = self.fix_fragment(m)
if 'refid' in node:
node['refid'] = node['refid'].replace(':', '-')
for node in tree.traverse(addnodes.desc_signature):
ids = node.attributes['ids']
newids = []
for id in ids:
newids.append(id.replace(':', '-'))
node.attributes['ids'] = newids
def add_visible_links(self, tree):
"""Append visible link targets after external links.
"""
for node in tree.traverse(nodes.reference):
uri = node.get('refuri', '')
if (uri.startswith('http:') or uri.startswith('https:') or
uri.startswith('ftp:')) and uri not in node.astext():
uri = _link_target_template % {'uri': uri}
if uri:
idx = node.parent.index(node) + 1
link = nodes.inline(uri, uri)
link['classes'].append(_css_link_target_class)
node.parent.insert(idx, link)
def write_doc(self, docname, doctree):
"""Write one document file.
This method is overwritten in order to fix fragment identifiers
and to add visible external links.
"""
self.fix_ids(doctree)
self.add_visible_links(doctree)
return StandaloneHTMLBuilder.write_doc(self, docname, doctree)
def fix_genindex(self, tree):
"""Fix href attributes for genindex pages.
"""
# XXX: modifies tree inline
# Logic modeled from themes/basic/genindex.html
for key, columns in tree:
for entryname, (links, subitems) in columns:
for (i, link) in enumerate(links):
m = _refuri_re.match(link)
if m:
links[i] = self.fix_fragment(m)
for subentryname, subentrylinks in subitems:
for (i, link) in enumerate(subentrylinks):
m = _refuri_re.match(link)
if m:
subentrylinks[i] = self.fix_fragment(m)
def handle_page(self, pagename, addctx, templatename='page.html',
outfilename=None, event_arg=None):
"""Create a rendered page.
This method is overwritten for genindex pages in order to fix
href link attributes.
"""
if pagename.startswith('genindex'):
self.fix_genindex(addctx['genindexentries'])
StandaloneHTMLBuilder.handle_page(self, pagename, addctx, templatename,
outfilename, event_arg)
# Finish by building the epub file
def handle_finish(self):
@@ -388,7 +441,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
navstack.append(navlist)
navlist = []
level += 1
if lastnode:
if lastnode and self.config.epub_tocdup:
# Insert starting point in subtoc with same playOrder
navlist.append(self.new_navpoint(lastnode, level, False))
navlist.append(self.new_navpoint(node, level))

View File

@@ -30,7 +30,7 @@ from docutils.frontend import OptionParser
from docutils.readers.doctree import Reader as DoctreeReader
from sphinx import package_dir, __version__
from sphinx.util import copy_static_entry
from sphinx.util import jsonimpl, copy_static_entry
from sphinx.util.osutil import SEP, os_path, relative_uri, ensuredir, \
movefile, ustrftime, copyfile
from sphinx.util.nodes import inline_all_toctrees
@@ -47,14 +47,6 @@ from sphinx.util.console import bold, darkgreen, brown
from sphinx.writers.html import HTMLWriter, HTMLTranslator, \
SmartyPantsHTMLTranslator
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
json = None
#: the filename for the inventory of objects
INVENTORY_FILENAME = 'objects.inv'
#: the filename for the "last build" file (for serializing builders)
@@ -855,8 +847,14 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
def get_doc_context(self, docname, body, metatags):
# no relation links...
toc = self.env.get_toctree_for(self.config.master_doc, self, False)
self.fix_refuris(toc)
toc = self.render_partial(toc)['fragment']
# if there is no toctree, toc is None
if toc:
self.fix_refuris(toc)
toc = self.render_partial(toc)['fragment']
display_toc = True
else:
toc = ''
display_toc = False
return dict(
parents = [],
prev = None,
@@ -869,7 +867,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
rellinks = [],
sourcename = '',
toc = toc,
display_toc = True,
display_toc = display_toc,
)
def write(self, *ignored):
@@ -1007,15 +1005,15 @@ class JSONHTMLBuilder(SerializingHTMLBuilder):
"""
A builder that dumps the generated HTML into JSON files.
"""
implementation = json
indexer_format = json
implementation = jsonimpl
indexer_format = jsonimpl
name = 'json'
out_suffix = '.fjson'
globalcontext_filename = 'globalcontext.json'
searchindex_filename = 'searchindex.json'
def init(self):
if json is None:
if jsonimpl.json is None:
raise SphinxError(
'The module simplejson (or json in Python >= 2.6) '
'is not available. The JSONHTMLBuilder builder will not work.')

View File

@@ -124,6 +124,7 @@ class Config(object):
epub_post_files = ([], 'env'),
epub_exclude_files = ([], 'env'),
epub_tocdepth = (3, 'env'),
epub_tocdup = (True, 'env'),
# LaTeX options
latex_documents = ([], None),

View File

@@ -102,7 +102,7 @@ class LiteralInclude(Directive):
rel_fn = filename[1:]
else:
docdir = path.dirname(env.doc2path(env.docname, base=None))
rel_fn = path.normpath(path.join(docdir, filename))
rel_fn = path.join(docdir, filename)
try:
fn = path.join(env.srcdir, rel_fn)
except UnicodeDecodeError:

View File

@@ -215,12 +215,7 @@ class VersionChange(Directive):
else:
ret = [node]
env = self.state.document.settings.env
env.versionchanges.setdefault(node['version'], []).append(
(node['type'], env.temp_data['docname'], self.lineno,
# XXX: python domain specific
env.temp_data.get('py:module'),
env.temp_data.get('object'),
node.astext()))
env.note_versionchange(node['type'], node['version'], node, self.lineno)
return ret

View File

@@ -56,7 +56,7 @@ class JSObject(ObjectDescription):
else:
# just a function or constructor
objectname = ''
fullname = ''
fullname = name
signode['object'] = objectname
signode['fullname'] = fullname

View File

@@ -28,9 +28,10 @@ class ReSTMarkup(ObjectDescription):
"""
def add_target_and_index(self, name, sig, signode):
if name not in self.state.document.ids:
signode['names'].append(name)
signode['ids'].append(name)
targetname = name + '-' + self.objtype
if targetname not in self.state.document.ids:
signode['names'].append(targetname)
signode['ids'].append(targetname)
signode['first'] = (not self.names)
self.state.document.note_explicit_target(signode)
@@ -47,7 +48,7 @@ class ReSTMarkup(ObjectDescription):
indextext = self.get_index_text(self.objtype, name)
if indextext:
self.indexnode['entries'].append(('single', indextext,
name, name))
targetname, targetname))
def get_index_text(self, objectname, name):
if self.objtype == 'directive':

View File

@@ -63,7 +63,7 @@ default_settings = {
# This is increased every time an environment attribute is added
# or changed to properly invalidate pickle files.
ENV_VERSION = 36
ENV_VERSION = 37
default_substitutions = set([
@@ -733,6 +733,12 @@ class BuildEnvironment:
def note_dependency(self, filename):
self.dependencies.setdefault(self.docname, set()).add(filename)
def note_versionchange(self, type, version, node, lineno):
self.versionchanges.setdefault(version, []).append(
(type, self.temp_data['docname'], lineno,
self.temp_data.get('py:module'),
self.temp_data.get('object'), node.astext()))
# post-processing of read doctrees
def filter_messages(self, doctree):

View File

@@ -191,10 +191,12 @@ def missing_reference(app, env, node, contnode):
return
objtypes = ['%s:%s' % (domain, objtype) for objtype in objtypes]
to_try = [(env.intersphinx_inventory, target)]
in_set = None
if ':' in target:
# first part may be the foreign doc set name
setname, newtarget = target.split(':', 1)
if setname in env.intersphinx_named_inventory:
in_set = setname
to_try.append((env.intersphinx_named_inventory[setname], newtarget))
for inventory, target in to_try:
for objtype in objtypes:
@@ -204,10 +206,13 @@ def missing_reference(app, env, node, contnode):
newnode = nodes.reference('', '', internal=False, refuri=uri,
reftitle='(in %s v%s)' % (proj, version))
if dispname == '-':
newnode.append(contnode)
else:
newnode.append(contnode.__class__(dispname, dispname))
dispname = target
newnode.append(contnode.__class__(dispname, dispname))
return newnode
# at least get rid of the ':' in the target if no explicit title given
if in_set is not None and not node.get('refexplicit', True):
if len(contnode) and isinstance(contnode[0], nodes.Text):
contnode[0] = nodes.Text(newtarget, contnode[0].rawsource)
def setup(app):

View File

@@ -61,3 +61,4 @@ def setup(app):
app.add_role('cfunc', old_crole)
app.add_role('cmacro', old_crole)
app.add_role('ctype', old_crole)
app.add_role('cmember', old_crole)

View File

@@ -0,0 +1 @@
Documentation.addTranslations({"locale": "bn", "plural_expr": "(n != 1)", "messages": {"Search Results": "\u0985\u09a8\u09c1\u09b8\u09a8\u09cd\u09a7\u09be\u09a8\u09c7\u09b0 \u09ab\u09b2\u09be\u09ab\u09b2", "Preparing search...": "\u0985\u09a8\u09c1\u09b8\u09a8\u09cd\u09a7\u09be\u09a8\u09c7\u09b0 \u09aa\u09cd\u09b0\u09b8\u09cd\u09a4\u09c1\u09a4\u09bf \u099a\u09b2\u099b\u09c7...", "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories.": "\u0986\u09aa\u09a8\u09be\u09b0 \u0985\u09a8\u09c1\u09b8\u09a8\u09cd\u09a7\u09be\u09a8\u09c7 \u0995\u09c7\u09be\u09a8 \u09ab\u09b2\u09be\u09ab\u09b2 \u09aa\u09be\u0993\u09df\u09be \u09af\u09be\u09df\u09a8\u09bf\u0964 \u0986\u09aa\u09a8\u09be\u09b0 \u0985\u09a8\u09c1\u09b8\u09a8\u09cd\u09a7\u09be\u09a8\u09c7\u09b0 \u09b6\u09ac\u09cd\u09a6\u0997\u09c1\u09b2\u09c7\u09be\u09b0 \u09b8\u09a0\u09bf\u0995 \u09ac\u09be\u09a8\u09be\u09a8 \u0993 \u09ac\u09bf\u09ad\u09be\u0997 \u09a8\u09bf\u09b0\u09cd\u09ac\u09be\u099a\u09a8 \u09a8\u09bf\u09b6\u09cd\u099a\u09bf\u09a4 \u0995\u09b0\u09c1\u09a8\u0964", "Search finished, found %s page(s) matching the search query.": "\u0985\u09a8\u09c1\u09b8\u09a8\u09cd\u09a7\u09be\u09a8 \u09b6\u09c7\u09b7 \u09b9\u09df\u09c7\u099b\u09c7, \u09ab\u09b2\u09be\u09ab\u09b2\u09c7 %s-\u099f\u09bf \u09aa\u09be\u09a4\u09be \u09aa\u09be\u0993\u09df\u09be \u0997\u09c7\u099b\u09c7\u0964", ", in ": ", -", "Permalink to this headline": "\u098f\u0987 \u09b6\u09bf\u09b0\u09c7\u09be\u09a8\u09be\u09ae\u09c7\u09b0 \u09aa\u09be\u09b0\u09cd\u09ae\u09be\u09b2\u09bf\u0999\u09cd\u0995", "Searching": "\u0985\u09a8\u09c1\u09b8\u09a8\u09cd\u09a7\u09be\u09a8 \u099a\u09b2\u099b\u09c7", "Permalink to this definition": "\u098f\u0987 \u09b8\u0982\u099c\u09cd\u099e\u09be\u09b0 \u09aa\u09be\u09b0\u09cd\u09ae\u09be\u09b2\u09bf\u0999\u09cd\u0995", "Hide Search Matches": "\u0985\u09a8\u09c1\u09b8\u09a8\u09cd\u09a7\u09be\u09a8\u09c7\u09b0 \u09ae\u09cd\u09af\u09be\u099a\u0997\u09c1\u09b2\u09c7\u09be \u09b2\u09c1\u0995\u09be\u09a8"}});

Binary file not shown.

View File

@@ -0,0 +1,698 @@
# Translations template for Sphinx.
# Copyright (C) 2009 ORGANIZATION
# This file is distributed under the same license as the Sphinx project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: Sphinx 1.0pre/[?1034h2e1ab15e035e\n"
"Report-Msgid-Bugs-To: nasim.haque@gmail.com\n"
"POT-Creation-Date: 2009-11-08 16:28+0100\n"
"PO-Revision-Date: 2009-11-10 13:42+0100\n"
"Last-Translator: Nasimul Haque <nasim.haque@gmail.com>\n"
"Language-Team: Nasimul Haque <nasim.haque@gmail.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.4\n"
#: sphinx/environment.py:130
#: sphinx/writers/latex.py:184
#, python-format
msgid "%B %d, %Y"
msgstr "%B %d, %Y"
#: sphinx/environment.py:348
#: sphinx/themes/basic/genindex-single.html:2
#: sphinx/themes/basic/genindex-split.html:2
#: sphinx/themes/basic/genindex-split.html:5
#: sphinx/themes/basic/genindex.html:2
#: sphinx/themes/basic/genindex.html:5
#: sphinx/themes/basic/genindex.html:48
#: sphinx/themes/basic/layout.html:134
#: sphinx/writers/latex.py:190
msgid "Index"
msgstr "ইনডেক্স"
#: sphinx/environment.py:349
#: sphinx/writers/latex.py:189
msgid "Module Index"
msgstr "মডিউল ইনডেক্স"
#: sphinx/environment.py:350
#: sphinx/themes/basic/defindex.html:16
msgid "Search Page"
msgstr "অনুসন্ধান পাতা"
#: sphinx/roles.py:167
#, python-format
msgid "Python Enhancement Proposals!PEP %s"
msgstr "পাইথন উন্নয়ন পরামর্শ!PEP %s"
#: sphinx/builders/changes.py:70
msgid "Builtins"
msgstr "বিল্টইন সমূহ"
#: sphinx/builders/changes.py:72
msgid "Module level"
msgstr "মডিউল লেভেল"
#: sphinx/builders/html.py:224
#, python-format
msgid "%b %d, %Y"
msgstr "%b %d, %Y"
#: sphinx/builders/html.py:243
#: sphinx/themes/basic/defindex.html:21
msgid "General Index"
msgstr "সাধারণ ইনডেক্স"
#: sphinx/builders/html.py:243
msgid "index"
msgstr "ইনডেক্স"
#: sphinx/builders/html.py:247
#: sphinx/builders/htmlhelp.py:220
#: sphinx/builders/qthelp.py:133
#: sphinx/themes/basic/defindex.html:19
#: sphinx/themes/basic/modindex.html:2
#: sphinx/themes/basic/modindex.html:13
#: sphinx/themes/scrolls/modindex.html:2
#: sphinx/themes/scrolls/modindex.html:13
msgid "Global Module Index"
msgstr "গ্লোবাল মডিউল ইনডেক্স"
#: sphinx/builders/html.py:248
msgid "modules"
msgstr "মডিউল সমূহ"
#: sphinx/builders/html.py:304
msgid "next"
msgstr "পরবর্তী"
#: sphinx/builders/html.py:313
msgid "previous"
msgstr "পূর্ববর্তী"
#: sphinx/builders/latex.py:162
msgid " (in "
msgstr "(-"
#: sphinx/directives/__init__.py:78
#: sphinx/directives/__init__.py:79
#: sphinx/directives/__init__.py:80
#: sphinx/directives/__init__.py:81
msgid "Raises"
msgstr "রেইজেস"
#: sphinx/directives/__init__.py:82
#: sphinx/directives/__init__.py:83
#: sphinx/directives/__init__.py:84
msgid "Variable"
msgstr "ভ্যারিয়েবল"
#: sphinx/directives/__init__.py:85
#: sphinx/directives/__init__.py:86
#: sphinx/directives/__init__.py:92
#: sphinx/directives/__init__.py:93
msgid "Returns"
msgstr "রিটার্নস"
#: sphinx/directives/__init__.py:94
msgid "Return type"
msgstr "রিটার্ন টাইপ"
#: sphinx/directives/__init__.py:169
msgid "Parameter"
msgstr "প্যারামিটার"
#: sphinx/directives/__init__.py:173
msgid "Parameters"
msgstr "প্যারামিটার"
#: sphinx/directives/other.py:127
msgid "Section author: "
msgstr "অনুচ্ছেদ লেখক:"
#: sphinx/directives/other.py:129
msgid "Module author: "
msgstr "মডিউল লেখক:"
#: sphinx/directives/other.py:131
msgid "Author: "
msgstr "লেখক:"
#: sphinx/directives/other.py:233
msgid "See also"
msgstr "আরও দেখুন"
#: sphinx/domains/c.py:124
#, python-format
msgid "%s (C function)"
msgstr "%s (C ফাংশন)"
#: sphinx/domains/c.py:126
#, python-format
msgid "%s (C member)"
msgstr "%s (C মেম্বার)"
#: sphinx/domains/c.py:128
#, python-format
msgid "%s (C macro)"
msgstr "%s (C ম্যাক্রো)"
#: sphinx/domains/c.py:130
#, python-format
msgid "%s (C type)"
msgstr "%s (C টাইপ)"
#: sphinx/domains/c.py:132
#, python-format
msgid "%s (C variable)"
msgstr "%s (C ভ্যারিয়েবল)"
#: sphinx/domains/c.py:162
msgid "C function"
msgstr "C ফাংশন"
#: sphinx/domains/c.py:163
msgid "C member"
msgstr "C মেম্বার"
#: sphinx/domains/c.py:164
msgid "C macro"
msgstr "C ম্যাক্রো"
#: sphinx/domains/c.py:165
msgid "C type"
msgstr "C টাইপ"
#: sphinx/domains/c.py:166
msgid "C variable"
msgstr "C ভ্যারিয়েবল"
#: sphinx/domains/python.py:186
#, python-format
msgid "%s() (built-in function)"
msgstr "%s() (বিল্ট-ইন ফাংশন)"
#: sphinx/domains/python.py:187
#: sphinx/domains/python.py:244
#: sphinx/domains/python.py:256
#: sphinx/domains/python.py:269
#, python-format
msgid "%s() (in module %s)"
msgstr "%s() (%s মডিউলে)"
#: sphinx/domains/python.py:190
#, python-format
msgid "%s (built-in variable)"
msgstr "%s (বিল্ট-ইন ভ্যারিয়েবল)"
#: sphinx/domains/python.py:191
#: sphinx/domains/python.py:282
#, python-format
msgid "%s (in module %s)"
msgstr "%s (%s মডিউলে)"
#: sphinx/domains/python.py:207
#, python-format
msgid "%s (built-in class)"
msgstr "%s (বিল্ট-ইন ক্লাস)"
#: sphinx/domains/python.py:208
#, python-format
msgid "%s (class in %s)"
msgstr "%s (%s ক্লাসে)"
#: sphinx/domains/python.py:248
#, python-format
msgid "%s() (%s.%s method)"
msgstr "%s (%s.%s মেথড)"
#: sphinx/domains/python.py:250
#, python-format
msgid "%s() (%s method)"
msgstr "%s() (%s মেথড)"
#: sphinx/domains/python.py:260
#, python-format
msgid "%s() (%s.%s static method)"
msgstr "%s (%s.%s স্ট্যাটিক মেথড)"
#: sphinx/domains/python.py:263
#, python-format
msgid "%s() (%s static method)"
msgstr "%s() (%s স্ট্যাটিক মেথড)"
#: sphinx/domains/python.py:273
#, python-format
msgid "%s() (%s.%s class method)"
msgstr "%s() (%s.%s ক্লাস মেথড)"
#: sphinx/domains/python.py:276
#, python-format
msgid "%s() (%s class method)"
msgstr "%s() (%s ক্লাস মেথড)"
#: sphinx/domains/python.py:286
#, python-format
msgid "%s (%s.%s attribute)"
msgstr "%s (%s.%s এ্যট্রিবিউট)"
#: sphinx/domains/python.py:288
#, python-format
msgid "%s (%s attribute)"
msgstr "%s (%s এ্যট্রিবিউট)"
#: sphinx/domains/python.py:334
msgid "Platforms: "
msgstr "প্লাটফরম:"
#: sphinx/domains/python.py:340
#, python-format
msgid "%s (module)"
msgstr "%s (মডিউল)"
#: sphinx/domains/python.py:396
msgid "function"
msgstr "ফাংশন"
#: sphinx/domains/python.py:397
msgid "data"
msgstr "ডাটা"
#: sphinx/domains/python.py:398
msgid "class"
msgstr "ক্লাস"
#: sphinx/domains/python.py:399
#: sphinx/locale/__init__.py:161
msgid "exception"
msgstr "এক্সেপশন"
#: sphinx/domains/python.py:400
msgid "method"
msgstr "মেথড"
#: sphinx/domains/python.py:401
msgid "attribute"
msgstr "এ্যট্রিবিউট"
#: sphinx/domains/python.py:402
#: sphinx/locale/__init__.py:157
msgid "module"
msgstr "মডিউল"
#: sphinx/domains/std.py:67
#: sphinx/domains/std.py:83
#, python-format
msgid "environment variable; %s"
msgstr "এনভায়রনমেন্ট ভ্যারিয়েবল; %s"
#: sphinx/domains/std.py:156
#, python-format
msgid "%scommand line option; %s"
msgstr "%sকমান্ড লাইন অপশন; %s"
#: sphinx/domains/std.py:324
msgid "glossary term"
msgstr "শব্দকোষ"
#: sphinx/domains/std.py:325
msgid "grammar token"
msgstr "ব্যকরণ টোকেন"
#: sphinx/domains/std.py:326
msgid "environment variable"
msgstr "এনভায়রনমেন্ট ভ্যারিয়েবল"
#: sphinx/domains/std.py:327
msgid "program option"
msgstr "প্রোগ্রাম অপশন"
#: sphinx/ext/autodoc.py:892
#, python-format
msgid " Bases: %s"
msgstr "বেস: %s"
#: sphinx/ext/autodoc.py:925
#, python-format
msgid "alias of :class:`%s`"
msgstr ":class:`%s` এর উপনাম"
#: sphinx/ext/todo.py:40
msgid "Todo"
msgstr "অসমাপ্ত কাজ"
#: sphinx/ext/todo.py:98
#, python-format
msgid "(The original entry is located in %s, line %d and can be found "
msgstr "(%s, %d লাইনে মূল অন্তর্ভুক্তিটি রয়েছে, যা পাওয়া যাবে"
#: sphinx/ext/todo.py:104
msgid "here"
msgstr "এখানে"
#: sphinx/locale/__init__.py:138
msgid "Attention"
msgstr "দৃষ্টি আকর্ষণ"
#: sphinx/locale/__init__.py:139
msgid "Caution"
msgstr "সতর্কীকরণ"
#: sphinx/locale/__init__.py:140
msgid "Danger"
msgstr "বিপজ্জনক"
#: sphinx/locale/__init__.py:141
msgid "Error"
msgstr "ভুল (এরর)"
#: sphinx/locale/__init__.py:142
msgid "Hint"
msgstr "আভাস"
#: sphinx/locale/__init__.py:143
msgid "Important"
msgstr "গুরুত্বপূর্ণ"
#: sphinx/locale/__init__.py:144
msgid "Note"
msgstr "নোট"
#: sphinx/locale/__init__.py:145
msgid "See Also"
msgstr "আরও দেখুন"
#: sphinx/locale/__init__.py:146
msgid "Tip"
msgstr "পরামর্শ"
#: sphinx/locale/__init__.py:147
msgid "Warning"
msgstr "সতর্কতা"
#: sphinx/locale/__init__.py:151
#, python-format
msgid "New in version %s"
msgstr "%s ভার্সনে নতুন"
#: sphinx/locale/__init__.py:152
#, python-format
msgid "Changed in version %s"
msgstr "%s ভার্সনে পরিবর্তিত"
#: sphinx/locale/__init__.py:153
#, python-format
msgid "Deprecated since version %s"
msgstr "%s ভার্সন থেকে ডেপ্রিকেটেড"
#: sphinx/locale/__init__.py:158
msgid "keyword"
msgstr "কিওয়ার্ড"
#: sphinx/locale/__init__.py:159
msgid "operator"
msgstr "অপারেটর"
#: sphinx/locale/__init__.py:160
msgid "object"
msgstr "অবজেক্ট"
#: sphinx/locale/__init__.py:162
msgid "statement"
msgstr "স্ট্যাটমেন্ট"
#: sphinx/locale/__init__.py:163
msgid "built-in function"
msgstr "বিল্ট-ইন ফাংশন"
#: sphinx/themes/basic/defindex.html:2
msgid "Overview"
msgstr "ভুমিকা"
#: sphinx/themes/basic/defindex.html:11
msgid "Indices and tables:"
msgstr "ইনডেক্স ও টেবিল সমূহ:"
#: sphinx/themes/basic/defindex.html:14
msgid "Complete Table of Contents"
msgstr "পূর্ণাঙ্গ সূচীপত্র"
#: sphinx/themes/basic/defindex.html:15
msgid "lists all sections and subsections"
msgstr "সকল অনুচ্ছেদ সমূহের তালিকা"
#: sphinx/themes/basic/defindex.html:17
msgid "search this documentation"
msgstr "এই সহায়িকাতে অনুসন্ধা করুন"
#: sphinx/themes/basic/defindex.html:20
msgid "quick access to all modules"
msgstr "সকল মডিউলে দ্রুত প্রবেশ"
#: sphinx/themes/basic/defindex.html:22
msgid "all functions, classes, terms"
msgstr "সকল ফাংশন, ক্লাস, টার্ম"
#: sphinx/themes/basic/genindex-single.html:5
#, python-format
msgid "Index &ndash; %(key)s"
msgstr "ইনডেক্স &ndash; %(key)s"
#: sphinx/themes/basic/genindex-single.html:44
#: sphinx/themes/basic/genindex-split.html:14
#: sphinx/themes/basic/genindex-split.html:27
#: sphinx/themes/basic/genindex.html:54
msgid "Full index on one page"
msgstr "এক পাতায় সম্পূর্ণ ইনডেক্স"
#: sphinx/themes/basic/genindex-split.html:7
msgid "Index pages by letter"
msgstr "বর্ণানুসারে ইনডেক্স পাতা"
#: sphinx/themes/basic/genindex-split.html:15
msgid "can be huge"
msgstr "খুব বড় হতে পারে"
#: sphinx/themes/basic/layout.html:10
msgid "Navigation"
msgstr "নেভিগেশন"
#: sphinx/themes/basic/layout.html:42
msgid "Table Of Contents"
msgstr "সূচীপত্র"
#: sphinx/themes/basic/layout.html:48
msgid "Previous topic"
msgstr "পূর্ববর্তী টপিক"
#: sphinx/themes/basic/layout.html:50
msgid "previous chapter"
msgstr "পূর্ববর্তী অধ্যায়"
#: sphinx/themes/basic/layout.html:53
msgid "Next topic"
msgstr "পরবর্তী টপিক"
#: sphinx/themes/basic/layout.html:55
msgid "next chapter"
msgstr "পরবর্তী অধ্যায়"
#: sphinx/themes/basic/layout.html:60
msgid "This Page"
msgstr "এই পাতা"
#: sphinx/themes/basic/layout.html:63
msgid "Show Source"
msgstr "সোর্স দেখুন"
#: sphinx/themes/basic/layout.html:73
msgid "Quick search"
msgstr "দ্রুত অনুসন্ধান"
#: sphinx/themes/basic/layout.html:76
msgid "Go"
msgstr "যান"
#: sphinx/themes/basic/layout.html:81
msgid "Enter search terms or a module, class or function name."
msgstr "অনুসন্ধানের জন্য টার্ম, মডিউল, ক্লাস অথবা ফাংশনের নাম দিন।"
#: sphinx/themes/basic/layout.html:122
#, python-format
msgid "Search within %(docstitle)s"
msgstr "%(docstitle)s এর মধ্যে খুঁজুন"
#: sphinx/themes/basic/layout.html:131
msgid "About these documents"
msgstr "এই ডকুমেন্ট সম্পর্কে"
#: sphinx/themes/basic/layout.html:137
#: sphinx/themes/basic/search.html:2
#: sphinx/themes/basic/search.html:5
msgid "Search"
msgstr "অনুসন্ধান"
#: sphinx/themes/basic/layout.html:140
msgid "Copyright"
msgstr "কপিরাইট"
#: sphinx/themes/basic/layout.html:187
#: sphinx/themes/scrolls/layout.html:83
#, python-format
msgid "&copy; <a href=\"%(path)s\">Copyright</a> %(copyright)s."
msgstr "&copy; <a href=\"%(path)s\">কপিরাইট</a> %(copyright)s."
#: sphinx/themes/basic/layout.html:189
#: sphinx/themes/scrolls/layout.html:85
#, python-format
msgid "&copy; Copyright %(copyright)s."
msgstr "&copy; কপিরাইট %(copyright)s."
#: sphinx/themes/basic/layout.html:193
#: sphinx/themes/scrolls/layout.html:89
#, python-format
msgid "Last updated on %(last_updated)s."
msgstr "%(last_updated)s সর্বশেষ পরিবর্তন করা হয়েছে।"
#: sphinx/themes/basic/layout.html:196
#: sphinx/themes/scrolls/layout.html:92
#, python-format
msgid "Created using <a href=\"http://sphinx.pocoo.org/\">Sphinx</a> %(sphinx_version)s."
msgstr "<a href=\"http://sphinx.pocoo.org/\">Sphinx</a> %(sphinx_version)s দিয়ে তৈরী।"
#: sphinx/themes/basic/modindex.html:36
#: sphinx/themes/scrolls/modindex.html:37
msgid "Deprecated"
msgstr "ডেপ্রিকেটেড"
#: sphinx/themes/basic/opensearch.xml:4
#, python-format
msgid "Search %(docstitle)s"
msgstr "%(docstitle)s-এ খুঁজুন"
#: sphinx/themes/basic/search.html:9
msgid ""
"Please activate JavaScript to enable the search\n"
" functionality."
msgstr ""
"অনুসন্ধান করার জন্য অনুগ্রহপূর্বক জাভাস্ক্রিপ্ট \n"
" সক্রিয় করুন।"
#: sphinx/themes/basic/search.html:14
msgid ""
"From here you can search these documents. Enter your search\n"
" words into the box below and click \"search\". Note that the search\n"
" function will automatically search for all of the words. Pages\n"
" containing fewer words won't appear in the result list."
msgstr ""
"এখান থেকে এই নথিগুলোতে আপনি অনুসন্ধান করতে পারবেন। \n"
" আপনার কাঙ্ক্ষিত শব্দসমূহ নিচের বাক্সে লিখুন এবং \"অনুসন্ধান\" বাটনে ক্লিক করুন।\n"
" উল্লেখ্য, সকল শব্দসমূহের উপস্থিতি নিয়ে অনুসন্ধান করা হবে। যেসব পাতায় সকল\n"
" শব্দ নেই সেগুলো বাদ দেয়া হবে।"
#: sphinx/themes/basic/search.html:21
msgid "search"
msgstr "খুঁজুন"
#: sphinx/themes/basic/search.html:25
#: sphinx/themes/basic/static/searchtools.js:473
msgid "Search Results"
msgstr "অনুসন্ধানের ফলাফল"
#: sphinx/themes/basic/search.html:27
msgid "Your search did not match any results."
msgstr "আপনার অনুসন্ধানে কোন ফলাফল পাওয়া যায়নি।"
#: sphinx/themes/basic/changes/frameset.html:5
#: sphinx/themes/basic/changes/versionchanges.html:12
#, python-format
msgid "Changes in Version %(version)s &mdash; %(docstitle)s"
msgstr "%(version)s &mdash; %(docstitle)s-এ পরিবর্তন সমূহ"
#: sphinx/themes/basic/changes/rstsource.html:5
#, python-format
msgid "%(filename)s &mdash; %(docstitle)s"
msgstr "%(filename)s &mdash; %(docstitle)s"
#: sphinx/themes/basic/changes/versionchanges.html:17
#, python-format
msgid "Automatically generated list of changes in version %(version)s"
msgstr "স্বয়ংক্রিয়ভাবে তৈরী %(version)s-এ পরিবর্তন সমূহের তালিকা।"
#: sphinx/themes/basic/changes/versionchanges.html:18
msgid "Library changes"
msgstr "লাইব্রেরির পরিবর্তন"
#: sphinx/themes/basic/changes/versionchanges.html:23
msgid "C API changes"
msgstr "C API পরিবর্তন"
#: sphinx/themes/basic/changes/versionchanges.html:25
msgid "Other changes"
msgstr "অন্যান্য পরিবর্তন"
#: sphinx/themes/basic/static/doctools.js:138
#: sphinx/writers/html.py:462
#: sphinx/writers/html.py:467
msgid "Permalink to this headline"
msgstr "এই শিরোনামের পার্মালিঙ্ক"
#: sphinx/themes/basic/static/doctools.js:144
#: sphinx/writers/html.py:80
msgid "Permalink to this definition"
msgstr "এই সংজ্ঞার পার্মালিঙ্ক"
#: sphinx/themes/basic/static/doctools.js:173
msgid "Hide Search Matches"
msgstr "অনুসন্ধানের ম্যাচগুলো লুকান"
#: sphinx/themes/basic/static/searchtools.js:274
msgid "Searching"
msgstr "অনুসন্ধান চলছে"
#: sphinx/themes/basic/static/searchtools.js:279
msgid "Preparing search..."
msgstr "অনুসন্ধানের প্রস্তুতি চলছে..."
#: sphinx/themes/basic/static/searchtools.js:352
msgid ", in "
msgstr ", -"
#: sphinx/themes/basic/static/searchtools.js:475
msgid "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories."
msgstr "আপনার অনুসন্ধানে কোন ফলাফল পাওয়া যায়নি। আপনার অনুসন্ধানের শব্দগুলোর সঠিক বানান ও বিভাগ নির্বাচন নিশ্চিত করুন।"
#: sphinx/themes/basic/static/searchtools.js:477
#, python-format
msgid "Search finished, found %s page(s) matching the search query."
msgstr "অনুসন্ধান শেষ হয়েছে, ফলাফলে %s-টি পাতা পাওয়া গেছে।"
#: sphinx/writers/latex.py:187
msgid "Release"
msgstr "রিলিজ"
#: sphinx/writers/latex.py:579
msgid "Footnotes"
msgstr "পাদটীকা"
#: sphinx/writers/latex.py:647
msgid "continued from previous page"
msgstr "পূর্ববর্তী পাতা হতে চলমান"
#: sphinx/writers/latex.py:652
msgid "Continued on next page"
msgstr "পরবর্তী পাতাতে চলমান"
#: sphinx/writers/text.py:166
#, python-format
msgid "Platform: %s"
msgstr "প্লাটফরম: %s"
#: sphinx/writers/text.py:428
msgid "[image]"
msgstr "[ছবি]"

View File

@@ -279,6 +279,9 @@ epub_copyright = u'%(copyright_str)s'
# The depth of the table of contents in toc.ncx.
#epub_tocdepth = 3
# Allow duplicate toc entries.
#epub_tocdup = True
'''
INTERSPHINX_CONFIG = '''

View File

@@ -205,8 +205,9 @@ def indexmarkup_role(typ, rawtext, etext, lineno, inliner,
_amp_re = re.compile(r'(?<!&)&(?![&\s])')
def menusel_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
if typ == 'menuselection':
text = utils.unescape(text).replace('-->', u'\N{TRIANGULAR BULLET}')
text = text.replace('-->', u'\N{TRIANGULAR BULLET}')
spans = _amp_re.split(text)
node = nodes.emphasis(rawtext=rawtext)

View File

@@ -141,9 +141,13 @@ class TypedField(GroupedField):
par = nodes.paragraph()
par += self.make_xref(self.rolename, domain, fieldarg, nodes.strong)
if fieldarg in types:
typename = u''.join(n.astext() for n in types[fieldarg])
par += nodes.Text(' (')
par += self.make_xref(self.typerolename, domain, typename)
fieldtype = types[fieldarg]
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in types[fieldarg])
par += self.make_xref(self.typerolename, domain, typename)
else:
par += fieldtype
par += nodes.Text(')')
par += nodes.Text(' -- ')
par += content
@@ -222,7 +226,10 @@ class DocFieldTransformer(object):
if is_typefield:
# filter out only inline nodes; others will result in invalid
# markup being written out
content = filter(lambda n: isinstance(n, nodes.Inline), content)
content = filter(
lambda n: isinstance(n, nodes.Inline) or
isinstance(n, nodes.Text),
content)
if content:
types.setdefault(typename, {})[fieldarg] = content
continue

43
sphinx/util/jsonimpl.py Normal file
View File

@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
"""
sphinx.util.jsonimpl
~~~~~~~~~~~~~~~~~~~~
JSON serializer implementation wrapper.
:copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import UserString
try:
import json
JSONEncoder = json.JSONEncoder
except ImportError:
try:
import simplejson as json
JSONEncoder = json.JSONEncoder
except ImportError:
json = None
JSONEncoder = object
class SphinxJSONEncoder(JSONEncoder):
"""JSONEncoder subclass that forces translation proxies."""
def default(self, obj):
if isinstance(obj, UserString.UserString):
return unicode(obj)
return JSONEncoder.default(self, obj)
def dump(obj, fp, *args, **kwds):
kwds['cls'] = SphinxJSONEncoder
return json.dump(obj, fp, *args, **kwds)
def dumps(obj, *args, **kwds):
kwds['cls'] = SphinxJSONEncoder
return json.dumps(obj, *args, **kwds)
load = json.load
loads = json.loads

View File

@@ -250,7 +250,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
'\\label{%s}' % self.idescape(id)
def hyperlink(self, id):
return '\\hyperref[%s]{' % (self.idescape(id))
return '{\\hyperref[%s]{' % (self.idescape(id))
def hyperpageref(self, id):
return '\\autopageref*{%s}' % (self.idescape(id))
@@ -1051,9 +1051,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
id = self.curfilestack[-1] + ':' + uri[1:]
self.body.append(self.hyperlink(id))
if self.builder.config.latex_show_pagerefs:
self.context.append('} (%s)' % self.hyperpageref(id))
self.context.append('}} (%s)' % self.hyperpageref(id))
else:
self.context.append('}')
self.context.append('}}')
elif uri.startswith('%'):
# references to documents or labels inside documents
hashindex = uri.find('#')
@@ -1067,12 +1067,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
if len(node) and hasattr(node[0], 'attributes') and \
'std-term' in node[0].get('classes', []):
# don't add a pageref for glossary terms
self.context.append('}')
self.context.append('}}')
else:
if self.builder.config.latex_show_pagerefs:
self.context.append('} (%s)' % self.hyperpageref(id))
self.context.append('}} (%s)' % self.hyperpageref(id))
else:
self.context.append('}')
self.context.append('}}')
elif uri.startswith('@token'):
if self.in_production_list:
self.body.append('\\token{')

View File

@@ -97,21 +97,23 @@ Inline markup
*Generic inline markup*
* :command:`command`
* :dfn:`dfn`
* :guilabel:`guilabel with &accelerator`
* :kbd:`kbd`
* :mailheader:`mailheader`
* :makevar:`makevar`
* :manpage:`manpage`
* :mimetype:`mimetype`
* :newsgroup:`newsgroup`
* :program:`program`
* :regexp:`regexp`
* :menuselection:`File --> Close`
Adding \n to test unescaping.
* :command:`command\\n`
* :dfn:`dfn\\n`
* :guilabel:`guilabel with &accelerator and \\n`
* :kbd:`kbd\\n`
* :mailheader:`mailheader\\n`
* :makevar:`makevar\\n`
* :manpage:`manpage\\n`
* :mimetype:`mimetype\\n`
* :newsgroup:`newsgroup\\n`
* :program:`program\\n`
* :regexp:`regexp\\n`
* :menuselection:`File --> Close\\n`
* :menuselection:`&File --> &Print`
* :file:`a/{varpart}/b`
* :samp:`print {i}`
* :file:`a/{varpart}/b\\n`
* :samp:`print {i}\\n`
*Linking inline markup*

View File

@@ -43,6 +43,11 @@ Testing object descriptions
.. class:: TimeInt
:param moo: |test|
:type moo: |test|
.. |test| replace:: Moo
.. class:: Time(hour, minute, isdst)
:param hour: The year.

View File

@@ -21,6 +21,10 @@ def teardown_module():
def test_pickle(app):
app.builder.build_all()
@with_app(buildername='json')
def test_json(app):
app.builder.build_all()
@with_app(buildername='linkcheck')
def test_linkcheck(app):
app.builder.build_all()

View File

@@ -11,7 +11,6 @@
import os
import re
import difflib
import htmlentitydefs
from StringIO import StringIO
@@ -37,9 +36,9 @@ ENV_WARNINGS = """\
http://www.python.org/logo.png
%(root)s/includes.txt:\\d*: \\(WARNING/2\\) Encoding 'utf-8-sig' used for \
reading included file u'wrongenc.inc' seems to be wrong, try giving an \
:encoding: option
:encoding: option\\n?
%(root)s/includes.txt:4: WARNING: download file not readable: nonexisting.png
%(root)s/objects.txt:79: WARNING: using old C markup; please migrate to \
%(root)s/objects.txt:84: WARNING: using old C markup; please migrate to \
new-style markup \(e.g. c:function instead of cfunction\), see \
http://sphinx.pocoo.org/domains.html
"""
@@ -51,183 +50,197 @@ HTML_WARNINGS = ENV_WARNINGS + """\
%(root)s/markup.txt:: WARNING: invalid pair index entry u'keyword; '
"""
def tail_check(check):
rex = re.compile(check)
def checker(nodes):
for node in nodes:
if node.tail and rex.search(node.tail):
return True
assert False, '%r not found in tail of any nodes %s' % (check, nodes)
return checker
HTML_XPATH = {
'images.html': {
".//img[@src='_images/img.png']": '',
".//img[@src='_images/img1.png']": '',
".//img[@src='_images/simg.png']": '',
".//object[@data='_images/svgimg.svg']": '',
".//embed[@src='_images/svgimg.svg']": '',
},
'subdir/images.html': {
".//img[@src='../_images/img1.png']": '',
".//img[@src='../_images/rimg.png']": '',
},
'subdir/includes.html': {
".//a[@href='../_downloads/img.png']": '',
".//img[@src='../_images/img.png']": '',
".//p": 'This is an include file.',
},
'includes.html': {
".//pre": u'Max Strauß',
".//a[@href='_downloads/img.png']": '',
".//a[@href='_downloads/img1.png']": '',
".//pre": u'"quotes"',
".//pre": u"'included'",
},
'autodoc.html': {
".//dt[@id='test_autodoc.Class']": '',
".//dt[@id='test_autodoc.function']/em": r'\*\*kwds',
".//dd/p": r'Return spam\.',
},
'extapi.html': {
".//strong": 'from function: Foo',
".//strong": 'from class: Bar',
},
'markup.html': {
".//title": 'set by title directive',
".//p/em": 'Section author: Georg Brandl',
".//p/em": 'Module author: Georg Brandl',
'images.html': [
(".//img[@src='_images/img.png']", ''),
(".//img[@src='_images/img1.png']", ''),
(".//img[@src='_images/simg.png']", ''),
(".//object[@data='_images/svgimg.svg']", ''),
(".//embed[@src='_images/svgimg.svg']", ''),
],
'subdir/images.html': [
(".//img[@src='../_images/img1.png']", ''),
(".//img[@src='../_images/rimg.png']", ''),
],
'subdir/includes.html': [
(".//a[@href='../_downloads/img.png']", ''),
(".//img[@src='../_images/img.png']", ''),
(".//p", 'This is an include file.'),
],
'includes.html': [
(".//pre", u'Max Strauß'),
(".//a[@href='_downloads/img.png']", ''),
(".//a[@href='_downloads/img1.png']", ''),
(".//pre", u'"quotes"'),
(".//pre", u"'included'"),
],
'autodoc.html': [
(".//dt[@id='test_autodoc.Class']", ''),
(".//dt[@id='test_autodoc.function']/em", r'\*\*kwds'),
(".//dd/p", r'Return spam\.'),
],
'extapi.html': [
(".//strong", 'from function: Foo'),
(".//strong", 'from class: Bar'),
],
'markup.html': [
(".//title", 'set by title directive'),
(".//p/em", 'Section author: Georg Brandl'),
(".//p/em", 'Module author: Georg Brandl'),
# created by the meta directive
".//meta[@name='author'][@content='Me']": '',
".//meta[@name='keywords'][@content='docs, sphinx']": '',
(".//meta[@name='author'][@content='Me']", ''),
(".//meta[@name='keywords'][@content='docs, sphinx']", ''),
# a label created by ``.. _label:``
".//div[@id='label']": '',
(".//div[@id='label']", ''),
# code with standard code blocks
".//pre": '^some code$',
(".//pre", '^some code$'),
# an option list
".//span[@class='option']": '--help',
(".//span[@class='option']", '--help'),
# admonitions
".//p[@class='first admonition-title']": 'My Admonition',
".//p[@class='last']": 'Note text.',
".//p[@class='last']": 'Warning text.',
(".//p[@class='first admonition-title']", 'My Admonition'),
(".//p[@class='last']", 'Note text.'),
(".//p[@class='last']", 'Warning text.'),
# inline markup
".//li/strong": '^command$',
".//li/strong": '^program$',
".//li/em": '^dfn$',
".//li/tt/span[@class='pre']": '^kbd$',
".//li/em": u'File \N{TRIANGULAR BULLET} Close',
".//li/tt/span[@class='pre']": '^a/$',
".//li/tt/em/span[@class='pre']": '^varpart$',
".//li/tt/em/span[@class='pre']": '^i$',
".//a[@href='http://www.python.org/dev/peps/pep-0008']"
"[@class='pep reference external']/strong": 'PEP 8',
".//a[@href='http://tools.ietf.org/html/rfc1.html']"
"[@class='rfc reference external']/strong": 'RFC 1',
".//a[@href='objects.html#envvar-HOME']"
"[@class='reference internal']/tt/span[@class='pre']": 'HOME',
".//a[@href='#with']"
"[@class='reference internal']/tt/span[@class='pre']": '^with$',
".//a[@href='#grammar-token-try_stmt']"
"[@class='reference internal']/tt/span": '^statement$',
".//a[@href='subdir/includes.html']"
"[@class='reference internal']/em": 'Including in subdir',
".//a[@href='objects.html#cmdoption-python-c']"
"[@class='reference internal']/em": 'Python -c option',
(".//li/strong", r'^command\\n$'),
(".//li/strong", r'^program\\n$'),
(".//li/em", r'^dfn\\n$'),
(".//li/tt/span[@class='pre']", r'^kbd\\n$'),
(".//li/em", u'File \N{TRIANGULAR BULLET} Close'),
(".//li/tt/span[@class='pre']", '^a/$'),
(".//li/tt/em/span[@class='pre']", '^varpart$'),
(".//li/tt/em/span[@class='pre']", '^i$'),
(".//a[@href='http://www.python.org/dev/peps/pep-0008']"
"[@class='pep reference external']/strong", 'PEP 8'),
(".//a[@href='http://tools.ietf.org/html/rfc1.html']"
"[@class='rfc reference external']/strong", 'RFC 1'),
(".//a[@href='objects.html#envvar-HOME']"
"[@class='reference internal']/tt/span[@class='pre']", 'HOME'),
(".//a[@href='#with']"
"[@class='reference internal']/tt/span[@class='pre']", '^with$'),
(".//a[@href='#grammar-token-try_stmt']"
"[@class='reference internal']/tt/span", '^statement$'),
(".//a[@href='subdir/includes.html']"
"[@class='reference internal']/em", 'Including in subdir'),
(".//a[@href='objects.html#cmdoption-python-c']"
"[@class='reference internal']/em", 'Python -c option'),
# abbreviations
".//abbr[@title='abbreviation']": '^abbr$',
(".//abbr[@title='abbreviation']", '^abbr$'),
# version stuff
".//span[@class='versionmodified']": 'New in version 0.6',
(".//span[@class='versionmodified']", 'New in version 0.6'),
# footnote reference
".//a[@class='footnote-reference']": r'\[1\]',
(".//a[@class='footnote-reference']", r'\[1\]'),
# created by reference lookup
".//a[@href='contents.html#ref1']": '',
(".//a[@href='contents.html#ref1']", ''),
# ``seealso`` directive
".//div/p[@class='first admonition-title']": 'See also',
(".//div/p[@class='first admonition-title']", 'See also'),
# a ``hlist`` directive
".//table[@class='hlist']/tr/td/ul/li": '^This$',
(".//table[@class='hlist']/tr/td/ul/li", '^This$'),
# a ``centered`` directive
".//p[@class='centered']/strong": 'LICENSE',
(".//p[@class='centered']/strong", 'LICENSE'),
# a glossary
".//dl/dt[@id='term-boson']": 'boson',
(".//dl/dt[@id='term-boson']", 'boson'),
# a production list
".//pre/strong": 'try_stmt',
".//pre/a[@href='#grammar-token-try1_stmt']/tt/span": 'try1_stmt',
(".//pre/strong", 'try_stmt'),
(".//pre/a[@href='#grammar-token-try1_stmt']/tt/span", 'try1_stmt'),
# tests for ``only`` directive
".//p": 'A global substitution.',
".//p": 'In HTML.',
".//p": 'In both.',
".//p": 'Always present',
},
'objects.html': {
".//dt[@id='mod.Cls.meth1']": '',
".//dt[@id='errmod.Error']": '',
".//a[@href='#mod.Cls'][@class='reference internal']": '',
".//dl[@class='userdesc']": '',
".//dt[@id='userdesc-myobj']": '',
".//a[@href='#userdesc-myobj']": '',
(".//p", 'A global substitution.'),
(".//p", 'In HTML.'),
(".//p", 'In both.'),
(".//p", 'Always present'),
],
'objects.html': [
(".//dt[@id='mod.Cls.meth1']", ''),
(".//dt[@id='errmod.Error']", ''),
(".//a[@href='#mod.Cls'][@class='reference internal']", ''),
(".//dl[@class='userdesc']", ''),
(".//dt[@id='userdesc-myobj']", ''),
(".//a[@href='#userdesc-myobj']", ''),
# C references
".//span[@class='pre']": 'CFunction()',
".//a[@href='#Sphinx_DoSomething']": '',
".//a[@href='#SphinxStruct.member']": '',
".//a[@href='#SPHINX_USE_PYTHON']": '',
".//a[@href='#SphinxType']": '',
".//a[@href='#sphinx_global']": '',
(".//span[@class='pre']", 'CFunction()'),
(".//a[@href='#Sphinx_DoSomething']", ''),
(".//a[@href='#SphinxStruct.member']", ''),
(".//a[@href='#SPHINX_USE_PYTHON']", ''),
(".//a[@href='#SphinxType']", ''),
(".//a[@href='#sphinx_global']", ''),
# reference from old C markup extension
".//a[@href='#Sphinx_Func']": '',
(".//a[@href='#Sphinx_Func']", ''),
# test global TOC created by toctree()
".//ul[@class='current']/li[@class='toctree-l1 current']/a[@href='']":
'Testing object descriptions',
".//li[@class='toctree-l1']/a[@href='markup.html']":
'Testing various markup',
(".//ul[@class='current']/li[@class='toctree-l1 current']/a[@href='']",
'Testing object descriptions'),
(".//li[@class='toctree-l1']/a[@href='markup.html']",
'Testing various markup'),
# custom sidebar
".//h4": 'Custom sidebar',
},
'contents.html': {
".//meta[@name='hc'][@content='hcval']": '',
".//meta[@name='hc_co'][@content='hcval_co']": '',
".//meta[@name='testopt'][@content='testoverride']": '',
".//td[@class='label']": r'\[Ref1\]',
".//td[@class='label']": '',
".//li[@class='toctree-l1']/a": 'Testing various markup',
".//li[@class='toctree-l2']/a": 'Inline markup',
".//title": 'Sphinx <Tests>',
".//div[@class='footer']": 'Georg Brandl & Team',
".//a[@href='http://python.org/']"
"[@class='reference external']": '',
".//li/a[@href='genindex.html']/em": 'Index',
".//li/a[@href='py-modindex.html']/em": 'Module Index',
".//li/a[@href='search.html']/em": 'Search Page',
(".//h4", 'Custom sidebar'),
# docfields
(".//td[@class='field-body']/ul/li/strong", '^moo$'),
(".//td[@class='field-body']/ul/li/strong",
tail_check(r'\(Moo\) .* Moo')),
],
'contents.html': [
(".//meta[@name='hc'][@content='hcval']", ''),
(".//meta[@name='hc_co'][@content='hcval_co']", ''),
(".//meta[@name='testopt'][@content='testoverride']", ''),
(".//td[@class='label']", r'\[Ref1\]'),
(".//td[@class='label']", ''),
(".//li[@class='toctree-l1']/a", 'Testing various markup'),
(".//li[@class='toctree-l2']/a", 'Inline markup'),
(".//title", 'Sphinx <Tests>'),
(".//div[@class='footer']", 'Georg Brandl & Team'),
(".//a[@href='http://python.org/']"
"[@class='reference external']", ''),
(".//li/a[@href='genindex.html']/em", 'Index'),
(".//li/a[@href='py-modindex.html']/em", 'Module Index'),
(".//li/a[@href='search.html']/em", 'Search Page'),
# custom sidebar only for contents
".//h4": 'Contents sidebar',
},
'bom.html': {
".//title": " File with UTF-8 BOM",
},
'extensions.html': {
".//a[@href='http://python.org/dev/']": "http://python.org/dev/",
".//a[@href='http://bugs.python.org/issue1000']": "issue 1000",
".//a[@href='http://bugs.python.org/issue1042']": "explicit caption",
},
'_static/statictmpl.html': {
".//project": 'Sphinx <Tests>',
},
(".//h4", 'Contents sidebar'),
],
'bom.html': [
(".//title", " File with UTF-8 BOM"),
],
'extensions.html': [
(".//a[@href='http://python.org/dev/']", "http://python.org/dev/"),
(".//a[@href='http://bugs.python.org/issue1000']", "issue 1000"),
(".//a[@href='http://bugs.python.org/issue1042']", "explicit caption"),
],
'_static/statictmpl.html': [
(".//project", 'Sphinx <Tests>'),
],
}
if pygments:
HTML_XPATH['includes.html'].update({
".//pre/span[@class='s']": u'üöä',
".//div[@class='inc-pyobj1 highlight-text']//pre":
r'^class Foo:\n pass\n\s*$',
".//div[@class='inc-pyobj2 highlight-text']//pre":
r'^ def baz\(\):\n pass\n\s*$',
".//div[@class='inc-lines highlight-text']//pre":
r'^class Foo:\n pass\nclass Bar:\n$',
".//div[@class='inc-startend highlight-text']//pre":
ur'^foo = u"Including Unicode characters: üöä"\n$',
".//div[@class='inc-preappend highlight-text']//pre":
r'(?m)^START CODE$',
".//div[@class='inc-pyobj-dedent highlight-python']//span":
r'def',
".//div[@class='inc-tab3 highlight-text']//pre":
r'-| |-',
".//div[@class='inc-tab8 highlight-python']//pre":
r'-| |-',
})
HTML_XPATH['subdir/includes.html'].update({
".//pre/span": 'line 1',
".//pre/span": 'line 2',
})
HTML_XPATH['includes.html'].extend([
(".//pre/span[@class='s']", u'üöä'),
(".//div[@class='inc-pyobj1 highlight-text']//pre",
r'^class Foo:\n pass\n\s*$'),
(".//div[@class='inc-pyobj2 highlight-text']//pre",
r'^ def baz\(\):\n pass\n\s*$'),
(".//div[@class='inc-lines highlight-text']//pre",
r'^class Foo:\n pass\nclass Bar:\n$'),
(".//div[@class='inc-startend highlight-text']//pre",
ur'^foo = u"Including Unicode characters: üöä"\n$'),
(".//div[@class='inc-preappend highlight-text']//pre",
r'(?m)^START CODE$'),
(".//div[@class='inc-pyobj-dedent highlight-python']//span",
r'def'),
(".//div[@class='inc-tab3 highlight-text']//pre",
r'-| |-'),
(".//div[@class='inc-tab8 highlight-python']//pre",
r'-| |-'),
])
HTML_XPATH['subdir/includes.html'].extend([
(".//pre/span", 'line 1'),
(".//pre/span", 'line 2'),
])
class NslessParser(ET.XMLParser):
"""XMLParser that throws away namespaces in tag names."""
@@ -285,14 +298,14 @@ def test_html(app):
html_warnings_exp = HTML_WARNINGS % {'root': re.escape(app.srcdir)}
assert re.match(html_warnings_exp + '$', html_warnings), \
'Warnings don\'t match:\n' + \
'\n'.join(difflib.ndiff(html_warnings_exp.splitlines(),
html_warnings.splitlines()))
'--- Expected (regex):\n' + html_warnings_exp + \
'--- Got:\n' + html_warnings
for fname, paths in HTML_XPATH.iteritems():
parser = NslessParser()
parser.entity.update(htmlentitydefs.entitydefs)
etree = ET.parse(os.path.join(app.outdir, fname), parser)
for path, check in paths.iteritems():
for path, check in paths:
yield check_xpath, etree, fname, path, check
check_static_entries(app.builder.outdir)

View File

@@ -12,7 +12,6 @@
import os
import re
import sys
import difflib
from StringIO import StringIO
from subprocess import Popen, PIPE
@@ -42,8 +41,9 @@ def test_latex(app):
latex_warnings_exp = LATEX_WARNINGS % {'root': app.srcdir}
assert re.match(latex_warnings_exp + '$', latex_warnings), \
'Warnings don\'t match:\n' + \
'\n'.join(difflib.ndiff(latex_warnings_exp.splitlines(),
latex_warnings.splitlines()))
'--- Expected (regex):\n' + latex_warnings_exp + \
'--- Got:\n' + latex_warnings
# file from latex_additional_files
assert (app.outdir / 'svgimg.svg').isfile()

View File

@@ -80,7 +80,10 @@ def test_read_inventory_v2():
def test_missing_reference(tempdir, app):
inv_file = tempdir / 'inventory'
write_file(inv_file, inventory_v2)
app.config.intersphinx_mapping = {'http://docs.python.org/': inv_file}
app.config.intersphinx_mapping = {
'http://docs.python.org/': inv_file,
'py3k': ('http://docs.python.org/py3k/', inv_file),
}
app.config.intersphinx_cache_limit = 0
# load the inventory and check if it's done correctly
@@ -91,7 +94,7 @@ def test_missing_reference(tempdir, app):
('foo', '2.0', 'http://docs.python.org/foo.html#module-module2', '-')
# create fake nodes and check referencing
contnode = nodes.emphasis('foo')
contnode = nodes.emphasis('foo', 'foo')
refnode = addnodes.pending_xref('')
refnode['reftarget'] = 'module1.func'
refnode['reftype'] = 'func'
@@ -101,7 +104,7 @@ def test_missing_reference(tempdir, app):
assert isinstance(rn, nodes.reference)
assert rn['refuri'] == 'http://docs.python.org/sub/foo.html#module1.func'
assert rn['reftitle'] == '(in foo v2.0)'
assert rn[0] is contnode
assert rn[0].astext() == 'module1.func'
# create unresolvable nodes and check None return value
refnode['reftype'] = 'foo'
@@ -110,3 +113,27 @@ def test_missing_reference(tempdir, app):
refnode['reftype'] = 'function'
refnode['reftarget'] = 'foo.func'
assert missing_reference(app, app.env, refnode, contnode) is None
# check handling of prefixes
# prefix given, target found: prefix is stripped
refnode['reftype'] = 'mod'
refnode['reftarget'] = 'py3k:module2'
rn = missing_reference(app, app.env, refnode, contnode)
assert rn[0].astext() == 'module2'
# prefix given, target not found and nonexplicit title: prefix is stripped
refnode['reftarget'] = 'py3k:unknown'
refnode['refexplicit'] = False
contnode[0] = nodes.Text('py3k:unknown')
rn = missing_reference(app, app.env, refnode, contnode)
assert rn is None
assert contnode[0].astext() == 'unknown'
# prefix given, target not found and explicit title: nothing is changed
refnode['reftarget'] = 'py3k:unknown'
refnode['refexplicit'] = True
contnode[0] = nodes.Text('py3k:unknown')
rn = missing_reference(app, app.env, refnode, contnode)
assert rn is None
assert contnode[0].astext() == 'py3k:unknown'

17
tox.ini Normal file
View File

@@ -0,0 +1,17 @@
[tox]
envlist=du07,du06,du05
[testenv]
deps=nose
commands=
nosetests
sphinx-build -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html
[testenv:du05]
deps=docutils==0.5
[testenv:du06]
deps=docutils==0.6
[testenv:du07]
deps=docutils==0.7