Merge branch 'stable'

This commit is contained in:
Takeshi KOMIYA 2017-03-22 09:49:48 +09:00
commit 6376e6053c
7 changed files with 85 additions and 12 deletions

View File

@ -171,6 +171,9 @@ Bugs fixed
* #2665, #2607: Link names in C++ docfields, and make it possible for other domains. * #2665, #2607: Link names in C++ docfields, and make it possible for other domains.
* #3542: C++, fix parsing error of non-type template argument with template. * #3542: C++, fix parsing error of non-type template argument with template.
* #3065, #3520: python domain fails to recognize nested class * #3065, #3520: python domain fails to recognize nested class
* #3575: Problems with pdflatex in a Turkish document built with sphinx has
reappeared (refs #2997, #2397)
* #3577: Fix intersphinx debug tool
Testing Testing
-------- --------

View File

@ -4,7 +4,7 @@
import re import re
import sphinx import sphinx
language = 'ja'
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
'sphinx.ext.autosummary', 'sphinx.ext.extlinks', 'sphinx.ext.autosummary', 'sphinx.ext.extlinks',

View File

@ -76,9 +76,10 @@ directive name.
.. rubric:: Default Domain .. rubric:: Default Domain
To avoid having to writing the domain name all the time when you e.g. only For documentation describing objects from solely one domain, authors will not
describe Python objects, a default domain can be selected with either the config have to state again its name at each directive, role, etc... after
value :confval:`primary_domain` or this directive: having specified a default. This can be done either via the config
value :confval:`primary_domain` or via this directive:
.. rst:directive:: .. default-domain:: name .. rst:directive:: .. default-domain:: name

View File

@ -56,7 +56,7 @@ class ENUM(object):
"""represents the config value should be a one of candidates. """represents the config value should be a one of candidates.
Example: Example:
app.add_config_value('latex_show_urls', 'no', ENUM('no', 'footnote', 'inline')) app.add_config_value('latex_show_urls', 'no', None, ENUM('no', 'footnote', 'inline'))
""" """
def __init__(self, *candidates): def __init__(self, *candidates):
# type: (unicode) -> None # type: (unicode) -> None

View File

@ -26,6 +26,7 @@
from __future__ import print_function from __future__ import print_function
import sys
import time import time
import functools import functools
import posixpath import posixpath
@ -340,17 +341,27 @@ def setup(app):
return {'version': sphinx.__display_version__, 'parallel_read_safe': True} return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
if __name__ == '__main__': def debug(argv):
# debug functionality to print out an inventory # type: (List[unicode]) -> None
import sys """Debug functionality to print out an inventory"""
if len(argv) < 2:
print("Print out an inventory file.\n"
"Error: must specify local path or URL to an inventory file.",
file=sys.stderr)
sys.exit(1)
class MockConfig(object):
intersphinx_timeout = None # type: int
tls_verify = False
class MockApp(object): class MockApp(object):
srcdir = '' srcdir = ''
config = MockConfig()
def warn(self, msg): def warn(self, msg):
print(msg, file=sys.stderr) print(msg, file=sys.stderr)
filename = sys.argv[1] filename = argv[1]
invdata = fetch_inventory(MockApp(), '', filename) # type: ignore invdata = fetch_inventory(MockApp(), '', filename) # type: ignore
for key in sorted(invdata or {}): for key in sorted(invdata or {}):
print(key) print(key)
@ -358,3 +369,7 @@ if __name__ == '__main__':
print('\t%-40s %s%s' % (entry, print('\t%-40s %s%s' % (entry,
einfo[3] != '-' and '%-40s: ' % einfo[3] or '', einfo[3] != '-' and '%-40s: ' % einfo[3] or '',
einfo[2])) einfo[2]))
if __name__ == '__main__':
debug(argv=sys.argv) # type: ignore

View File

@ -185,9 +185,10 @@ class ExtBabel(Babel):
if shortlang in ('de', 'ngerman', 'sl', 'slovene', 'pt', 'portuges', if shortlang in ('de', 'ngerman', 'sl', 'slovene', 'pt', 'portuges',
'es', 'spanish', 'nl', 'dutch', 'pl', 'polish', 'it', 'es', 'spanish', 'nl', 'dutch', 'pl', 'polish', 'it',
'italian'): 'italian'):
return '\\if\\catcode`\\"\\active\\shorthandoff{"}\\fi' return '\\ifnum\\catcode`\\"=\\active\\shorthandoff{"}\\fi'
elif shortlang in ('tr', 'turkish'): elif shortlang in ('tr', 'turkish'):
return '\\if\\catcode`\\=\\active\\shorthandoff{=}\\fi' # memo: if ever Sphinx starts supporting 'Latin', do as for Turkish
return '\\ifnum\\catcode`\\=\\string=\\active\\shorthandoff{=}\\fi'
return '' return ''
def uses_cyrillic(self): def uses_cyrillic(self):

View File

@ -13,12 +13,15 @@ import unittest
from docutils import nodes from docutils import nodes
import mock import mock
import pytest
import requests
from io import BytesIO
from sphinx import addnodes from sphinx import addnodes
from sphinx.ext.intersphinx import setup as intersphinx_setup from sphinx.ext.intersphinx import setup as intersphinx_setup
from sphinx.ext.intersphinx import ( from sphinx.ext.intersphinx import (
load_mappings, missing_reference, _strip_basic_auth, load_mappings, missing_reference, _strip_basic_auth,
_get_safe_url, fetch_inventory, INVENTORY_FILENAME _get_safe_url, fetch_inventory, INVENTORY_FILENAME, debug
) )
from test_util_inventory import inventory_v2 from test_util_inventory import inventory_v2
@ -229,3 +232,53 @@ def test_getsafeurl_unauthed():
expected = 'https://domain.com/project/objects.inv' expected = 'https://domain.com/project/objects.inv'
actual = _get_safe_url(url) actual = _get_safe_url(url)
assert expected == actual assert expected == actual
def test_debug_noargs(capsys):
"""debug interface, without arguments"""
with pytest.raises(SystemExit):
debug(['sphinx/ext/intersphinx.py'])
expected = (
"Print out an inventory file.\n"
"Error: must specify local path or URL to an inventory file."
)
stdout, stderr = capsys.readouterr()
assert stdout == ""
assert stderr == expected + "\n"
def test_debug_file(capsys, tempdir):
"""debug interface, with file argument"""
inv_file = tempdir / 'inventory'
inv_file.write_bytes(inventory_v2)
debug(['sphinx/ext/intersphinx.py', str(inv_file)])
stdout, stderr = capsys.readouterr()
assert stdout.startswith("c:function\n")
assert stderr == ""
@mock.patch('requests.get')
def test_debug_url(fake_get, capsys):
"""debug interface, with url argument"""
raw = BytesIO(inventory_v2)
real_read = raw.read
def fake_read(*args, **kwargs):
return real_read()
raw.read = fake_read
url = 'http://hostname/' + INVENTORY_FILENAME
resp = requests.Response()
resp.status_code = 200
resp.url = url
resp.raw = raw
fake_get.return_value = resp
debug(['sphinx/ext/intersphinx.py', url])
stdout, stderr = capsys.readouterr()
assert stdout.startswith("c:function\n")
assert stderr == ""