From 50188b570ac3649d65b1c96dcf70a6a032573039 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 15 Jul 2018 18:29:23 +0900 Subject: [PATCH] Fix py domain: rtype field could not handle "None" as a type (refs: #4946) --- CHANGES | 1 + sphinx/domains/python.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index e67684297..f4eb39ce4 100644 --- a/CHANGES +++ b/CHANGES @@ -42,6 +42,7 @@ Bugs fixed * autosummary: warnings of autosummary indicates wrong location (refs: #5146) * #5143: autodoc: crashed on inspecting dict like object which does not support sorting +* #4946: py domain: rtype field could not handle "None" as a type Testing -------- diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 1d1f28b03..8067ce16c 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -148,7 +148,15 @@ class PyXrefMixin(object): class PyField(PyXrefMixin, Field): - pass + def make_xref(self, rolename, domain, target, + innernode=nodes.emphasis, contnode=None, env=None): + # type: (unicode, unicode, unicode, nodes.Node, nodes.Node, BuildEnvironment) -> nodes.Node # NOQA + if rolename == 'class' and target == 'None': + # None is not a type, so use obj role instead. + rolename = 'obj' + + return super(PyField, self).make_xref(rolename, domain, target, + innernode, contnode, env) class PyGroupedField(PyXrefMixin, GroupedField):