mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '1.7' into 5104_broken_apidoc_main
This commit is contained in:
commit
f54d886a61
3
CHANGES
3
CHANGES
@ -29,6 +29,9 @@ Bugs fixed
|
|||||||
* #5019: autodoc: crashed by Form Feed Character
|
* #5019: autodoc: crashed by Form Feed Character
|
||||||
* #5032: autodoc: loses the first staticmethod parameter for old styled classes
|
* #5032: autodoc: loses the first staticmethod parameter for old styled classes
|
||||||
* #5036: quickstart: Typing Ctrl-U clears the whole of line
|
* #5036: quickstart: Typing Ctrl-U clears the whole of line
|
||||||
|
* #5066: html: "relations" sidebar is not shown by default
|
||||||
|
* #5091: latex: curly braces in index entries are not handled correctly
|
||||||
|
* #5070: epub: Wrong internal href fragment links
|
||||||
* #5104: apidoc: Interface of ``sphinx.apidoc:main()`` has changed
|
* #5104: apidoc: Interface of ``sphinx.apidoc:main()`` has changed
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
|
14
doc/_templates/indexsidebar.html
vendored
14
doc/_templates/indexsidebar.html
vendored
@ -3,19 +3,9 @@
|
|||||||
{%trans%}project{%endtrans%}</p>
|
{%trans%}project{%endtrans%}</p>
|
||||||
|
|
||||||
<h3>Download</h3>
|
<h3>Download</h3>
|
||||||
{% if version.endswith('+') %}
|
<p class="download">{%trans%}Current version: <a href="https://pypi.org/project/Sphinx/" alt="PyPI"><img src="https://img.shields.io/pypi/v/sphinx.svg"></a>{%endtrans%}</p>
|
||||||
<p>{%trans%}This documentation is for version <b><a href="changes.html">{{ version }}</a></b>, which is
|
<p>{%trans%}Install Sphinx with:{%endtrans%}</p>
|
||||||
not released yet.{%endtrans%}</p>
|
|
||||||
<p>{%trans%}You can use it from the
|
|
||||||
<a href="https://github.com/sphinx-doc/sphinx/">Git repo</a> or look for
|
|
||||||
released versions in the <a href="https://pypi.python.org/pypi/Sphinx">Python
|
|
||||||
Package Index</a>.{%endtrans%}</p>
|
|
||||||
{% else %}
|
|
||||||
<p>{%trans%}Current version: <b><a href="changes.html">{{ version }}</a></b>{%endtrans%}</p>
|
|
||||||
<p>{%trans%}Get Sphinx from the <a href="https://pypi.python.org/pypi/Sphinx">Python Package
|
|
||||||
Index</a>, or install it with:{%endtrans%}</p>
|
|
||||||
<pre>pip install -U Sphinx</pre>
|
<pre>pip install -U Sphinx</pre>
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<h3>{%trans%}Questions? Suggestions?{%endtrans%}</h3>
|
<h3>{%trans%}Questions? Suggestions?{%endtrans%}</h3>
|
||||||
|
|
||||||
|
4
doc/_themes/sphinx13/static/sphinx13.css
vendored
4
doc/_themes/sphinx13/static/sphinx13.css
vendored
@ -140,6 +140,10 @@ div.sphinxsidebar .logo img {
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.sphinxsidebar .download a img {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
div.subscribeformwrapper {
|
div.subscribeformwrapper {
|
||||||
display: block;
|
display: block;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
REM Command file for Sphinx documentation
|
REM Command file for Sphinx documentation
|
||||||
|
|
||||||
if "%SPHINXBUILD%" == "" (
|
if "%SPHINXBUILD%" == "" (
|
||||||
set SPHINXBUILD=python ../sphinx-build.py
|
set SPHINXBUILD=python ../sphinx/cmd/build.py
|
||||||
)
|
)
|
||||||
set SOURCEDIR=.
|
set SOURCEDIR=.
|
||||||
set BUILDDIR=_build
|
set BUILDDIR=_build
|
||||||
|
@ -271,6 +271,16 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
node['refuri'] = self.fix_fragment(m.group(1), m.group(2))
|
node['refuri'] = self.fix_fragment(m.group(1), m.group(2))
|
||||||
if 'refid' in node:
|
if 'refid' in node:
|
||||||
node['refid'] = self.fix_fragment('', node['refid'])
|
node['refid'] = self.fix_fragment('', node['refid'])
|
||||||
|
for node in tree.traverse(nodes.target):
|
||||||
|
for i, node_id in enumerate(node['ids']):
|
||||||
|
if ':' in node_id:
|
||||||
|
node['ids'][i] = self.fix_fragment('', node_id)
|
||||||
|
|
||||||
|
next_node = node.next_node(siblings=True)
|
||||||
|
if next_node and isinstance(next_node, nodes.Element):
|
||||||
|
for i, node_id in enumerate(next_node['ids']):
|
||||||
|
if ':' in node_id:
|
||||||
|
next_node['ids'][i] = self.fix_fragment('', node_id)
|
||||||
for node in tree.traverse(addnodes.desc_signature):
|
for node in tree.traverse(addnodes.desc_signature):
|
||||||
ids = node.attributes['ids']
|
ids = node.attributes['ids']
|
||||||
newids = []
|
newids = []
|
||||||
|
@ -906,19 +906,27 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
def has_wildcard(pattern):
|
def has_wildcard(pattern):
|
||||||
# type: (unicode) -> bool
|
# type: (unicode) -> bool
|
||||||
return any(char in pattern for char in '*?[')
|
return any(char in pattern for char in '*?[')
|
||||||
sidebars = self.theme.get_config('theme', 'sidebars', None)
|
sidebars = None
|
||||||
matched = None
|
matched = None
|
||||||
customsidebar = None
|
customsidebar = None
|
||||||
|
|
||||||
# default sidebars settings for selected theme
|
# default sidebars settings for selected theme
|
||||||
theme_default_sidebars = self.theme.get_config('theme', 'sidebars', None)
|
if self.theme.name == 'alabaster':
|
||||||
if theme_default_sidebars:
|
|
||||||
sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
|
|
||||||
elif self.theme.name == 'alabaster':
|
|
||||||
# provide default settings for alabaster (for compatibility)
|
# provide default settings for alabaster (for compatibility)
|
||||||
# Note: this will be removed before Sphinx-2.0
|
# Note: this will be removed before Sphinx-2.0
|
||||||
sidebars = ['about.html', 'navigation.html', 'relation.html',
|
try:
|
||||||
'searchbox.html', 'donate.html']
|
# get default sidebars settings from alabaster (if defined)
|
||||||
|
theme_default_sidebars = self.theme.config.get('theme', 'sidebars')
|
||||||
|
if theme_default_sidebars:
|
||||||
|
sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
|
||||||
|
except Exception:
|
||||||
|
# fallback to better default settings
|
||||||
|
sidebars = ['about.html', 'navigation.html', 'relations.html',
|
||||||
|
'searchbox.html', 'donate.html']
|
||||||
|
else:
|
||||||
|
theme_default_sidebars = self.theme.get_config('theme', 'sidebars', None)
|
||||||
|
if theme_default_sidebars:
|
||||||
|
sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
|
||||||
|
|
||||||
# user sidebar settings
|
# user sidebar settings
|
||||||
for pattern, patsidebars in iteritems(self.config.html_sidebars):
|
for pattern, patsidebars in iteritems(self.config.html_sidebars):
|
||||||
|
@ -1953,8 +1953,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
# type: (nodes.Node, Pattern) -> None
|
# type: (nodes.Node, Pattern) -> None
|
||||||
def escape(value):
|
def escape(value):
|
||||||
value = self.encode(value)
|
value = self.encode(value)
|
||||||
value = value.replace(r'\{', r'\sphinxleftcurlybrace')
|
value = value.replace(r'\{', r'{\sphinxleftcurlybrace}')
|
||||||
value = value.replace(r'\}', r'\sphinxrightcurlybrace')
|
value = value.replace(r'\}', r'{\sphinxrightcurlybrace}')
|
||||||
return value
|
return value
|
||||||
|
|
||||||
if not node.get('inline', True):
|
if not node.get('inline', True):
|
||||||
|
11
tests/roots/test-epub-anchor-id/conf.py
Normal file
11
tests/roots/test-epub-anchor-id/conf.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
master_doc = 'index'
|
||||||
|
|
||||||
|
latex_documents = [
|
||||||
|
(master_doc, 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app):
|
||||||
|
app.add_crossref_type(directivename="setting", rolename="setting")
|
8
tests/roots/test-epub-anchor-id/index.rst
Normal file
8
tests/roots/test-epub-anchor-id/index.rst
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
test-epub-anchor-id
|
||||||
|
===================
|
||||||
|
|
||||||
|
.. setting:: STATICFILES_FINDERS
|
||||||
|
|
||||||
|
blah blah blah
|
||||||
|
|
||||||
|
see :setting:`STATICFILES_FINDERS`
|
@ -317,6 +317,15 @@ def test_epub_writing_mode(app):
|
|||||||
assert 'writing-mode: vertical-rl;' in css
|
assert 'writing-mode: vertical-rl;' in css
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx('epub', testroot='epub-anchor-id')
|
||||||
|
def test_epub_anchor_id(app):
|
||||||
|
app.build()
|
||||||
|
|
||||||
|
html = (app.outdir / 'index.xhtml').text()
|
||||||
|
assert '<p id="std-setting-STATICFILES_FINDERS">blah blah blah</p>' in html
|
||||||
|
assert 'see <a class="reference internal" href="#std-setting-STATICFILES_FINDERS">' in html
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('epub')
|
@pytest.mark.sphinx('epub')
|
||||||
def test_run_epubcheck(app):
|
def test_run_epubcheck(app):
|
||||||
app.build()
|
app.build()
|
||||||
|
@ -1230,21 +1230,50 @@ def test_html_remote_images(app, status, warning):
|
|||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='basic')
|
@pytest.mark.sphinx('html', testroot='basic')
|
||||||
def test_html_sidebar(app, status, warning):
|
def test_html_sidebar(app, status, warning):
|
||||||
|
ctx = {}
|
||||||
|
|
||||||
|
# default for alabaster
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
result = (app.outdir / 'index.html').text(encoding='utf8')
|
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||||
assert '<h3><a href="#">Table Of Contents</a></h3>' in result
|
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||||
|
'aria-label="main navigation">' in result)
|
||||||
|
assert '<h1 class="logo"><a href="#">Python</a></h1>' in result
|
||||||
|
assert '<h3>Navigation</h3>' in result
|
||||||
assert '<h3>Related Topics</h3>' in result
|
assert '<h3>Related Topics</h3>' in result
|
||||||
assert '<h3>This Page</h3>' in result
|
|
||||||
assert '<h3>Quick search</h3>' in result
|
assert '<h3>Quick search</h3>' in result
|
||||||
|
|
||||||
|
app.builder.add_sidebars('index', ctx)
|
||||||
|
assert ctx['sidebars'] == ['about.html', 'navigation.html', 'relations.html',
|
||||||
|
'searchbox.html', 'donate.html']
|
||||||
|
|
||||||
|
# only relations.html
|
||||||
|
app.config.html_sidebars = {'**': ['relations.html']}
|
||||||
|
app.builder.build_all()
|
||||||
|
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||||
|
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||||
|
'aria-label="main navigation">' in result)
|
||||||
|
assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
|
||||||
|
assert '<h3>Navigation</h3>' not in result
|
||||||
|
assert '<h3>Related Topics</h3>' in result
|
||||||
|
assert '<h3>Quick search</h3>' not in result
|
||||||
|
|
||||||
|
app.builder.add_sidebars('index', ctx)
|
||||||
|
assert ctx['sidebars'] == ['relations.html']
|
||||||
|
|
||||||
|
# no sidebars
|
||||||
app.config.html_sidebars = {'**': []}
|
app.config.html_sidebars = {'**': []}
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
result = (app.outdir / 'index.html').text(encoding='utf8')
|
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||||
assert '<h3><a href="#">Table Of Contents</a></h3>' not in result
|
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||||
|
'aria-label="main navigation">' not in result)
|
||||||
|
assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
|
||||||
|
assert '<h3>Navigation</h3>' not in result
|
||||||
assert '<h3>Related Topics</h3>' not in result
|
assert '<h3>Related Topics</h3>' not in result
|
||||||
assert '<h3>This Page</h3>' not in result
|
|
||||||
assert '<h3>Quick search</h3>' not in result
|
assert '<h3>Quick search</h3>' not in result
|
||||||
|
|
||||||
|
app.builder.add_sidebars('index', ctx)
|
||||||
|
assert ctx['sidebars'] == []
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('fname,expect', flat_dict({
|
@pytest.mark.parametrize('fname,expect', flat_dict({
|
||||||
'index.html': [(".//em/a[@href='https://example.com/man.1']", "", True),
|
'index.html': [(".//em/a[@href='https://example.com/man.1']", "", True),
|
||||||
|
@ -1209,7 +1209,7 @@ def test_latex_index(app, status, warning):
|
|||||||
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
||||||
assert 'A \\index{famous}famous \\index{equation}equation:\n' in result
|
assert 'A \\index{famous}famous \\index{equation}equation:\n' in result
|
||||||
assert '\n\\index{Einstein}\\index{relativity}\\ignorespaces \nand' in result
|
assert '\n\\index{Einstein}\\index{relativity}\\ignorespaces \nand' in result
|
||||||
assert '\n\\index{main \\sphinxleftcurlybrace}\\ignorespaces ' in result
|
assert '\n\\index{main {\\sphinxleftcurlybrace}}\\ignorespaces ' in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('latex', testroot='latex-equations')
|
@pytest.mark.sphinx('latex', testroot='latex-equations')
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import alabaster
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from sphinx.theming import ThemeError
|
from sphinx.theming import ThemeError
|
||||||
@ -23,11 +24,14 @@ from sphinx.theming import ThemeError
|
|||||||
def test_theme_api(app, status, warning):
|
def test_theme_api(app, status, warning):
|
||||||
cfg = app.config
|
cfg = app.config
|
||||||
|
|
||||||
|
themes = ['basic', 'default', 'scrolls', 'agogo', 'sphinxdoc', 'haiku',
|
||||||
|
'traditional', 'epub', 'nature', 'pyramid', 'bizstyle', 'classic', 'nonav',
|
||||||
|
'test-theme', 'ziptheme', 'staticfiles', 'parent', 'child']
|
||||||
|
if alabaster.version.__version_info__ >= (0, 7, 11):
|
||||||
|
themes.append('alabaster')
|
||||||
|
|
||||||
# test Theme class API
|
# test Theme class API
|
||||||
assert set(app.html_themes.keys()) == \
|
assert set(app.html_themes.keys()) == set(themes)
|
||||||
set(['basic', 'default', 'scrolls', 'agogo', 'sphinxdoc', 'haiku',
|
|
||||||
'traditional', 'epub', 'nature', 'pyramid', 'bizstyle', 'classic', 'nonav',
|
|
||||||
'test-theme', 'ziptheme', 'staticfiles', 'parent', 'child'])
|
|
||||||
assert app.html_themes['test-theme'] == app.srcdir / 'test_theme' / 'test-theme'
|
assert app.html_themes['test-theme'] == app.srcdir / 'test_theme' / 'test-theme'
|
||||||
assert app.html_themes['ziptheme'] == app.srcdir / 'ziptheme.zip'
|
assert app.html_themes['ziptheme'] == app.srcdir / 'ziptheme.zip'
|
||||||
assert app.html_themes['staticfiles'] == app.srcdir / 'test_theme' / 'staticfiles'
|
assert app.html_themes['staticfiles'] == app.srcdir / 'test_theme' / 'staticfiles'
|
||||||
|
Loading…
Reference in New Issue
Block a user