mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '1.7-release'
This commit is contained in:
commit
5558b63315
@ -15,7 +15,7 @@ matrix:
|
||||
- python: '2.7'
|
||||
env:
|
||||
- TOXENV=du13
|
||||
- PYTEST_ADDOPTS = --cov sphinx --cov-append --cov-config setup.cfg
|
||||
- PYTEST_ADDOPTS="--cov ./ --cov-append --cov-config setup.cfg"
|
||||
- python: '3.4'
|
||||
env: TOXENV=py34
|
||||
- python: '3.5'
|
||||
@ -23,7 +23,7 @@ matrix:
|
||||
- python: '3.6'
|
||||
env:
|
||||
- TOXENV=py36
|
||||
- PYTEST_ADDOPTS = --cov sphinx --cov-append --cov-config setup.cfg
|
||||
- PYTEST_ADDOPTS="--cov ./ --cov-append --cov-config setup.cfg"
|
||||
- python: 'nightly'
|
||||
env: TOXENV=py37
|
||||
- python: '3.6'
|
||||
@ -46,4 +46,4 @@ script:
|
||||
- tox -- -v
|
||||
|
||||
after_success:
|
||||
- codecov
|
||||
- if [[ -e .coverage ]]; then codecov -e $TOXENV; fi
|
||||
|
4
CHANGES
4
CHANGES
@ -57,6 +57,8 @@ Bugs fixed
|
||||
----------
|
||||
|
||||
* #4019: inheritance_diagram AttributeError stoping make process
|
||||
* #4531: autosummary: methods are not treated as attributes
|
||||
* #4538: autodoc: ``sphinx.ext.autodoc.Options`` has been moved
|
||||
* #4539: autodoc emits warnings for partialmethods
|
||||
|
||||
Testing
|
||||
@ -276,6 +278,8 @@ Bugs fixed
|
||||
* #4525: autosectionlabel does not support parallel build
|
||||
* #3953: Do not raise warning when there is a working intersphinx inventory
|
||||
* #4487: math: ValueError is raised on parallel build. Thanks to jschueller.
|
||||
* #2372: autosummary: invalid signatures are shown for type annotated functions
|
||||
* #3942: html: table is not aligned to center even if ``:align: center``
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -226,6 +226,18 @@ def between(marker, what=None, keepempty=False, exclude=False):
|
||||
return process
|
||||
|
||||
|
||||
# This class is used only in ``sphinx.ext.autodoc.directive``,
|
||||
# But we define this class here to keep compatibility (see #4538)
|
||||
class Options(dict):
|
||||
"""A dict/attribute hybrid that returns None on nonexisting keys."""
|
||||
def __getattr__(self, name):
|
||||
# type: (unicode) -> Any
|
||||
try:
|
||||
return self[name.replace('_', '-')]
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
|
||||
class Documenter(object):
|
||||
"""
|
||||
A Documenter knows how to autodocument a single object type. When
|
||||
|
@ -12,7 +12,7 @@ from docutils.parsers.rst import Directive
|
||||
from docutils.statemachine import ViewList
|
||||
from docutils.utils import assemble_option_dict
|
||||
|
||||
from sphinx.ext.autodoc import get_documenters
|
||||
from sphinx.ext.autodoc import Options, get_documenters
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.docutils import switch_source_input
|
||||
from sphinx.util.nodes import nested_parse_with_titles
|
||||
@ -43,16 +43,6 @@ class DummyOptionSpec(object):
|
||||
return lambda x: x
|
||||
|
||||
|
||||
class Options(dict):
|
||||
"""A dict/attribute hybrid that returns None on nonexisting keys."""
|
||||
def __getattr__(self, name):
|
||||
# type: (unicode) -> Any
|
||||
try:
|
||||
return self[name.replace('_', '-')]
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
|
||||
class DocumenterBridge(object):
|
||||
"""A parameters container for Documenters."""
|
||||
|
||||
|
@ -399,10 +399,20 @@ class Autosummary(Directive):
|
||||
return [table_spec, table]
|
||||
|
||||
|
||||
def strip_arg_typehint(s):
|
||||
# type: (unicode) -> unicode
|
||||
"""Strip a type hint from argument definition."""
|
||||
return s.split(':')[0].strip()
|
||||
|
||||
|
||||
def mangle_signature(sig, max_chars=30):
|
||||
# type: (unicode, int) -> unicode
|
||||
"""Reformat a function signature to a more compact form."""
|
||||
s = re.sub(r"^\((.*)\)$", r"\1", sig).strip()
|
||||
# Strip return type annotation
|
||||
s = re.sub(r"\)\s*->\s.*$", ")", sig)
|
||||
|
||||
# Remove parenthesis
|
||||
s = re.sub(r"^\((.*)\)$", r"\1", s).strip()
|
||||
|
||||
# Strip strings (which can contain things that confuse the code below)
|
||||
s = re.sub(r"\\\\", "", s)
|
||||
@ -424,6 +434,13 @@ def mangle_signature(sig, max_chars=30):
|
||||
opts.insert(0, m.group(2))
|
||||
s = m.group(1)[:-2]
|
||||
|
||||
# Strip typehints
|
||||
for i, arg in enumerate(args):
|
||||
args[i] = strip_arg_typehint(arg)
|
||||
|
||||
for i, opt in enumerate(opts):
|
||||
opts[i] = strip_arg_typehint(opt)
|
||||
|
||||
# Produce a more compact signature
|
||||
sig = limited_join(", ", args, max_chars=max_chars - 2)
|
||||
if opts:
|
||||
|
@ -230,7 +230,7 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
||||
generate_autosummary_docs(new_files, output_dir=output_dir,
|
||||
suffix=suffix, warn=warn, info=info,
|
||||
base_path=base_path, builder=builder,
|
||||
template_dir=template_dir)
|
||||
template_dir=template_dir, app=app)
|
||||
|
||||
|
||||
# -- Finding documented entries in files ---------------------------------------
|
||||
|
@ -349,6 +349,11 @@ table.docutils {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table caption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ def test_mangle_signature():
|
||||
(a, b={'c=d, ': 3, '\\\\': 3}) :: (a[, b])
|
||||
(a=1, b=2, c=3) :: ([a, b, c])
|
||||
(a=1, b=<SomeClass: a, b, c>, c=3) :: ([a, b, c])
|
||||
(a: int, b: int) -> str :: (a, b)
|
||||
"""
|
||||
|
||||
TEST = [[y.strip() for y in x.split("::")] for x in TEST.split("\n")
|
||||
|
2
tox.ini
2
tox.ini
@ -5,7 +5,7 @@ envlist = docs,flake8,mypy,coverage,py{27,34,35,36,py},du{11,12,13,14}
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
passenv =
|
||||
https_proxy http_proxy no_proxy PERL PERL5LIB
|
||||
https_proxy http_proxy no_proxy PERL PERL5LIB PYTEST_ADDOPTS
|
||||
description =
|
||||
py{27,34,35,36,py}: Run unit tests against {envname}.
|
||||
du{11,12,13,14}: Run unit tests with the given version of docutils.
|
||||
|
Loading…
Reference in New Issue
Block a user