diff --git a/CHANGES b/CHANGES index a30d490e7..b4cb49338 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,11 @@ Release 1.1 (in development) Release 1.0.2 (in development) ============================== +* #490: Fix cross-references to objects of types added by the + :func:`~.Sphinx.add_object_type` API function. + +* Fix handling of doc field types for different directive types. + * Allow breaking long signatures, continuing with backlash-escaped newlines. diff --git a/doc/ext/autodoc.rst b/doc/ext/autodoc.rst index 813331015..a1d9d98fb 100644 --- a/doc/ext/autodoc.rst +++ b/doc/ext/autodoc.rst @@ -84,6 +84,9 @@ inserting them into the page source under a suitable :rst:dir:`py:module`, will document all non-private member functions and properties (that is, those whose name doesn't start with ``_``). + For modules, ``__all__`` will be respected when looking for members; the + order of the members will also be the order in ``__all__``. + You can also give an explicit list of members; only these will then be documented:: diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index 48c44178d..b7adbcafd 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -162,7 +162,6 @@ class ObjectDescription(Directive): self.env.temp_data['object'] = self.names[0] self.before_content() self.state.nested_parse(self.content, self.content_offset, contentnode) - #self.handle_doc_fields(contentnode) DocFieldTransformer(self).transform_all(contentnode) self.env.temp_data['object'] = None self.after_content() diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index 63a3bf6dc..6194ace9a 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -484,7 +484,13 @@ class StandardDomain(Domain): return make_refnode(builder, fromdocname, docname, labelid, contnode) else: - docname, labelid = self.data['objects'].get((typ, target), ('', '')) + objtypes = self.objtypes_for_role(typ) or [] + for objtype in objtypes: + if (objtype, target) in self.data['objects']: + docname, labelid = self.data['objects'][objtype, target] + break + else: + docname, labelid = '', '' if not docname: if typ == 'term': env.warn(node.get('refdoc', fromdocname), diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py index 6ce6d82bf..89f81e8cb 100644 --- a/sphinx/util/docfields.py +++ b/sphinx/util/docfields.py @@ -167,7 +167,7 @@ class DocFieldTransformer(object): def __init__(self, directive): self.domain = directive.domain - if not hasattr(directive, '_doc_field_type_map'): + if '_doc_field_type_map' not in directive.__class__.__dict__: directive.__class__._doc_field_type_map = \ self.preprocess_fieldtypes(directive.__class__.doc_field_types) self.typemap = directive._doc_field_type_map diff --git a/sphinx/util/smartypants.py b/sphinx/util/smartypants.py index 75888ea4d..f83f5689b 100644 --- a/sphinx/util/smartypants.py +++ b/sphinx/util/smartypants.py @@ -83,6 +83,7 @@ def sphinx_smarty_pants(t): # Constants for quote education. punct_class = r"""[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]""" +end_of_word_class = r"""[\s.,;:!?)]""" close_class = r"""[^\ \t\r\n\[\{\(\-]""" dec_dashes = r"""–|—""" @@ -117,8 +118,8 @@ opening_double_quotes_regex = re.compile(r""" closing_double_quotes_regex = re.compile(r""" #(%s)? # character that indicates the quote should be closing " - (?=\s) - """ % (close_class,), re.VERBOSE) + (?=%s) + """ % (close_class, end_of_word_class), re.VERBOSE) closing_double_quotes_regex_2 = re.compile(r""" (%s) # character that indicates the quote should be closing diff --git a/tests/test_build_html.py b/tests/test_build_html.py index a685fcb61..1911aabeb 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -172,7 +172,7 @@ HTML_XPATH = { (".//a[@href='#mod.Cls'][@class='reference internal']", ''), (".//dl[@class='userdesc']", ''), (".//dt[@id='userdesc-myobj']", ''), - (".//a[@href='#userdesc-myobj']", ''), + (".//a[@href='#userdesc-myobj'][@class='reference internal']", ''), # C references (".//span[@class='pre']", 'CFunction()'), (".//a[@href='#Sphinx_DoSomething']", ''),