Chris, On Wednesday June 25, 2003 03:44, Chris W. Parker wrote: > Hello. > > I'm looking to make a source code documenting program and instead of > reinventing the wheel* I'd like to use a ready made wheel so to speak. Are > there any libraries out there (I am guessing maybe in C or Perl) that > recognize PHP and know what's what? That is, if I fed it a string or a > complete page of source code I would like to be albe to know the names of > all the functions and the names of all the variables. > > Any ideas?
If you mean something like Javadoc does for Java code, then you are already done and it's called PHPDoc. http://www.phpdoc.de/ If you mean something that simply extracts the obvious stuff (you shouldn't need to "document" the existing PHP functions, only the ones you create), then use the below (modify to your heart's content). #!/bin/bash # Filename : phpscan.sh # Usage : phpscan.sh <filename> # Check that filename was provided if [ $# -eq 0 ]; then echo "No file name provided" echo "Usage : `basename $0` <filename>" exit 65 fi # Check that file exists if [ ! -e "$1" ]; then echo "File does not exist" exit 1 fi # First scan for functions. We're looking for where they are defined FUNCTIONS=`grep function $1 | sort | uniq` # Then scan for variables. We're looking for assignment. VARIABLES=`grep -o -e "\$.*=" $1 | cut -d " " -f 1 | sort | uniq` #Show Function list echo "The functions are :" for fun in $FUNCTIONS do if [ "$fun" = function ]; then echo continue fi echo -n $fun done #Show Variables list echo echo "The variables are :" for var in $VARIABLES do echo $var done exit 0 -- Brian Ashe CTO Dee-Web Software Services, LLC. [EMAIL PROTECTED] http://www.dee-web.com/ -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://www.redhat.com/mailman/listinfo/redhat-list