Merge branch '1.7' into qthelp_templates

This commit is contained in:
Takeshi KOMIYA 2018-03-20 01:43:46 +09:00 committed by GitHub
commit f2d4ebe9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 30 additions and 36 deletions

View File

@ -28,9 +28,12 @@ Bugs fixed
* #4716: Generation PDF file with TexLive on Windows, file not found error
* #4574: vertical space before equation in latex
* #4720: message when an image is mismatched for builder is not clear
* #4655, #4684: Incomplete localization strings in Polish and Chinese
* #2286: Sphinx crashes when error is happens in rendering HTML pages
* #4688: Error to download remote images having long URL
* #4754: sphinx/pycode/__init__.py raises AttributeError
* #1435: qthelp builder should htmlescape keywords
Testing
--------

View File

@ -96,7 +96,7 @@ switch on line numbers for the individual block::
Some more Ruby code.
The first line number can be selected with the ``lineno-start`` option. If
present, ``linenos`` is automatically activated as well::
present, ``linenos`` flag is automatically activated::
.. code-block:: ruby
:lineno-start: 10

View File

@ -35,8 +35,9 @@ from sphinx.deprecation import RemovedInSphinx20Warning
from sphinx.environment.adapters.asset import ImageAdapter
from sphinx.environment.adapters.indexentries import IndexEntries
from sphinx.environment.adapters.toctree import TocTree
from sphinx.errors import ThemeError
from sphinx.highlighting import PygmentsBridge
from sphinx.locale import _, l_
from sphinx.locale import _, __, l_
from sphinx.search import js_index
from sphinx.theming import HTMLThemeFactory
from sphinx.util import jsonimpl, logging, status_iterator
@ -1016,6 +1017,9 @@ class StandaloneHTMLBuilder(Builder):
"Please make sure all config values that contain "
"non-ASCII content are Unicode strings.", pagename)
return
except Exception as exc:
raise ThemeError(__("An error happened in rendering the page %s.\nReason: %r") %
(pagename, exc))
if not outfilename:
outfilename = self.get_outfilename(pagename)

View File

@ -104,7 +104,7 @@ def jobs_argument(value):
def get_parser():
# type: () -> argparse.ArgumentParser
parser = argparse.ArgumentParser(
usage='usage: %(prog)s [OPTIONS] SOURCEDIR OUTPUTDIR [FILENAMES...]',
usage='%(prog)s [OPTIONS] SOURCEDIR OUTPUTDIR [FILENAMES...]',
epilog='For more information, visit <http://sphinx-doc.org/>.',
description="""
Generate documentation from source files.

View File

@ -295,7 +295,7 @@ def is_excluded(root, excludes):
def get_parser():
# type: () -> argparse.ArgumentParser
parser = argparse.ArgumentParser(
usage='usage: %(prog)s [OPTIONS] -o <OUTPUT_PATH> <MODULE_PATH> '
usage='%(prog)s [OPTIONS] -o <OUTPUT_PATH> <MODULE_PATH> '
'[EXCLUDE_PATTERN, ...]',
epilog='For more information, visit <http://sphinx-doc.org/>.',
description="""

View File

@ -265,7 +265,7 @@ msgstr ""
msgid ""
"the extension %r was already merged with Sphinx since version %s; this "
"extension is ignored."
msgstr "自版本 %s 开始,扩展 %r 已合并至 Sphinx该扩展被忽略。"
msgstr ""
#: sphinx/registry.py:315
msgid "Original exception:\n"
@ -1295,7 +1295,7 @@ msgstr "目录"
#: sphinx/transforms/post_transforms/__init__.py:139
#, python-format
msgid "more than one target found for 'any' cross-reference %r: could be %s"
msgstr "'any' 交叉引用的目标不唯一:可能是 %s"
msgstr ""
#: sphinx/transforms/post_transforms/__init__.py:169
#, python-format

View File

@ -117,23 +117,3 @@ class ModuleAnalyzer(object):
self.parse()
return self.tags
if __name__ == '__main__':
import time
import pprint
x0 = time.time()
# ma = ModuleAnalyzer.for_file(__file__.rstrip('c'), 'sphinx.builders.html')
ma = ModuleAnalyzer.for_file('sphinx/environment.py',
'sphinx.environment')
ma.tokenize()
x1 = time.time()
ma.parse()
x2 = time.time()
# for (ns, name), doc in iteritems(ma.find_attr_docs()):
# print '>>', ns, name
# print '\n'.join(doc)
pprint.pprint(ma.find_tags())
x3 = time.time()
# print nodes.nice_repr(ma.parsetree, number2name)
print("tokenizing %.4f, parsing %.4f, finding %.4f" % (x1 - x0, x2 - x1, x3 - x2))

View File

@ -30,6 +30,8 @@ if False:
logger = logging.getLogger(__name__)
MAX_FILENAME_LEN = 32
class BaseImageConverter(SphinxTransform):
def apply(self):
@ -66,16 +68,21 @@ class ImageDownloader(BaseImageConverter):
def handle(self, node):
# type: (nodes.Node) -> None
basename = os.path.basename(node['uri'])
if '?' in basename:
basename = basename.split('?')[0]
if basename == '':
basename = sha1(node['uri'].encode("utf-8")).hexdigest()
dirname = node['uri'].replace('://', '/').translate({ord("?"): u"/",
ord("&"): u"/"})
ensuredir(os.path.join(self.imagedir, dirname))
path = os.path.join(self.imagedir, dirname, basename)
try:
basename = os.path.basename(node['uri'])
if '?' in basename:
basename = basename.split('?')[0]
if basename == '' or len(basename) > MAX_FILENAME_LEN:
filename, ext = os.path.splitext(node['uri'])
basename = sha1(filename.encode("utf-8")).hexdigest() + ext
dirname = node['uri'].replace('://', '/').translate({ord("?"): u"/",
ord("&"): u"/"})
if len(dirname) > MAX_FILENAME_LEN:
dirname = sha1(dirname.encode('utf-8')).hexdigest()
ensuredir(os.path.join(self.imagedir, dirname))
path = os.path.join(self.imagedir, dirname, basename)
headers = {}
if os.path.exists(path):
timestamp = ceil(os.stat(path).st_mtime)