从命令行查找函数定义/签名。

FindFunc的Python项目详细描述


在源代码文件中查找并打印函数定义/签名。 它目前处理javascript、shell、python(类也是,因为 不管怎样,它们只是函数:smile:),和c-style函数 定义,以及makefile目标。它将突出 用于可读性的函数。

依赖关系

这些可以用pip

安装
NameDescription
colrTerminal colors.
docoptCommand line argument parsing.
printdebugDebug printing for command line tools.
pygmentsSource 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在多次运行时的输出 对于各种文件类型:

asciicast

我没有键入每个命令,而是编写了一个脚本来完成这项任务。所以 可能有点快。它正在运行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标志。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
html如何在JavaScript中获取当前Windows用户的名称   用于屏蔽电子邮件的java正则表达式   java Jsoup Android解析   为了避免在运行时缺少Java泛型,将超类型绑定到子类实例   java JTextArea。setText(空);不会释放内存   安卓源Java OutOfMemoryError在构建AOSP 10时出错   java打印到达数组末尾所需的最小跳数序列   使用mvn命令的java Selenium TestNG并行执行   javasocket编程:在关闭服务器之前通知所有客户端   java如何在加载新的安卓片段时显示progressbar?   java从actor系统中删除AKKA actor,并创建另一个具有相同路径名的actor   java我可以用浓缩咖啡做性能测试,还是应该用其他东西?   JavaTreeView(TreeItem)是否可以获取层次结构索引?   带远程服务的java Android应用程序