@@ -362,27 +362,27 @@ def make_xref(self, rolename: str, domain: str, target: str,
362362 result = super ().make_xref (rolename , domain , target , # type: ignore
363363 innernode , contnode ,
364364 env , inliner = None , location = None )
365- result [ 'refspecific' ] = True
366- result ['py:module ' ] = env . ref_context . get ( 'py:module' )
367- result ['py:class ' ] = env .ref_context .get ('py:class ' )
368- if target . startswith (( '.' , '~' )):
369- prefix , result [ 'reftarget' ] = target [ 0 ], target [ 1 :]
370- if prefix == '.' :
371- text = target [ 1 :]
372- elif prefix == '~' :
373- text = target . split ( '.' )[ - 1 ]
374- for node in list ( result . traverse ( nodes . Text )):
375- node . parent [ node . parent . index ( node )] = nodes . Text ( text )
376- break
377- elif isinstance ( result , pending_xref ) and env .config .python_use_unqualified_type_names :
378- children = result .children
379- result .clear ()
380-
381- shortname = target .split ('.' )[- 1 ]
382- textnode = innernode ('' , shortname )
383- contnodes = [pending_xref_condition ('' , '' , textnode , condition = 'resolved' ),
384- pending_xref_condition ('' , '' , * children , condition = '*' )]
385- result .extend (contnodes )
365+ if isinstance ( result , pending_xref ):
366+ result ['refspecific ' ] = True
367+ result ['py:module ' ] = env .ref_context .get ('py:module ' )
368+ result [ 'py:class' ] = env . ref_context . get ( 'py:class' )
369+
370+ reftype , reftarget , reftitle , _ = parse_reftarget ( target )
371+ if reftarget != reftitle :
372+ result [ 'reftype' ] = reftype
373+ result [ 'reftarget' ] = reftarget
374+
375+ result . clear ( )
376+ result += innernode ( reftitle , reftitle )
377+ elif env .config .python_use_unqualified_type_names :
378+ children = result .children
379+ result .clear ()
380+
381+ shortname = target .split ('.' )[- 1 ]
382+ textnode = innernode ('' , shortname )
383+ contnodes = [pending_xref_condition ('' , '' , textnode , condition = 'resolved' ),
384+ pending_xref_condition ('' , '' , * children , condition = '*' )]
385+ result .extend (contnodes )
386386
387387 return result
388388
@@ -415,33 +415,15 @@ def make_xrefs(self, rolename: str, domain: str, target: str,
415415
416416
417417class PyField (PyXrefMixin , Field ):
418- def make_xref (self , rolename : str , domain : str , target : str ,
419- innernode : Type [TextlikeNode ] = nodes .emphasis ,
420- contnode : Node = None , env : BuildEnvironment = None ,
421- inliner : Inliner = None , location : Node = None ) -> Node :
422- if rolename == 'class' and target == 'None' :
423- # None is not a type, so use obj role instead.
424- rolename = 'obj'
425-
426- return super ().make_xref (rolename , domain , target , innernode , contnode ,
427- env , inliner , location )
418+ pass
428419
429420
430421class PyGroupedField (PyXrefMixin , GroupedField ):
431422 pass
432423
433424
434425class PyTypedField (PyXrefMixin , TypedField ):
435- def make_xref (self , rolename : str , domain : str , target : str ,
436- innernode : Type [TextlikeNode ] = nodes .emphasis ,
437- contnode : Node = None , env : BuildEnvironment = None ,
438- inliner : Inliner = None , location : Node = None ) -> Node :
439- if rolename == 'class' and target == 'None' :
440- # None is not a type, so use obj role instead.
441- rolename = 'obj'
442-
443- return super ().make_xref (rolename , domain , target , innernode , contnode ,
444- env , inliner , location )
426+ pass
445427
446428
447429class PyObject (ObjectDescription [Tuple [str , str ]]):
0 commit comments