Beispiel #1
0
    def find_obj(self, env, modname, classname, name, type, searchmode=0):
        """Ensures an object always resolves to the desired module
        if defined there."""
        orig_matches = PythonDomain.find_obj(self, env, modname, classname,
                                             name, type, searchmode)

        if len(orig_matches) <= 1:
            return orig_matches

        # If multiple matches, try to take the shortest if all the modules are
        # the same
        first_match_name_sp = orig_matches[0][0].split('.')
        base_name = first_match_name_sp[0]
        min_len = len(first_match_name_sp)
        best_match = orig_matches[0]

        for match in orig_matches[1:]:
            match_name = match[0]
            match_name_sp = match_name.split('.')
            match_base = match_name_sp[0]

            # If we have mismatched bases, return them all to trigger warnings
            if match_base != base_name:
                return orig_matches

            # Otherwise, check and see if it's shorter
            if len(match_name_sp) < min_len:
                min_len = len(match_name_sp)
                best_match = match

        return (best_match, )
Beispiel #2
0
 def find_obj(self, env, modname, classname, name, type, searchmode=0):
     """Ensures an object always resolves to laurelin.ldap.Object if defined there."""
     desired_name = _desired_base_module + '.' + name.strip('.')
     matches = PythonDomain.find_obj(self, env, modname, classname, name, type, searchmode)
     for match in matches:
         match_name = match[0]
         if match_name == desired_name:
             return [match]
     return matches
Beispiel #3
0
 def find_obj(self, env, modname, classname, name, type, searchmode=0):
     """Ensures an object always resolves to the desired module if defined there."""
     orig_matches = PythonDomain.find_obj(self, env, modname, classname, name, type, searchmode)
     matches = []
     for match in orig_matches:
         match_name = match[0]
         desired_name = "pulpcore.app.models." + name.strip('.')
         if match_name == desired_name:
             matches.append(match)
             break
     if matches:
         return matches
     else:
         return orig_matches
Beispiel #4
0
    def find_obj(self, env, modname, classname, name, type, searchmode=0):
        """
        Ensures an object always resolves to the desired module if defined
        there.

        See: https://github.com/sphinx-doc/sphinx/issues/3866
        """
        orig_matches = PythonDomain.find_obj(self, env, modname, classname, name, type, searchmode)
        matches = []
        for match in orig_matches:
            match_name = match[0]
            desired_name = 'osbrain' + '.' + name.strip('.')
            if match_name == desired_name:
                matches.append(match)
                break
        if matches:
            return matches
        else:
            return orig_matches
Beispiel #5
0
    def find_obj(self, env, modname, classname, name, type, searchmode=0):
        """
        Ensures an object always resolves to the desired module if defined
        there.

        See: https://github.com/sphinx-doc/sphinx/issues/3866
        """
        orig_matches = PythonDomain.find_obj(self, env, modname, classname,
                                             name, type, searchmode)
        matches = []
        for match in orig_matches:
            match_name = match[0]
            desired_name = 'osbrain' + '.' + name.strip('.')
            if match_name == desired_name:
                matches.append(match)
                break
        if matches:
            return matches
        else:
            return orig_matches
Beispiel #6
0
 def find_obj(self, env, modname, classname, name, type, searchmode=0):
     orig_matches = PythonDomain.find_obj(self, env, modname, classname,
                                          name, type, searchmode)
     # longest match is supposed to be original definition
     return sorted(orig_matches, key=lambda m: len(m[0]))[-1:]