PHPDocTester – console script for evaluating your PHPDoc comments

If you are fan of command line like me and do some PHP coding in console or simply keep console constantly opened than this script could be useful for you for quick evaluation of PHPDoc documentation generated for your PHP.

This script will generate PHPDoc documentation saving all files into temporary folder, display them in elinks console web browser and clear temporary folder after leaving browser. Script expects “elinks” and “phpdoc” to be installed on your system.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
PATH=/bin:/usr/bin:
 
# check input parameters
if [ "$#" -lt 1 ]; then
    echo "Usage:"
    echo "`basename $0` filename/dirname [options]"
    exit 1
fi
 
# create temporary directory
TARGET=`mktemp -dt phpdoctester.XXXXXX`
FILE=$1
 
# check if input is directory, otherwise assume it's file or filemask
if [ -d "$FILE" ]; then
    FCONFDIR="--directory"
else
    FCONFDIR="--filename"
fi
 
# create phpdoc documentation in temporary directory
phpdoc \
	$FCONFDIR "$FILE" \
	--target "$TARGET" \
	--parseprivate on \
	--undocumentedelements on \
	--output HTML:frames:default \
	|
	grep -P 'ERROR in |WARNING in ' \
	|
	sed -e 's/^\s*\(.*\)/\1/'
 
echo "\nPress any key to open phpdoc in console web browser..."
read
 
# show documentation in console browser
DOCFILE="${TARGET}/index.html"
elinks $DOCFILE 
 
# remove temporary directory
rm -r $TARGET

Leave a Reply