MCPcopy Index your code
hub / github.com/numpy/numpy / find_names

Function find_names

tools/refguide_check.py:136–187  ·  view source on GitHub ↗

Finds the occurrences of function names, special directives like data and functions and scipy constants in the docstrings of `module`. The following patterns are searched for: * 3 spaces followed by function name, and maybe some spaces, some dashes, and an explanation; only f

(module, names_dict)

Source from the content-addressed store, hash-verified

134
135
136def find_names(module, names_dict):
137 """
138 Finds the occurrences of function names, special directives like data
139 and functions and scipy constants in the docstrings of `module`. The
140 following patterns are searched for:
141
142 * 3 spaces followed by function name, and maybe some spaces, some
143 dashes, and an explanation; only function names listed in
144 refguide are formatted like this (mostly, there may be some false
145 positives
146 * special directives, such as data and function
147 * (scipy.constants only): quoted list
148
149 The `names_dict` is updated by reference and accessible in calling method
150
151 Parameters
152 ----------
153 module : ModuleType
154 The module, whose docstrings is to be searched
155 names_dict : dict
156 Dictionary which contains module name as key and a set of found
157 function names and directives as value
158
159 Returns
160 -------
161 None
162 """
163 patterns = [
164 r"^\s\s\s([a-z_0-9A-Z]+)(\s+-+.*)?$",
165 r"^\.\. (?:data|function)::\s*([a-z_0-9A-Z]+)\s*$"
166 ]
167
168 if module.__name__ == 'scipy.constants':
169 patterns += ["^``([a-z_0-9A-Z]+)``"]
170
171 patterns = [re.compile(pattern) for pattern in patterns]
172 module_name = module.__name__
173
174 for line in module.__doc__.splitlines():
175 res = re.search(r"^\s*\.\. (?:currentmodule|module):: ([a-z0-9A-Z_.]+)\s*$",
176 line)
177 if res:
178 module_name = res.group(1)
179 continue
180
181 for pattern in patterns:
182 res = re.match(pattern, line)
183 if res is not None:
184 name = res.group(1)
185 entry = f'{module_name}.{name}'
186 names_dict.setdefault(module_name, set()).add(name)
187 break
188
189
190def get_all_dict(module):

Callers 1

mainFunction · 0.85

Calls 3

splitlinesMethod · 0.80
compileMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…