cvs: phpdoc /scripts switch-to-newstyle.php
| From: | Philip Olson | Date: | Mon, 15 Jan 2007 19:44:58 +0000 |
| Subject: | cvs: phpdoc /scripts switch-to-newstyle.php | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969374820@lists.php.net to get a copy of this message | ||
philip Mon Jan 15 19:44:58 2007 UTC
Modified files:
/phpdoc/scripts switch-to-newstyle.php
Log:
Added whitespace to output, a "already new doc style" check, and some stat info
http://cvs.php.net/viewvc.cgi/phpdoc/scripts/switch-to-newstyle.php?r1=1.2&r2=1.3&diff_format=u
Index: phpdoc/scripts/switch-to-newstyle.php
diff -u phpdoc/scripts/switch-to-newstyle.php:1.2 phpdoc/scripts/switch-to-newstyle.php:1.3
--- phpdoc/scripts/switch-to-newstyle.php:1.2 Mon Jan 15 03:11:59 2007
+++ phpdoc/scripts/switch-to-newstyle.php Mon Jan 15 19:44:58 2007
@@ -16,7 +16,7 @@
| Authors: Mehdi Achour <didou@php.net> |
+----------------------------------------------------------------------+
-$Id: switch-to-newstyle.php,v 1.2 2007/01/15 03:11:59 didou Exp $
+$Id: switch-to-newstyle.php,v 1.3 2007/01/15 19:44:58 philip Exp $
*/
if (PHP_SAPI !== 'cli') {
@@ -43,13 +43,21 @@
exit(1);
}
-
+$counts = array('old' => 0, 'new' => 0);
foreach (glob($fullpath_dir . "*.xml") as $file) {
+
$old = file_get_contents($file);
+
+ // Check if file is already using the new style and if so, skip it
+ if (false !== strpos($old, '<refsect1 role=')) {
+ $counts['new']++;
+ continue;
+ }
+
// Switch description and examples
$new = str_replace(
array('<refsect1>', '<title>Description</title>', "
</para>\n <para>\n <example>"),
- array('<refsect1 role="description">',
'&reftitle.description;', " </para>\n </refsect1>\n <refsect1
role=\"examples\">\n &reftitle.examples;\n <para>\n
<example>"),
+ array("\n".' <refsect1 role="description">',
'&reftitle.description;', " </para>\n </refsect1>\n\n <refsect1
role=\"examples\">\n &reftitle.examples;\n <para>\n
<example>"),
$old);
// Remove splitted from .. which doesn't make sense anymore
@@ -62,6 +70,7 @@
</para>
</refsect1>!',
' </refsect1>
+
<refsect1 role="seealso">
&reftitle.seealso;
<para>
@@ -80,6 +89,7 @@
preg_match_all('@<parameter>([^<]*)</parameter>@', $result[1],
$params);
if (count($params) && count($params[1])) {
$buffer = '</refsect1>
+
<refsect1 role="parameters">
&reftitle.parameters;
<para>
@@ -99,6 +109,7 @@
$buffer .= ' </variablelist>
</para>
</refsect1>
+
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
@@ -107,9 +118,18 @@
}
$new = preg_replace('!</refsect1>!', $buffer, $new, 1);
}
+
+ if ($new === $old) {
+ continue;
+ }
+ $counts['old']++;
$fp = fopen($file, 'w');
fputs($fp, $new);
fclose($fp);
}
+
+echo "Modified file information:\n";
+echo "Old --> New: {$counts['old']}\n";
+echo "Already New: {$counts['new']}\n";
\ No newline at end of file