mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '1.7'
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
coverage:
|
||||
status:
|
||||
patch:
|
||||
project:
|
||||
default:
|
||||
# allowed to drop X% and still result in a "success" commit status
|
||||
threshold: 0.05
|
||||
|
||||
9
CHANGES
9
CHANGES
@@ -54,6 +54,11 @@ Incompatible changes
|
||||
Deprecated
|
||||
----------
|
||||
|
||||
* #4623: ``sphinx.build_main()`` is deprecated. Use
|
||||
``sphinx.cmd.build.build_main()`` instead.
|
||||
* autosummary: The interface of ``sphinx.ext.autosummary.get_documenter()`` has
|
||||
been changed (Since 1.7.0)
|
||||
|
||||
Features added
|
||||
--------------
|
||||
|
||||
@@ -66,6 +71,10 @@ Bugs fixed
|
||||
* #4622: epub: :confval:`epub_scheme` does not effect to content.opf
|
||||
* #4627: graphviz: Fit graphviz images to page
|
||||
* #4617: quickstart: PROJECT_DIR argument is required
|
||||
* #4623: sphinx.build_main no longer exists in 1.7.0
|
||||
* #4615: The argument of ``sphinx.build`` has been changed in 1.7.0
|
||||
* autosummary: The interface of ``sphinx.ext.autosummary.get_documenter()`` has
|
||||
been changed
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
from os import path
|
||||
|
||||
@@ -77,9 +78,30 @@ def main(*args, **kwargs):
|
||||
RemovedInSphinx20Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
args = args[1:] # skip first argument to adjust arguments (refs: #4615)
|
||||
return build.main(*args, **kwargs)
|
||||
|
||||
|
||||
def build_main(argv=sys.argv):
|
||||
"""Sphinx build "main" command-line entry."""
|
||||
warnings.warn(
|
||||
'`sphinx.build_main()` has moved to `sphinx.cmd.build.build_main()`.',
|
||||
RemovedInSphinx20Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return build.build_main(argv[1:]) # skip first argument to adjust arguments (refs: #4615)
|
||||
|
||||
|
||||
def make_main(argv=sys.argv):
|
||||
"""Sphinx build "make mode" entry."""
|
||||
warnings.warn(
|
||||
'`sphinx.build_main()` has moved to `sphinx.cmd.build.make_main()`.',
|
||||
RemovedInSphinx20Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return build.make_main(argv[1:]) # skip first argument to adjust arguments (refs: #4615)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from .cmd import build
|
||||
warnings.warn(
|
||||
|
||||
@@ -28,6 +28,7 @@ def main(*args, **kwargs):
|
||||
RemovedInSphinx20Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
args = args[1:] # skip first argument to adjust arguments (refs: #4615)
|
||||
_main(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ import os
|
||||
import posixpath
|
||||
import re
|
||||
import sys
|
||||
import warnings
|
||||
from types import ModuleType
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
@@ -69,6 +70,7 @@ from six import text_type
|
||||
|
||||
import sphinx
|
||||
from sphinx import addnodes
|
||||
from sphinx.deprecation import RemovedInSphinx20Warning
|
||||
from sphinx.environment.adapters.toctree import TocTree
|
||||
from sphinx.ext.autodoc import get_documenters
|
||||
from sphinx.ext.autodoc.directive import DocumenterBridge, Options
|
||||
@@ -154,14 +156,18 @@ def autosummary_table_visit_html(self, node):
|
||||
|
||||
# -- autodoc integration -------------------------------------------------------
|
||||
|
||||
# current application object (used in `get_documenter()`).
|
||||
_app = None # type: Sphinx
|
||||
|
||||
|
||||
class FakeDirective(DocumenterBridge):
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
super(FakeDirective, self).__init__({}, None, Options(), 0) # type: ignore
|
||||
|
||||
|
||||
def get_documenter(app, obj, parent):
|
||||
# type: (Sphinx, Any, Any) -> Type[Documenter]
|
||||
def get_documenter(*args):
|
||||
# type: (Any) -> Type[Documenter]
|
||||
"""Get an autodoc.Documenter class suitable for documenting the given
|
||||
object.
|
||||
|
||||
@@ -170,6 +176,16 @@ def get_documenter(app, obj, parent):
|
||||
belongs to.
|
||||
"""
|
||||
from sphinx.ext.autodoc import DataDocumenter, ModuleDocumenter
|
||||
if len(args) == 3:
|
||||
# new style arguments: (app, obj, parent)
|
||||
app, obj, parent = args
|
||||
else:
|
||||
# old style arguments: (obj, parent)
|
||||
app = _app
|
||||
obj, parent = args
|
||||
warnings.warn('the interface of get_documenter() has been changed. '
|
||||
'Please give application object as first argument.',
|
||||
RemovedInSphinx20Warning)
|
||||
|
||||
if inspect.ismodule(obj):
|
||||
# ModuleDocumenter.can_document_member always returns False
|
||||
|
||||
@@ -27,6 +27,7 @@ def main(*args, **kwargs):
|
||||
RemovedInSphinx20Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
args = args[1:] # skip first argument to adjust arguments (refs: #4615)
|
||||
_main(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
@@ -9,15 +9,18 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from six import string_types, iteritems
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx30Warning
|
||||
from sphinx.util import import_object
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any, Dict # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.config import Config # NOQA
|
||||
@@ -35,9 +38,24 @@ def deprecate_source_parsers(app, config):
|
||||
app.add_source_parser(suffix, parser)
|
||||
|
||||
|
||||
def register_application_for_autosummary(app):
|
||||
# type: (Sphinx) -> None
|
||||
"""Register application object to autosummary module.
|
||||
|
||||
Since Sphinx-1.7, documenters and attrgetters are registered into
|
||||
applicaiton object. As a result, the arguments of
|
||||
``get_documenter()`` has been changed. To keep compatibility,
|
||||
this handler registers application object to the module.
|
||||
"""
|
||||
if 'sphinx.ext.autosummary' in sys.modules:
|
||||
from sphinx.ext import autosummary
|
||||
autosummary._app = app
|
||||
|
||||
|
||||
def setup(app):
|
||||
# type: (Sphinx) -> Dict[unicode, Any]
|
||||
app.connect('config-inited', deprecate_source_parsers)
|
||||
app.connect('builder-inited', register_application_for_autosummary)
|
||||
|
||||
return {
|
||||
'version': 'builtin',
|
||||
|
||||
Reference in New Issue
Block a user