This patch compresses the methodnames in a class synopsis if it matches
the class name it belongs to. Since cvs patch doesn't seem to pick up on
added files, PhDTheme.class.php is also attached, which needs to be
placed in the include/ directory. A few notes:

- The serialized index cache hack has been added until we get a same
indexing algorithm. On regular runs, index.ser is generated.
- PhDTheme is now an abstract class that implements iPhDTheme and now
contains a pointer to the Format object. All themes inherit from it.
Since we only support xhtml currently, that format object is always the
one to get registered, soon, however, we'll have to split up themes by
format
- phpdotnet is now an abstract class, as it presumably isn't supposed to
be used as a theme
- phpdotnet->format_function_text() now has an optional parameter
$display_value, which if set overrides the original value. The original
value is still necessary to generate the link, however.
- There is no support for constants; adding that shouldn't be difficult
to do though

I don't like big PHP files, because my editor doesn't let me open up
multiple tabs of different locations in the same file, so I find myself
constantly seeking from end to end to make changes. Any suggestions?
(Besides using gvim, which I do need to learn, but later.)

-- 
 Edward Z. Yang                        GnuPG: 0x869C48DA
 HTML Purifier <http://htmlpurifier.org> Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
? build-imagick.bat
? build.bat
Index: .cvsignore
===================================================================
RCS file: /repository/phd/.cvsignore,v
retrieving revision 1.3
diff -u -r1.3 .cvsignore
--- .cvsignore  16 Sep 2007 12:52:49 -0000      1.3
+++ .cvsignore  6 Nov 2007 18:24:36 -0000
@@ -9,4 +9,4 @@
 pdo-data.sqlite
 html
 php
-
+index.ser
Index: build.php
===================================================================
RCS file: /repository/phd/build.php,v
retrieving revision 1.37
diff -u -r1.37 build.php
--- build.php   5 Nov 2007 19:49:04 -0000       1.37
+++ build.php   6 Nov 2007 18:22:20 -0000
@@ -41,12 +41,16 @@
 require $ROOT. "/include/PhDPartialReader.class.php";
 require $ROOT. "/include/PhDHelper.class.php";
 require $ROOT. "/include/PhDFormat.class.php";
+require $ROOT. "/include/PhDTheme.class.php";
 
 if ($OPTIONS["index"]) {
     if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
         v("Indexing...\n");
     }
     require $ROOT. "/mktoc.php";
+    file_put_contents('index.ser', $ser = serialize($IDs));
+    $IDs2 = unserialize($ser);
+    if ($IDs !== $IDs2) exit('serialized representation does not match');
     if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
         v("Indexing done\n");
     }
@@ -59,6 +63,13 @@
     }
 } else {
     /* FIXME: Load from sqlite db? */
+    if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
+        v("Unserializing cached index file...\n");
+    }
+    $IDs = unserialize(file_get_contents('index.ser'));
+    if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
+        v("Unserialization done\n");
+    }
 }
 
 foreach($OPTIONS["output_format"] as $output_format) {
@@ -98,6 +109,11 @@
                 default:
                     $themes[$themename] = new $themename($IDs);
             }
+            
+            // WARNING: this needs to go away when we add support for
+            // things other than xhtml
+            $themes[$themename]->registerFormat($format);
+            
 
             // If the theme returns empty callback map there is no need to 
include it
             $tmp = $themes[$themename]->getElementMap();
Index: formats/xhtml.php
===================================================================
RCS file: /repository/phd/formats/xhtml.php,v
retrieving revision 1.41
diff -u -r1.41 xhtml.php
--- formats/xhtml.php   3 Nov 2007 17:14:45 -0000       1.41
+++ formats/xhtml.php   6 Nov 2007 18:43:58 -0000
@@ -254,6 +254,20 @@
             /* DEFAULT */         false,
             'fieldsynopsis'    => 'format_fieldsynopsis_modifier_text',
         ),
+        'classname'            => array(
+            /* DEFAULT */         false,
+            'ooclass'          => array(
+                /* DEFAULT */     false,
+                'classsynopsis' => 
'format_classsynopsis_ooclass_classname_text',
+            ),
+        ),
+        'methodname'           => array(
+            /* DEFAULT */         false,
+            'methodsynopsis'    => array(
+                /* DEFAULT */     false,
+                'classsynopsis' => 
'format_classsynopsis_methodsynopsis_methodname_text',
+            ),
+        ),
     );
 
 
@@ -389,6 +403,19 @@
         }
         return "</div>";
     }
+    
+    public function format_classsynopsis_ooclass_classname_text($value, $tag) {
+        $this->tmp["classsynopsis"]["classname"] = $value;
+        return $value;
+    }
+    
+    public function 
format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
+        if (!isset($this->tmp["classsynopsis"]["classname"])) return $value;
+        list($class, $method) = explode('::', $value);
+        if ($class !== $this->tmp["classsynopsis"]["classname"]) return $value;
+        return $method;
+    }
+    
     public function format_fieldsynopsis($open, $name, $attrs) {
         $this->tmp["fieldsynopsis"] = array();
         if ($open) {
Index: include/PhDFormat.class.php
===================================================================
RCS file: /repository/phd/include/PhDFormat.class.php,v
retrieving revision 1.7
diff -u -r1.7 PhDFormat.class.php
--- include/PhDFormat.class.php 2 Oct 2007 14:37:42 -0000       1.7
+++ include/PhDFormat.class.php 5 Nov 2007 22:22:21 -0000
@@ -79,9 +79,6 @@
 
 }
 
-interface PhDTheme {
-    public function appendData($data, $isChunk);
-}
 /*
  * vim600: sw=4 ts=4 fdm=syntax syntax=php et
  * vim<600: sw=4 ts=4
Index: themes/php/bightml.php
===================================================================
RCS file: /repository/phd/themes/php/bightml.php,v
retrieving revision 1.5
diff -u -r1.5 bightml.php
--- themes/php/bightml.php      5 Nov 2007 19:49:04 -0000       1.5
+++ themes/php/bightml.php      5 Nov 2007 22:23:40 -0000
@@ -2,7 +2,7 @@
 /*  $Id: bightml.php,v 1.5 2007/11/05 19:49:04 bjori Exp $ */
 
 require_once $ROOT . '/themes/php/phpdotnet.php';
-class bightml extends phpdotnet implements PhDTheme {
+class bightml extends phpdotnet {
     public function __construct(array $IDs, $filename, $ext = "html") {
         parent::__construct($IDs, $filename, $ext, false);
         $this->stream = fopen("bightml.html", "w");
Index: themes/php/phpdotnet.php
===================================================================
RCS file: /repository/phd/themes/php/phpdotnet.php,v
retrieving revision 1.28
diff -u -r1.28 phpdotnet.php
--- themes/php/phpdotnet.php    3 Nov 2007 16:44:10 -0000       1.28
+++ themes/php/phpdotnet.php    6 Nov 2007 18:43:29 -0000
@@ -1,7 +1,7 @@
 <?php
 /*  $Id: phpdotnet.php,v 1.28 2007/11/03 16:44:10 bjori Exp $ */
 
-class phpdotnet extends PhDHelper {
+abstract class phpdotnet extends PhDTheme {
     protected $elementmap = array(
         'acronym'               => 'format_suppressed_tags',
         'function'              => 'format_suppressed_tags',
@@ -80,7 +80,13 @@
     protected $textmap =        array(
         'acronym'               => 'format_acronym_text',
         'function'              => 'format_function_text',
-        'methodname'            => 'format_function_text',
+        'methodname'            => array(
+            /* DEFAULT */          'format_function_text',
+            'methodsynopsis'    => array(
+                /* DEFAULT */      'format_function_text',
+                'classsynopsis' => 
'format_classsynopsis_methodsynopsis_methodname_text',
+            ),
+        ),
         'type'                  => array(
             /* DEFAULT */          'format_type_text',
             'classsynopsisinfo' => false,
@@ -353,14 +359,21 @@
         /* ignore it */
         return "";
     }
-    public function format_function_text($value, $tag) {
+    
+    public function 
format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
+        $display_value = 
$this->format->format_classsynopsis_methodsynopsis_methodname_text($value, 
$tag);
+        return $this->format_function_text($value, $tag, $display_value);
+    }
+    
+    public function format_function_text($value, $tag, $display_value = null) {
+        if ($display_value === null) $display_value = $value;
         $link = strtolower(str_replace(array("__", "_", "::", "->"), array("", 
"-", "-", "-"), $value));
 
         if ($this->CURRENT_FUNCTION === $link || !($filename = 
PhDHelper::getFilename("function.$link"))) {
-            return '<b>' .$value.($tag == "function" ? "()" : ""). '</b>';
+            return '<b>' .$display_value.($tag == "function" ? "()" : ""). 
'</b>';
         }
 
-        return '<a href="' .($this->chunked ? "" : "#").$filename. '.' 
.$this->ext. '" class="function">' .$value.($tag == "function" ? "()" : ""). 
'</a>';
+        return '<a href="' .($this->chunked ? "" : "#").$filename. '.' 
.$this->ext. '" class="function">' .$display_value.($tag == "function" ? "()" : 
""). '</a>';
     }
     public function format_type_text($type, $tagname) {
         $t = strtolower($type);
Index: themes/php/phpweb.php
===================================================================
RCS file: /repository/phd/themes/php/phpweb.php,v
retrieving revision 1.18
diff -u -r1.18 phpweb.php
--- themes/php/phpweb.php       5 Nov 2007 19:49:04 -0000       1.18
+++ themes/php/phpweb.php       5 Nov 2007 22:23:34 -0000
@@ -2,7 +2,7 @@
 /*  $Id: phpweb.php,v 1.18 2007/11/05 19:49:04 bjori Exp $ */
 
 require_once $ROOT . '/themes/php/phpdotnet.php';
-class phpweb extends phpdotnet implements PhDTheme {
+class phpweb extends phpdotnet {
     protected $streams = array();
     protected $writeit = false;
 
format = $format; } } interface iPhDTheme { public function appendData($data, $isChunk); }

Reply via email to