Update of /cvsroot/phpweather/phpweather/docs/src
In directory usw-pr-cvs1:/tmp/cvs-serv19362
Added Files:
make-docs.sh php.ini phpdoc2latex.php
Log Message:
A shellscript, a phpscript and an inifile for PHP. Use these tools to
regenerate the documentation.
--- NEW FILE ---
#!/bin/bash
#
# Copyright 2001 Martin Geisler <[EMAIL PROTECTED]>
# You're free to use this as described in the GPL.
echo -n "Generating HTML and XML files... "
php4 -f ./../../../PHPDoc/PHPDoc.php > /dev/null
rm -f xml/*.xml
mv ../html/*.xml xml/
echo "done."
echo
echo -n "Generating LaTeX source... "
php4 -f phpdoc2latex.php xml/ latex/apidoc.tex
echo "done."
cd latex
echo
echo "Processing Dot files:"
echo -n " Making PostScript files... "
for file in *.dot; do
dot -Tps $file -o ${file%dot}ps
done
echo "done."
echo -n " Making PDF files... "
for file in *.ps; do
ps2pdf $file
done
echo "done."
echo
echo "Running LaTeX"
echo -n " to produce phpweather-a4.dvi... "
latex '\nonstopmode\input phpweather-a4.tex' > /dev/null
echo "done."
echo -n " to produce phpweather-letter.dvi... "
latex '\nonstopmode\input phpweather-letter.tex' > /dev/null
echo "done."
echo
echo -n "Making index... "
makeindex -q phpweather-a4
makeindex -q phpweather-letter
echo "done."
echo
echo "Rerunning LaTeX to incorporate index"
echo -n " into phpweather-a4.dvi... "
latex '\nonstopmode\input phpweather-a4.tex' > /dev/null
echo "done."
echo -n " into phpweather-letter.dvi... "
latex '\nonstopmode\input phpweather-letter.tex' > /dev/null
echo "done."
echo
echo "Final run of LaTeX to get references right"
echo -n " in phpweather-a4.dvi... "
latex '\nonstopmode\input phpweather-a4.tex' > /dev/null
echo "done."
echo -n " in phpweather-letter.dvi... "
latex '\nonstopmode\input phpweather-letter.tex' > /dev/null
echo "done."
echo
echo "Making PostScript files:"
echo -n " phpweather-a4.ps... "
dvips -q phpweather-a4.dvi -o
echo "done."
echo -n " phpweather-letter.ps... "
dvips -q -t letter phpweather-letter.dvi -o
echo "done."
echo "Compressing PostScript files"
echo -n " Making .gz files... "
cp phpweather-a4.ps phpweather-a4.ps.bak
cp phpweather-letter.ps phpweather-letter.ps.bak
gzip -f --best phpweather-a4.ps phpweather-letter.ps
echo "done."
echo -n " Making .bz2 files... "
cp phpweather-a4.ps.bak phpweather-a4.ps
cp phpweather-letter.ps.bak phpweather-letter.ps
bzip2 phpweather-a4.ps phpweather-letter.ps
echo "done."
echo -n " Making .zip files... "
cp phpweather-a4.ps.bak phpweather-a4.ps
cp phpweather-letter.ps.bak phpweather-letter.ps
zip -q phpweather-a4.ps.zip phpweather-a4.ps
zip -q phpweather-letter.ps.zip phpweather-letter.ps
echo "done."
echo -n "Moving PostScript files... "
mv phpweather-a4.ps.bak phpweather-a4.ps
mv phpweather-letter.ps.bak phpweather-letter.ps
mv phpweather-*.ps* ../../ps/
echo "done."
echo
echo "Making PDF files:"
echo -n " phpweather-a4.pdf... "
pdflatex '\nonstopmode\input phpweather-a4.tex' > /dev/null
pdflatex '\nonstopmode\input phpweather-a4.tex' > /dev/null
echo "done."
echo -n " phpweather-letter.pdf... "
pdflatex '\nonstopmode\input phpweather-letter.tex' > /dev/null
pdflatex '\nonstopmode\input phpweather-letter.tex' > /dev/null
echo "done."
echo "Compressing PDF files:"
echo -n " Making .gz files... "
cp phpweather-a4.pdf phpweather-a4.pdf.bak
cp phpweather-letter.pdf phpweather-letter.pdf.bak
gzip -f --best phpweather-a4.pdf phpweather-letter.pdf
echo "done."
echo -n " Making .bz2 files... "
cp phpweather-a4.pdf.bak phpweather-a4.pdf
cp phpweather-letter.pdf.bak phpweather-letter.pdf
bzip2 phpweather-a4.pdf phpweather-letter.pdf
echo "done."
echo -n " Making .zip files... "
cp phpweather-a4.pdf.bak phpweather-a4.pdf
cp phpweather-letter.pdf.bak phpweather-letter.pdf
zip -q phpweather-a4.pdf.zip phpweather-a4.pdf
zip -q phpweather-letter.pdf.zip phpweather-letter.pdf
echo "done."
echo -n "Moving PDF files... "
mv phpweather-a4.pdf.bak phpweather-a4.pdf
mv phpweather-letter.pdf.bak phpweather-letter.pdf
mv phpweather-*.pdf* ../../pdf/
echo "done."
echo
echo "Documentation has been generated."
--- NEW FILE ---
[PHP]
; $Id: php.ini,v 1.1 2001/07/12 19:54:01 gimpster Exp $
;;;;;;;;;;;;;;;;;;;
; About this file ;
;;;;;;;;;;;;;;;;;;;
; This file controls many aspects of PHP's behavior. In order for PHP to
; read it, it must be named 'php.ini'. PHP looks for it in the current
; working directory, in the path designated by the environment variable
; PHPRC, and in the path that was defined in compile time (in that order).
; Under Windows, the compile-time path is the Windows directory. The
; path in which the php.ini file is looked for can be overriden using
; the -c argument in command line mode.
;
; The syntax of the file is extremely simple. Whitespace and Lines
; beginning with a semicolon are silently ignored (as you probably guessed).
; Section headers (e.g. [Foo]) are also silently ignored, even though
; they might mean something in the future.
;
; Directives are specified using the following syntax:
; directive = value
; Directive names are *case sensitive* - foo=bar is different from FOO=bar.
;
; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one
; of the INI constants (On, Off, True, False, Yes, No and None) or an expression
; (e.g. E_ALL & ~E_NOTICE), or a quoted string ("foo").
;
; Expressions in the INI file are limited to bitwise operators and parentheses:
; | bitwise OR
; & bitwise AND
; ~ bitwise NOT
; ! boolean NOT
;
; Boolean flags can be turned on using the values 1, On, True or Yes.
; They can be turned off using the values 0, Off, False or No.
;
; An empty string can be denoted by simply not writing anything after the equal
; sign, or by using the None keyword:
;
; foo = ; sets foo to an empty string
; foo = none ; sets foo to an empty string
; foo = "none" ; sets foo to the string 'none'
;
; If you use constants in your value, and these constants belong to a
; dynamically loaded extension (either a PHP extension or a Zend extension),
; you may only use these constants *after* the line that loads the extension.
;
; All the values in the php.ini-dist file correspond to the builtin
; defaults (that is, if no php.ini is used, or if you delete these lines,
; the builtin defaults will be identical).
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; We don't want these HTML errors
html_errors = Off
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2"
include_path = ".:/usr/share/pear/"
--- NEW FILE ---
#!/usr/bin/php4 -q
<?php
/* You should run this script from the commandline. But it's also easy
to adapt it to run on a webserver. */
if ($argc == 3 && is_dir($argv[1]) && is_writable(dirname($argv[2]))) {
parse_files($argv[1], $argv[2]);
} else {
die ("Usage: phpdoc2latex.php xml_dir output_file\n");
}
function out($str) {
global $output, $output_type, $output_name;
$output[$output_type][$output_name] .= $str;
}
function push($tag) {
global $stack;
array_push($stack, $tag);
}
function pop() {
global $stack;
if (empty($stack)) {
return array();
} else {
return array_pop($stack);
}
}
function escape($str) {
/* This marks the variables. */
$str =
ereg_replace('(&?\$)([\'a-zA-Z_][a-zA-Z0-9_]*(\['[\'a-zA-Z_][a-zA-Z0-9_]*'\])?)',
'\variable{\1}{\2}', $str);
/* This takes care of functions. */
$str = ereg_replace('([a-zA-Z_][a-zA-Z0-9_]*)\(\)',
'\function{\1}', $str);
/* This converts ASCII double quotes into LaTeX double quotes. */
$str = ereg_replace('"([^&]+)"', "``\\1''", $str);
/* This converts ASCII single quotes into LaTeX single quotes. */
$str = ereg_replace(''([^&]+)'', "`\\1'", $str);
/* This converts the remaining special characters. */
$str = str_replace(array('_',
'$',
''',
'...',
'=>',
'<=',
'<',
'>',
'&'),
array('\_',
'\$',
"'",
'\ldots',
'\ensuremath{\Rightarrow}',
'\ensuremath{\Leftarrow}',
'\ensuremath{<}',
'\ensuremath{>}',
'\&'),
$str);
return $str;
}
function tag_open($parser, $tag, $attributes = '') {
global $class, $function, $context;
switch ($tag) {
case 'CLASS':
$context = 'CLASS';
$class = $attributes;
echo "%%%%%%%%%%%%%%%%\n% Start of class " . $attributes['NAME'] . ".\n\n";
echo '\section{\class{' . escape($attributes['NAME']) . "}}\n\n";
echo '\begin{figure}[!hb]' . "\n";
echo '\centering' . "\n";
echo '\includegraphics{' . $attributes['NAME'] . "}\n";
echo '\caption{The relationship between \class{' .
escape($attributes['NAME']) . "} and other classes.}\n";
echo '\end{figure}' . "\n\n";
break;
case 'FUNCTION':
$function = array('name' => $attributes['NAME'],
'access' => $attributes['ACCESS']);
$context = 'FUNCTION';
break;
default:
push(array('name' => $tag,
'attributes' => $attributes));
break;
}
}
function cdata($parser, $cdata) {
$tag = pop();
$tag['cdata'] .= $cdata;
push($tag);
}
function tag_close($parser, $tag) {
global $class, $function, $parameters, $context,
$output, $output_type, $output_name;
switch($tag) {
case 'DOC':
pop();
break;
case 'FILE':
$tag = pop();
$class['filename'] = str_replace('../phpweather',
'PHPWEATHER_BASE_DIR',
$tag['cdata']);
break;
case 'AUTHOR':
$tag = pop();
if ($context == 'CLASS') {
$class['author']['name'] = $tag['cdata'];
$class['author']['email'] = $tag['attributes']['EMAIL'];
} elseif ($context == 'FUNCTION') {
$function['author']['name'] = $tag['cdata'];
$function['author']['email'] = $tag['attributes']['EMAIL'];
}
break;
case 'DESCRIPTION':
$tag = pop();
if ($context == 'CLASS') {
$class['description'] = $tag['cdata'];
} elseif ($context == 'FUNCTION') {
$function['description'] = $tag['cdata'];
}
break;
case 'SHORTDESCRIPTION':
$tag = pop();
if ($context == 'CLASS') {
$class['shortdescription'] = $tag['cdata'];
} elseif ($context == 'FUNCTION') {
$function['shortdescription'] = $tag['cdata'];
}
break;
case 'VERSION':
$tag = pop();
$class['version'] = $tag['cdata'];
break;
case 'PARAMETER':
$tag = pop();
$parameters[] =
array('name' => substr(strrchr($tag['attributes']['NAME'], '$'), 1),
'type' => $tag['attributes']['TYPE'],
'description' => $tag['cdata'],
'prefix' => substr($tag['attributes']['NAME'], 0,
strspn($tag['attributes']['NAME'], '&$')));
break;
case 'FUNCTION':
/*
echo "% \$function:\n";
print_r($function);
echo "% \$parameters:\n";
print_r($parameters);
*/
$output_type = 'function';
$output_name = $function['name'];
out("%%%%%%%%\n% Start of function " . $function['name'] . "\n\n");
out('\subsection{\function{' . escape($function['name']) . "}}\n\n");
out(wordwrap(escape($function['shortdescription'])) . "\n\n");
if (!empty($function['description'])) {
out(wordwrap(escape($function['description'])) . "\n\n");
}
out('\begin{funcdesc}' . "\n\n");
/* The function definition comes next */
out(wordwrap('\item[Definition] \functiondef{' .
$function['access'] . ' ' .
$function['return']['type'] . ' ' .
escape($function['name']) . '('));
if (!empty($parameters)) {
reset($parameters);
list($key, $parameter) = each($parameters);
out($parameter['type'] . ' ' .
escape($parameter['prefix'] . $parameter['name']));
while (list($key, $parameter) = each($parameters)) {
out(', ' . $parameter['type'] . ' ' .
escape($parameter['prefix'] . $parameter['name']));
}
} else {
out('void');
}
out(")}\n\n");
/* Then comes the parameters */
if (!empty($parameters)) {
if (count($parameters) == 1) {
out(wordwrap('\item[Parameters] \textbf{' . $parameters[0]['type'] . ' ' .
escape($parameters[0]['prefix'] . $parameters[0]['name']) . '} ' .
escape($parameters[0]['description']) . "\n\n"));
} else {
out('\item[Parameters]\mbox{}' . "\n\n");
out('\begin{description}' . "\n\n");
reset($parameters);
while (list($k, $parameter) = each($parameters)) {
out(wordwrap('\item[' . $parameter['type'] . ' ' .
escape($parameter['prefix'] . $parameter['name']) . '] ' .
escape($parameter['description']) . "\n\n"));
}
out('\end{description}' . "\n\n");
}
/* We have to clear the parameters for the next function. */
unset($GLOBALS['parameters']);
}
/* Now comes the return value */
out('\item[Return value] ');
out(wordwrap('\textbf{' . $function['return']['type'] . '}\hspace{\labelsep} ' .
escape($function['return']['description']) . "\n\n"));
/* Last comes the 'See also' part */
if (!empty($function['seealso'])) {
out('\item[See also] ');
list($k, $seealso) = each($function['seealso']);
out(escape($seealso['name']));
while (list($k, $seealso) = each($function['seealso'])) {
out(', ' . escape($seealso['name']));
}
out(".\n\n");
}
out('\end{funcdesc}' . "\n\n");
out('% End of function ' . $function['name'] . "()\n%%%%%%%%\n\n\n");
break;
case 'CLASS':
echo wordwrap(escape($class['shortdescription'])) . "\n\n";
echo wordwrap(escape($class['description'])) . "\n\n";
echo '\begin{description}' . "\n\n";
echo wordwrap('\item[Definition] \classdef{' . $class['ACCESS'] .
' class ' . escape($class['NAME']));
if (empty($class['EXTENDS'])) {
echo "}\n\n";
} else {
echo ' extends ' . escape($class['EXTENDS']) . "}\n\n";
}
echo '\item[Author] ' . escape($class['author']['name']) .
' \email{' . $class['author']['email'] . "}\n\n";
echo '\item[Version] ' . escape($class['version']) . "\n\n";
echo '\item[Filename] \filename{' . $class['filename'] . "}\n\n";
echo '\end{description}' . "\n\n";
reset($output['function']);
while(list($k, $function) = each($output['function'])) {
echo $function;
}
echo '% End of class ' . $class['NAME'] .
".\n%%%%%%%%%%%%%%%%\n\n";
break;
/* Return value tag. There can only be one of these. */
case 'RETURN':
$tag = pop();
$function['return']['type'] = $tag['attributes']['TYPE'];
if (!empty($tag['cdata'])) {
$function['return']['description'] = $tag['cdata'];
}
break;
/* See also tag. There might be several of these. */
case 'SEE':
$tag = pop();
$type = $tag['attributes']['TYPE'];
$function['seealso'][] = array('type' => $type,
'name' => $tag['cdata']);
break;
}
}
function make_dot_file($class, $output_dir) {
global $tree, $baseclass;
if (!($fp = fopen("$output_dir/$class.dot", 'w'))) {
return false;
}
fputs($fp, "digraph $class {\n");
fputs($fp, " node [fontname = \"Palatino-Roman\", fontsize = 10];\n");
fputs($fp, " class [label=\"$class\", color=blue];\n");
if ($class != $baseclass) {
reset($tree);
while (list($a_class, $subclasses) = each($tree)) {
if (in_array($class, $subclasses)) {
fputs($fp, " $a_class -> class;\n");
break;
}
}
}
if (!empty($tree[$class])) {
fputs($fp, " class -> { ");
for ($i = 0; $i < count($tree[$class]); $i++) {
fputs($fp, $tree[$class][$i] . ' ');
}
fputs($fp, "}\n");
}
fputs($fp, "}\n");
fclose($fp);
}
function parse_file($xml_file) {
/* We start by resetting the global variables. */
$GLOBALS['stack'] = array();
$GLOBALS['output'] = '';
$GLOBALS['output_type'] = '';
$GLOBALS['output_name'] = '';
$GLOBALS['function'] = '';
$GLOBALS['class'] = '';
if (!($fp = fopen($xml_file, 'r'))) {
die("Could not open $xml_file for parsing!\n");
}
$data = '';
while (!feof($fp)) {
$data .= fread($fp, 4096);
}
fclose($fp);
$parser = xml_parser_create();
xml_set_element_handler($parser, 'tag_open', 'tag_close');
xml_set_character_data_handler($parser, 'cdata');
xml_parse($parser, $data);
xml_parser_free($parser);
}
function parse_files($xml_dir, $output_file) {
global $classes, $tree;
function classtree_tag_open($parser, $tag, $attributes = '') {
global $baseclass, $current_class;
//echo "Opening $tag\n\n";
switch($tag) {
case 'CLASS':
$current_class = $attributes['NAME'];
break;
case 'CLASSTREE':
$baseclass = $attributes['BASECLASS'];
break;
}
}
function classtree_tag_close($parser, $tag) {
global $baseclass;
if ($tag == 'CLASSTREE') {
/* We're done. */
//unset($GLOBALS['tree']);
find_subclasses($baseclass);
}
}
function find_subclasses($class) {
global $classes, $tree;
$classes[] = $class;
if (!empty($tree[$class])) {
while (list($k, $subclass) = each($tree[$class])) {
find_subclasses($subclass);
}
}
}
function classtree_cdata($parser, $cdata) {
global $tree, $current_class;
$tree[$current_class][] = $cdata;
}
if (!($fp = fopen("$xml_dir/classtree_base_object.xml", 'r'))) {
die("Could not open $xml_dir/classtree_base_object.xml for parsing!\n");
}
$data = '';
while (!feof($fp)) {
$data .= fread($fp, 4096);
}
fclose($fp);
$classtree_parser = xml_parser_create();
xml_set_element_handler($classtree_parser,
'classtree_tag_open',
'classtree_tag_close');
xml_set_character_data_handler($classtree_parser,
'classtree_cdata');
xml_parse($classtree_parser, $data);
xml_parser_free($classtree_parser);
ob_start();
echo '\chapter{API Documentation}' . "\n\n";
echo wordwrap('The following information has been generated from the doc-comments
found in the sources for \phpw.') . "\n\n";
while (list($k, $class) = each($classes)) {
make_dot_file($class, dirname($output_file));
parse_file("$xml_dir/class_$class.xml");
}
if (!($fp = fopen($output_file, 'w'))) {
die("Could not open $output_file for writing!\n");
} else {
fputs($fp, ob_get_contents());
fclose($fp);
ob_end_clean();
}
}
?>
_______________________________________________
PHPWeather-checkins mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/phpweather-checkins