从命令行查找函数定义/签名。
FindFunc的Python项目详细描述
在源代码文件中查找并打印函数定义/签名。 它目前处理javascript、shell、python(类也是,因为 不管怎样,它们只是函数:smile:),和c-style函数 定义,以及makefile目标。它将突出 用于可读性的函数。
依赖关系
这些可以用pip:
安装Name | Description |
---|---|
colr | Terminal colors. |
docopt | Command line argument parsing. |
printdebug | Debug printing for command line tools. |
pygments | Source code highlighting. |
安装:
这个包列在pypi上,可以用pip:
安装pip install findfunc
用法
Usage: findfunc -h | -v findfunc PAT -p [-a] [--color] [-D] [-S] [-s] [-c pat] [-C pat] [-e pat] [-f pat] [-l num] [-m num] findfunc PAT [PATH...] [-a] [--color] [-D] [-S] [-s] [-c pat] [-C pat] [-e pat] [-f pat] [-l num] [-m num] Options: PATH : Zero or more file paths to search. If the path is a directory it will be walked. Default: stdin PAT : Function name or regex pattern to search for. -a,--any : Matches anywhere in the name. This is the same as: (.+?pattern|pattern.+?) --color : Always use color. -c pat,--contains pat : Only show definitions that contain this pattern in the body. -C pat,--without pat : Only show definitions that do not contain this pattern in the body. This cancels out any -c pattern. -D,--debug : Print some debugging info while running. -e pat,--exclude pat : Regex pattern to exclude file paths. -f pat,--filter pat : Regex pattern to include file paths. -h,--help : Show this help message. -l num,--length num : Show definitions that match this line length. Tests can be prepended: >N : More than N lines. <N : Less than N lines. >=N : More than or equal to N lines. <=N : Less than or equal to N lines. =N : Exactly N lines. ==N : Exactly N lines. N : Exactly N lines. -m num,--maxcount num : Maximum number of definitions to show. -p,--paths : Search all directories found in the config file. -S,--signature : Just print the signatures found. -s,--short : Use shorter output mode. -v,--version : Show version. Any file with a name like '[Mm]akefile' will trigger makefile-mode. Unfortunately that mode doesn't work for stdin data. JSON config can be loaded from: ~/findfunc.json
演示
下面是一个记录,显示了findfunc在多次运行时的输出 对于各种文件类型:
我没有键入每个命令,而是编写了一个脚本来完成这项任务。所以 可能有点快。它正在运行findfunc PATTERN DIR_OR_FILE 有或没有--maxcount或--signature标志集。
配置
config是一个json文件,可以从CWD加载, ~/findfunc.json,或~/.local/share/findfunc.json。
格式是:
{"default_paths":["my_dir1","my_file1","/home/me/scripts"]}
default_paths是要在以下情况下搜索的目录或文件路径的列表 给出了-p标志。