Wallogit.com
2017 © Pedro Peláez
Extracts and combines multiline comments from php files
This command line tool allows you to extract multiline comments from php source files producing a string with all matched comments. This will not extract doc blocks, only texts between /* and */., (*1)
Either clone this repo or use composer:, (*2)
composer require flsouto/textract
For convenience I recommend you create an alias to the "process" script:, (*3)
alias textract='php /path/to/flsouto/textract/process.php'
Say we have created two scripts containing multiline comments:, (*4)
source1.php:, (*5)
<?php
/*
This line and
this other line
must be extracted
*/
function test(){
return '';
}
/*
This line should also be extracted
*/
source2.php:, (*6)
<?php /* More text from source2 */
Now, if we run textract from the command line:, (*7)
textract source1.php source2.php
We get this output:, (*8)
This line and this other line must be extracted This line should also be extracted More text from source2
Instead, we could write:, (*9)
textract source1.php source2.php > output.md
And we would have the output saved to the output.md file., (*10)
I use this utility for producing documentations out of the source code itself because I think it speeds up the process a lot. Also, if you are interested in this kind of thing, you should take a look at this other utility I created which allows you to extract snippets from your source code, execute them, and paste both the snippet and output in your markdown documentation: markdown-x, (*11)