cvs: php-gtk-doc /updater firstOutput updateMethods.php

[email protected] ("Christian Weiske")
Newsgroups php.gtk.doc
Message-ID <cvscweiske1160459368@cvsserver>
cweiske		Tue Oct 10 05:49:28 2006 UTC

  Removed files:               
    /php-gtk-doc/updater	firstOutput 

  Modified files:              
    /php-gtk-doc/updater	updateMethods.php 
  Log:
  - Removing that firstOutput file nobody needs
  - Some fixes to the updater, generates <methods> tag correctly now
  
  
http://cvs.php.net/viewvc.cgi/php-gtk-doc/updater/updateMethods.php?r1=1.18&r2=1.19&diff_format=u
Index: php-gtk-doc/updater/updateMethods.php
diff -u php-gtk-doc/updater/updateMethods.php:1.18 php-gtk-doc/updater/updateMethods.php:1.19
--- php-gtk-doc/updater/updateMethods.php:1.18	Mon Oct  9 20:43:56 2006
+++ php-gtk-doc/updater/updateMethods.php	Tue Oct 10 05:49:28 2006
@@ -15,7 +15,8 @@
 *   - beautify output (xml_beautifier?)
 *   - add/check signals
 *   - add/check properties
-*   - what happens if no <methods> tag exists?
+*   - write no-<methods> and no-<constructors> testcase
+*   - testcase for adding constructor
 *
 *   Done:
 *   - add void if no return value (always since we cannot determine)
@@ -27,6 +28,7 @@
 *   - check existing methods
 *   - check parameters of already docced methods
 *       (void -> parameter, parameter count)
+*   - what happens if no <methods> tag exists?
 *
 *   @author Anant Narayanan <[email protected]>
 *   @author Christian Weiske <[email protected]>
@@ -101,15 +103,20 @@
         } else {
             $trueMethods   = $childMethods;
         }
-        echo ' ' . str_pad(count($trueMethods), 3) . " methods\n";
+
         $arMethodNames = $this->getMethodNames($trueMethods);
 
         $doc = new DOMDocument();
         if ($doc->load($file)) {
             $xpath = new DOMXPath($doc);
+
+            $nExisting = $xpath->evaluate('count(//methods/method/funcsynopsis/funcprototype/funcdef/function/text())');
+            echo ' ' . str_pad(count($trueMethods), 3) . ' methods (' . $nExisting . ' existing)' . "\n";
+
             $this->checkInterface($doc, $xpath, $refObject);
 
             //check the existence of each method defined in the docs
+            $nRemoved = 0;
             foreach ($xpath->query('//methods/method/funcsynopsis/funcprototype/funcdef/function/text()') as $method) {
                 $strMethod = $method->textContent;
                 if (!in_array($strMethod, $arMethodNames)) {
@@ -117,8 +124,13 @@
                     $toRemove = $xpath->query('//methods/method[funcsynopsis/funcprototype/funcdef/function/text()="' . $strMethod . '"]');
                     $toRemoveParent = $xpath->query('//methods');
                     $toRemoveParent->item(0)->removeChild($toRemove->item(0));
+                    ++$nRemoved;
                 }
             }
+            if ($nRemoved > 0) {
+                $this->methodCount += $nRemoved;
+                echo ' Removed ' . $nRemoved . ' methods' . "\n";
+            }
 
             //Update each method in the class
             foreach ($trueMethods as $key => $methodObj) {
@@ -128,6 +140,11 @@
             if (is_subclass_of($classname, 'GObject')) {
                 $this->checkSignals($classname, $doc, $xpath);
             }
+
+            if ($this->methodCount > 0) {
+                //something changed? save the thing
+                $doc->save($file);
+            }
         } else {
             echo 'XML is broken in ' . $file . " - skipping.\n";
         }
@@ -258,37 +275,34 @@
 
             $xmlMethod->appendChild($doc->createTextNode('  '));
 
-            /* Save the xml file after adding the whole method node */
             if ($ismethod) {
                 echo "M ";
-                $topLevel = $doc->getElementsByTagName('methods');
+                $topLevels = $doc->getElementsByTagName('methods');
 
                 // If there is no methods section, create one.
-                if ($topLevel->length == 0) {
-                    $methods = $doc->createElement('methods');
-                    $doc->appendChild($methods);
-                    $topLevel = $doc->getElementsByTagName('methods');
+                if ($topLevels->length == 0) {
+                    $methods        = $doc->createElement('methods');
+                    $doc->getElementsByTagName('classentry')->item(0)->appendChild($methods);
+                    $topLevels       = $doc->getElementsByTagName('methods');
                 }
             } else {
                 echo "C ";
-                $topLevel = $doc->getElementsByTagName('constructors');
+                $topLevels = $doc->getElementsByTagName('constructors');
 
                 // If there is no constructor section, create one.
-                if ($topLevel->length == 0) {
-                    $methods = $doc->createElement('constructors');
-                    $doc->appendChild($methods);
-                    $topLevel = $doc->getElementsByTagName('constructors');
+                if ($topLevels->length == 0) {
+                    $constructors   = $doc->createElement('constructors');
+                    $doc->getElementsByTagName('classentry')->item(0)->appendChild($constructors);
+                    $topLevels       = $doc->getElementsByTagName('constructors');
                 }
             }
-            $topLevel = $topLevel->item(0);
+            $topLevel = $topLevels->item(0);
             echo "Updating " . $daID . "\n";
             $topLevel->appendChild($doc->createTextNode('  '));
             $topLevel->appendChild($xmlMethod);
             $topLevel->appendChild($doc->createTextNode("\n\n"));
 
-            $doc->save($file);
-
-            $this->methodCount += 1;
+            ++$this->methodCount;
         } else {
             /**
             *   Method exists
@@ -300,10 +314,10 @@
             $this->checkExistingMethodParams($doc, $xpath, $method, $path);
 
             // Add a static entity if needed.
-            if ($method->isStatic()) {
+            //only if not a constructor
+            if ($ismethod && $method->isStatic()) {
                 if ($this->addStatic($doc, $xmlDesc)) {
                     ++$this->methodCount;
-                    $doc->save($file);
                 }
             }
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.