mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '2.0' into 6712_optional_Path_import
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -17,6 +17,8 @@ Features added
|
||||
--------------
|
||||
|
||||
* #6707: C++, support bit-fields.
|
||||
* #267: html: Eliminate prompt characters of doctest block from copyable text
|
||||
* #6729: html theme: agogo theme now supports ``rightsidebar`` option
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
@@ -29,6 +31,8 @@ Bugs fixed
|
||||
* #6704: linkcheck: Be defensive and handle newly defined HTTP error code
|
||||
* #6655: image URLs containing ``data:`` causes gettext builder crashed
|
||||
* #6584: i18n: Error when compiling message catalogs on Hindi
|
||||
* #6708: mathbase: Some deprecated functions have removed
|
||||
* #6709: autodoc: mock object does not work as a class decorator
|
||||
* #6712: Allow not to install sphinx.testing as runtime (mainly for ALT Linux)
|
||||
|
||||
Testing
|
||||
|
||||
@@ -237,6 +237,8 @@ These themes are:
|
||||
- **documentwidth** (CSS length): Width of the document (without sidebar),
|
||||
default 50em.
|
||||
- **sidebarwidth** (CSS length): Width of the sidebar, default 20em.
|
||||
- **rightsidebar** (true or false): Put the sidebar on the right side.
|
||||
Defaults to ``True``.
|
||||
- **bgcolor** (CSS color): Background color.
|
||||
- **headerbg** (CSS value for "background"): background for the header area,
|
||||
default a grayish gradient.
|
||||
|
||||
@@ -60,7 +60,7 @@ class _MockObject:
|
||||
return _make_subclass(key, self.__display_name__, self.__class__)()
|
||||
|
||||
def __call__(self, *args, **kw) -> Any:
|
||||
if args and type(args[0]) in [FunctionType, MethodType]:
|
||||
if args and type(args[0]) in [type, FunctionType, MethodType]:
|
||||
# Appears to be a decorator, pass through unchanged
|
||||
return args[0]
|
||||
return self
|
||||
|
||||
@@ -23,6 +23,10 @@ from sphinx.directives.patches import MathDirective as MathDirectiveBase
|
||||
from sphinx.domains.math import MathDomain # NOQA # to keep compatibility
|
||||
from sphinx.domains.math import MathReferenceRole as EqXRefRole # NOQA # to keep compatibility
|
||||
from sphinx.writers.html import HTMLTranslator
|
||||
from sphinx.writers.latex import LaTeXTranslator
|
||||
from sphinx.writers.manpage import ManualPageTranslator
|
||||
from sphinx.writers.texinfo import TexinfoTranslator
|
||||
from sphinx.writers.text import TextTranslator
|
||||
|
||||
|
||||
class MathDirective(MathDirectiveBase):
|
||||
@@ -70,6 +74,75 @@ def is_in_section_title(node: Element) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def latex_visit_math(self: LaTeXTranslator, node: Element) -> None:
|
||||
warnings.warn('latex_visit_math() is deprecated. '
|
||||
'Please use LaTeXTranslator.visit_math() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.visit_math(node)
|
||||
|
||||
|
||||
def latex_visit_displaymath(self: LaTeXTranslator, node: Element) -> None:
|
||||
warnings.warn('latex_visit_displaymath() is deprecated. '
|
||||
'Please use LaTeXTranslator.visit_math_block() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.visit_math_block(node)
|
||||
|
||||
|
||||
def man_visit_math(self: ManualPageTranslator, node: Element) -> None:
|
||||
warnings.warn('man_visit_math() is deprecated. '
|
||||
'Please use ManualPageTranslator.visit_math() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.visit_math(node)
|
||||
|
||||
|
||||
def man_visit_displaymath(self: ManualPageTranslator, node: Element) -> None:
|
||||
warnings.warn('man_visit_displaymath() is deprecated. '
|
||||
'Please use ManualPageTranslator.visit_math_block() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.visit_math_block(node)
|
||||
|
||||
|
||||
def man_depart_displaymath(self: ManualPageTranslator, node: Element) -> None:
|
||||
warnings.warn('man_depart_displaymath() is deprecated. '
|
||||
'Please use ManualPageTranslator.depart_math_block() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.depart_math_block(node)
|
||||
|
||||
|
||||
def texinfo_visit_math(self: TexinfoTranslator, node: Element) -> None:
|
||||
warnings.warn('texinfo_visit_math() is deprecated. '
|
||||
'Please use TexinfoTranslator.visit_math() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.visit_math(node)
|
||||
|
||||
|
||||
def texinfo_visit_displaymath(self: TexinfoTranslator, node: Element) -> None:
|
||||
warnings.warn('texinfo_visit_displaymath() is deprecated. '
|
||||
'Please use TexinfoTranslator.visit_math_block() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.visit_math_block(node)
|
||||
|
||||
|
||||
def texinfo_depart_displaymath(self: TexinfoTranslator, node: Element) -> None:
|
||||
warnings.warn('texinfo_depart_displaymath() is deprecated. '
|
||||
'Please use TexinfoTranslator.depart_math_block() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
|
||||
|
||||
def text_visit_math(self: TextTranslator, node: Element) -> None:
|
||||
warnings.warn('text_visit_math() is deprecated. '
|
||||
'Please use TextTranslator.visit_math() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.visit_math(node)
|
||||
|
||||
|
||||
def text_visit_displaymath(self: TextTranslator, node: Element) -> None:
|
||||
warnings.warn('text_visit_displaymath() is deprecated. '
|
||||
'Please use TextTranslator.visit_math_block() instead.',
|
||||
RemovedInSphinx30Warning, stacklevel=2)
|
||||
self.visit_math_block(node)
|
||||
|
||||
|
||||
def setup_math(app: Sphinx,
|
||||
htmlinlinevisitors: Tuple[Callable, Callable],
|
||||
htmldisplayvisitors: Tuple[Callable, Callable]) -> None:
|
||||
|
||||
@@ -33,15 +33,7 @@
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content-wrapper">
|
||||
<div class="content">
|
||||
<div class="document">
|
||||
{%- block document %}
|
||||
{{ super() }}
|
||||
{%- endblock %}
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
{%- macro agogo_sidebar() %}
|
||||
{%- block sidebartoc %}
|
||||
<h3>{{ _('Table of Contents') }}</h3>
|
||||
{{ toctree() }}
|
||||
@@ -55,7 +47,26 @@
|
||||
</form>
|
||||
</div>
|
||||
{%- endblock %}
|
||||
{% endmacro %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content-wrapper">
|
||||
<div class="content">
|
||||
{%- if not theme_rightsidebar|tobool %}
|
||||
<div class="sidebar">
|
||||
{{ agogo_sidebar() }}
|
||||
</div>
|
||||
{%- endif %}
|
||||
<div class="document">
|
||||
{%- block document %}
|
||||
{{ super() }}
|
||||
{%- endblock %}
|
||||
</div>
|
||||
{%- if theme_rightsidebar|tobool %}
|
||||
<div class="sidebar">
|
||||
{{ agogo_sidebar() }}
|
||||
</div>
|
||||
{%- endif %}
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -175,7 +175,11 @@ div.document {
|
||||
}
|
||||
|
||||
div.body {
|
||||
{%- if theme_rightsidebar|tobool %}
|
||||
padding-right: 2em;
|
||||
{%- else %}
|
||||
padding-left: 2em;
|
||||
{% endif %}
|
||||
text-align: {{ theme_textalign }};
|
||||
}
|
||||
|
||||
@@ -270,7 +274,11 @@ div.document ol {
|
||||
|
||||
div.sidebar {
|
||||
width: {{ theme_sidebarwidth|todim }};
|
||||
{%- if theme_rightsidebar|tobool %}
|
||||
float: right;
|
||||
{%- else %}
|
||||
float: left;
|
||||
{%- endif %}
|
||||
font-size: .9em;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ bodyfont = "Verdana", Arial, sans-serif
|
||||
headerfont = "Georgia", "Times New Roman", serif
|
||||
pagewidth = 70em
|
||||
documentwidth = 50em
|
||||
rightsidebar = true
|
||||
sidebarwidth = 20em
|
||||
bgcolor = #eeeeec
|
||||
headerbg = #555573 url(bgtop.png) top left repeat-x
|
||||
|
||||
@@ -672,6 +672,10 @@ div.code-block-caption + div > div.highlight > pre {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-number {
|
||||
padding: 0.1em 0.3em;
|
||||
font-style: italic;
|
||||
|
||||
@@ -269,6 +269,16 @@ class UnreferencedFootnotesDetector(SphinxTransform):
|
||||
location=node)
|
||||
|
||||
|
||||
class DoctestTransform(SphinxTransform):
|
||||
"""Set "doctest" style to each doctest_block node"""
|
||||
default_priority = 500
|
||||
|
||||
def apply(self, **kwargs):
|
||||
# type: (Any) -> None
|
||||
for node in self.document.traverse(nodes.doctest_block):
|
||||
node['classes'].append('doctest')
|
||||
|
||||
|
||||
class FigureAligner(SphinxTransform):
|
||||
"""
|
||||
Align figures to center by default.
|
||||
@@ -402,6 +412,7 @@ def setup(app: "Sphinx") -> Dict[str, Any]:
|
||||
app.add_transform(MoveModuleTargets)
|
||||
app.add_transform(HandleCodeBlocks)
|
||||
app.add_transform(SortIds)
|
||||
app.add_transform(DoctestTransform)
|
||||
app.add_transform(FigureAligner)
|
||||
app.add_transform(AutoNumbering)
|
||||
app.add_transform(AutoIndexUpgrader)
|
||||
|
||||
@@ -96,3 +96,24 @@ def test_abc_MockObject():
|
||||
assert isinstance(obj, Base)
|
||||
assert isinstance(obj, _MockObject)
|
||||
assert isinstance(obj.some_method(), Derived)
|
||||
|
||||
|
||||
def test_mock_decorator():
|
||||
mock = _MockObject()
|
||||
|
||||
@mock.function_deco
|
||||
def func():
|
||||
"""docstring"""
|
||||
|
||||
class Foo:
|
||||
@mock.method_deco
|
||||
def meth(self):
|
||||
"""docstring"""
|
||||
|
||||
@mock.class_deco
|
||||
class Bar:
|
||||
"""docstring"""
|
||||
|
||||
assert func.__doc__ == "docstring"
|
||||
assert Foo.meth.__doc__ == "docstring"
|
||||
assert Bar.__doc__ == "docstring"
|
||||
|
||||
Reference in New Issue
Block a user