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)
| 180 | |
| 181 | |
| 182 | def find_names(module, names_dict): |
| 183 | """ |
| 184 | Finds the occurrences of function names, special directives like data |
| 185 | and functions and scipy constants in the docstrings of `module`. The |
| 186 | following patterns are searched for: |
| 187 | |
| 188 | * 3 spaces followed by function name, and maybe some spaces, some |
| 189 | dashes, and an explanation; only function names listed in |
| 190 | refguide are formatted like this (mostly, there may be some false |
| 191 | positives |
| 192 | * special directives, such as data and function |
| 193 | * (scipy.constants only): quoted list |
| 194 | |
| 195 | The `names_dict` is updated by reference and accessible in calling method |
| 196 | |
| 197 | Parameters |
| 198 | ---------- |
| 199 | module : ModuleType |
| 200 | The module, whose docstrings is to be searched |
| 201 | names_dict : dict |
| 202 | Dictionary which contains module name as key and a set of found |
| 203 | function names and directives as value |
| 204 | |
| 205 | Returns |
| 206 | ------- |
| 207 | None |
| 208 | """ |
| 209 | patterns = [ |
| 210 | r"^\s\s\s([a-z_0-9A-Z]+)(\s+-+.*)?$", |
| 211 | r"^\.\. (?:data|function)::\s*([a-z_0-9A-Z]+)\s*$" |
| 212 | ] |
| 213 | |
| 214 | if module.__name__ == 'scipy.constants': |
| 215 | patterns += ["^``([a-z_0-9A-Z]+)``"] |
| 216 | |
| 217 | patterns = [re.compile(pattern) for pattern in patterns] |
| 218 | module_name = module.__name__ |
| 219 | |
| 220 | for line in module.__doc__.splitlines(): |
| 221 | res = re.search(r"^\s*\.\. (?:currentmodule|module):: ([a-z0-9A-Z_.]+)\s*$", line) |
| 222 | if res: |
| 223 | module_name = res.group(1) |
| 224 | continue |
| 225 | |
| 226 | for pattern in patterns: |
| 227 | res = re.match(pattern, line) |
| 228 | if res is not None: |
| 229 | name = res.group(1) |
| 230 | entry = '.'.join([module_name, name]) |
| 231 | names_dict.setdefault(module_name, set()).add(name) |
| 232 | break |
| 233 | |
| 234 | |
| 235 | def get_all_dict(module): |
no test coverage detected