diff options
author | Jakob Lykke Andersen <Jakob@caput.dk> | 2021-05-29 11:22:39 +0300 |
---|---|---|
committer | Jakob Lykke Andersen <Jakob@caput.dk> | 2021-06-03 17:36:37 +0300 |
commit | d5598b363e0fe5262893792ff4a865f59ba92962 (patch) | |
tree | a989be78efeb690e9cffbedddd66428237b7b381 /sphinx/util | |
parent | ec9d578ed35fd158a17cadb4852b989198204f91 (diff) |
DocFields, small fixes
Diffstat (limited to 'sphinx/util')
-rw-r--r-- | sphinx/util/docfields.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py index 39199b3b1..49ee26789 100644 --- a/sphinx/util/docfields.py +++ b/sphinx/util/docfields.py @@ -16,6 +16,7 @@ from docutils.parsers.rst.states import Inliner from sphinx import addnodes from sphinx.environment import BuildEnvironment +from sphinx.locale import __ from sphinx.util import logging from sphinx.util.typing import TextlikeNode @@ -72,22 +73,18 @@ class Field: assert (inliner is None) == (location is None), (inliner, location) if not rolename: return contnode or innernode(target, target) + # The domain is passed from DocFieldTransformer. So it surely exists. + # So we don't need to take care the env.get_domain() raises an exception. role = env.get_domain(domain).role(rolename) if role is None or inliner is None: if role is None and inliner is not None: msg = "Problem in %s domain: field is supposed " msg += "to use role '%s', but that role is not in the domain." - logger.warning(msg, domain, rolename, location=location) - if inliner is None: - # msg = "Field for %s domain using role '%s' does not run the role." - # msg += " No inliner provided." - # logger.warning(msg, domain, rolename) - pass + logger.warning(__(msg), domain, rolename, location=location) refnode = addnodes.pending_xref('', refdomain=domain, refexplicit=False, reftype=rolename, reftarget=target) refnode += contnode or innernode(target, target) - if env: - env.get_domain(domain).process_field_xref(refnode) + env.get_domain(domain).process_field_xref(refnode) return refnode lineno = logging.get_source_line(location)[1] ns, messages = role(rolename, target, target, lineno, inliner, {}, []) |