mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
use :class: as default role and only fall back to :obj: for singletons
This commit is contained in:
parent
f4817be7a9
commit
804df88e8d
@ -903,6 +903,10 @@ def _token_type(token):
|
||||
|
||||
def _convert_numpy_type_spec(_type, translations={}):
|
||||
def convert_obj(obj, translations, default_translation):
|
||||
# use :class: (the default) only if obj is not a standard singleton (None, True, False)
|
||||
if obj in (None, True, False) and default_translation == ":class:`{}`":
|
||||
default_translation = ":obj:`{}`"
|
||||
|
||||
return translations.get(obj, default_translation.format(obj))
|
||||
|
||||
tokens = _tokenize_type_spec(_type)
|
||||
@ -914,7 +918,7 @@ def _convert_numpy_type_spec(_type, translations={}):
|
||||
|
||||
# don't use the object role if it's not necessary
|
||||
default_translation = (
|
||||
":obj:`{}`"
|
||||
":class:`{}`"
|
||||
if not all(type_ == "obj" for _, type_ in types)
|
||||
else "{}"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user