flsouto/textract

本软件包最新版本(1.0.0)没有可用的许可证信息。

从php文件中提取并合并多行注释

1.0.0 2016-11-05 16:48 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:21:33 UTC


README

概述

此命令行工具允许您从php源文件中提取多行注释,生成包含所有匹配注释的字符串。此工具不会提取文档块,仅提取 /* 和 */ 之间的文本。

安装

您可以克隆此仓库或使用composer

composer require flsouto/textract

为了方便,我建议您为 "process" 脚本创建一个别名

alias textract='php /path/to/flsouto/textract/process.php'

用法

假设我们创建了两个包含多行注释的脚本

source1.php

<?php

/*
This line and
this other line
must be extracted
*/
function test(){
	return '';
}

/* 
This line should also be extracted
*/

source2.php

<?php

/*
More text from source2
*/

现在,如果我们从命令行运行textract

textract source1.php source2.php

我们会得到这个输出

This line and
this other line
must be extracted

This line should also be extracted

More text from source2

相反,我们可以这样写

textract source1.php source2.php > output.md

然后,输出将保存到output.md文件中。

最后思考

我使用这个工具从源代码本身生成文档,因为它可以大大加快这个过程。此外,如果您对这类工具感兴趣,您应该看看我创建的另一个工具,该工具允许您从源代码中提取代码片段,执行它们,并将代码片段和输出粘贴到markdown文档中:markdown-x