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

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第三方库


热门话题
java Android ListView显示的数字不超过8位   java什么导致警告“Classpath entry/XXX/XXX.jar将不会导出或发布。可能会导致运行时ClassNotFoundException。”   java使用Spring容器在非Spring对象上调用方法,允许参数连接?   java Android:当另一个手指已经在触摸屏幕时,是否可以处理一次点击?   java Veil加载JFrame上的图像或加载面板   JavaSpring没有为Redis缓存上的记录设置过期时间   java异常:SparkException:任务不可序列化   java Android studio用户注册数据未插入firebase数据库   java在StackPane中的区域图上覆盖节点   java获取活动UI的“会话已过期”消息   java组织。冬眠MappingNotFoundException:资源:*hbm。找不到xml   java Mockito mock在尝试存根包保护的方法时调用实方法实现