Generates `__all__` from the docstring of one or more modules. Usage: `make_all(__name__)` or `make_all(__name__, [sys.modules(__name__), other_module])`. The doc string modules must each a docstring, and `__all__` will contain all symbols with `@@` references, where that symbol currently e
(module_name, doc_string_modules=None)
| 28 | |
| 29 | |
| 30 | def make_all(module_name, doc_string_modules=None): |
| 31 | """Generates `__all__` from the docstring of one or more modules. |
| 32 | |
| 33 | Usage: `make_all(__name__)` or |
| 34 | `make_all(__name__, [sys.modules(__name__), other_module])`. The doc string |
| 35 | modules must each a docstring, and `__all__` will contain all symbols with |
| 36 | `@@` references, where that symbol currently exists in the module named |
| 37 | `module_name`. |
| 38 | |
| 39 | Args: |
| 40 | module_name: The name of the module (usually `__name__`). |
| 41 | doc_string_modules: a list of modules from which to take docstring. |
| 42 | If None, then a list containing only the module named `module_name` is used. |
| 43 | |
| 44 | Returns: |
| 45 | A list suitable for use as `__all__`. |
| 46 | """ |
| 47 | if doc_string_modules is None: |
| 48 | doc_string_modules = [_sys.modules[module_name]] |
| 49 | cur_members = set([name for name, _ |
| 50 | in _tf_inspect.getmembers(_sys.modules[module_name])]) |
| 51 | |
| 52 | results = set() |
| 53 | for doc_module in doc_string_modules: |
| 54 | results.update([m.group(1) |
| 55 | for m in _reference_pattern.finditer(doc_module.__doc__) |
| 56 | if m.group(1) in cur_members]) |
| 57 | return list(results) |
| 58 | |
| 59 | # Hidden attributes are attributes that have been hidden by |
| 60 | # `remove_undocumented`. They can be re-instated by `reveal_undocumented`. |
no test coverage detected