Do a keyword search on docstrings. A list of objects that matched the search is displayed, sorted by relevance. All given keywords need to be found in the docstring for it to be returned as a result, but the order does not matter. Parameters ---------- what : str
(what, module=None, import_modules=True, regenerate=False,
output=None)
| 753 | |
| 754 | @set_module('numpy') |
| 755 | def lookfor(what, module=None, import_modules=True, regenerate=False, |
| 756 | output=None): |
| 757 | """ |
| 758 | Do a keyword search on docstrings. |
| 759 | |
| 760 | A list of objects that matched the search is displayed, |
| 761 | sorted by relevance. All given keywords need to be found in the |
| 762 | docstring for it to be returned as a result, but the order does |
| 763 | not matter. |
| 764 | |
| 765 | Parameters |
| 766 | ---------- |
| 767 | what : str |
| 768 | String containing words to look for. |
| 769 | module : str or list, optional |
| 770 | Name of module(s) whose docstrings to go through. |
| 771 | import_modules : bool, optional |
| 772 | Whether to import sub-modules in packages. Default is True. |
| 773 | regenerate : bool, optional |
| 774 | Whether to re-generate the docstring cache. Default is False. |
| 775 | output : file-like, optional |
| 776 | File-like object to write the output to. If omitted, use a pager. |
| 777 | |
| 778 | See Also |
| 779 | -------- |
| 780 | source, info |
| 781 | |
| 782 | Notes |
| 783 | ----- |
| 784 | Relevance is determined only roughly, by checking if the keywords occur |
| 785 | in the function name, at the start of a docstring, etc. |
| 786 | |
| 787 | Examples |
| 788 | -------- |
| 789 | >>> np.lookfor('binary representation') # doctest: +SKIP |
| 790 | Search results for 'binary representation' |
| 791 | ------------------------------------------ |
| 792 | numpy.binary_repr |
| 793 | Return the binary representation of the input number as a string. |
| 794 | numpy.core.setup_common.long_double_representation |
| 795 | Given a binary dump as given by GNU od -b, look for long double |
| 796 | numpy.base_repr |
| 797 | Return a string representation of a number in the given base system. |
| 798 | ... |
| 799 | |
| 800 | """ |
| 801 | import pydoc |
| 802 | |
| 803 | # Cache |
| 804 | cache = _lookfor_generate_cache(module, import_modules, regenerate) |
| 805 | |
| 806 | # Search |
| 807 | # XXX: maybe using a real stemming search engine would be better? |
| 808 | found = [] |
| 809 | whats = str(what).lower().split() |
| 810 | if not whats: |
| 811 | return |
| 812 |