def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode): objects = self.data['objects'] package = node.get('java:package') imported = node.get('java:imported') type_context = node.get('java:outertype') # Partial function to make building the response easier make_ref = lambda fullname: make_refnode(builder, fromdocname, objects[ fullname][0], fullname, contnode, fullname) # Check for fully qualified references if target in objects: return make_ref(target) # Try with package name prefixed if package: fullname = package + '.' + target if fullname in objects: return make_ref(fullname) # Try with package and type prefixed if package and type_context: fullname = package + '.' + type_context + '.' + target if fullname in objects: return make_ref(fullname) # Try to find a matching suffix suffix = '.' + target basename_match = None basename_suffix = suffix.partition('(')[0] for fullname, (_, _, basename) in objects.items(): if fullname.endswith(suffix): return make_ref(fullname) elif basename.endswith(basename_suffix): basename_match = fullname if basename_match: return make_ref(basename_match) # Try creating an external documentation reference ref = extdoc.get_javadoc_ref(self.env, target, target) if not ref and target in java_dot_lang: fulltarget = 'java.lang.' + target ref = extdoc.get_javadoc_ref(self.env, fulltarget, fulltarget) # If the target was imported try with the package prefixed if not ref and imported: fulltarget = package + '.' + target ref = extdoc.get_javadoc_ref(self.env, fulltarget, fulltarget) if ref: ref.append(contnode) return ref else: return None
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode): objects = self.data['objects'] package = node.get('java:package') imported = node.get('java:imported') type_context = node.get('java:outertype') # Partial function to make building the response easier make_ref = lambda fullname: make_refnode(builder, fromdocname, objects[fullname][0], fullname, contnode, fullname) # Check for fully qualified references if target in objects: return make_ref(target) # Try with package name prefixed if package: fullname = package + '.' + target if fullname in objects: return make_ref(fullname) # Try with package and type prefixed if package and type_context: fullname = package + '.' + type_context + '.' + target if fullname in objects: return make_ref(fullname) # Try to find a matching suffix suffix = '.' + target basename_match = None basename_suffix = suffix.partition('(')[0] for fullname, (_, _, basename) in objects.items(): if fullname.endswith(suffix): return make_ref(fullname) elif basename.endswith(basename_suffix): basename_match = fullname if basename_match: return make_ref(basename_match) # Try creating an external documentation reference ref = extdoc.get_javadoc_ref(self.env, target, target) if not ref and target in java_dot_lang: fulltarget = 'java.lang.' + target ref = extdoc.get_javadoc_ref(self.env, fulltarget, fulltarget) # If the target was imported try with the package prefixed if not ref and imported: fulltarget = package + '.' + target ref = extdoc.get_javadoc_ref(self.env, fulltarget, fulltarget) if ref: ref.append(contnode) return ref else: return None