Changeset 12601

Show
Ignore:
Timestamp:
02/21/08 18:01:30 (11 months ago)
Author:
pottedmeat
Message:

Refs #5602.

  • Fix some dojo.declare example issues
  • Add example theming
  • Update GeSHi CSS
  • Add a quick namespace calculation thinger
Location:
util
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • util/branches/dev/jsdoc/INSTALL

    r10914 r12601  
    1616===================== 
    1717 
     18http://drupal.org/node/70151 
    1819Drop the jsdoc folder into sites/all/modules 
    1920 
  • util/branches/dev/jsdoc/jsdoc.css

    r11199 r12601  
    1 /** 
    2  * GeSHi Dynamically Generated Stylesheet 
    3  * -------------------------------------- 
    4  * Dynamically generated stylesheet for javascript 
    5  * CSS class: javascript, CSS id:  
    6  * GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) 
    7  */ 
    8 .javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} 
    9 .javascript  {} 
    10 .javascript .head {} 
    11 .javascript .foot {} 
    12 .javascript .imp {font-weight: bold; color: red;} 
    13 .javascript .ln-xtra {color: #cc0; background-color: #ffc;} 
    14 .javascript li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;} 
    15 .javascript li.li2 {font-weight: bold;} 
    16 .javascript .kw1 {color: #000066; font-weight: bold;} 
    17 .javascript .kw2 {color: #003366; font-weight: bold;} 
     1/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */ 
     2.javascript .de1, .javascript .de2 {font-weight:normal;background:transparent;color:#000; padding-left: 5px;} 
     3.javascript .kw1 {color: #a1a100;} 
     4.javascript .kw2 {color: #000; font-weight: bold;} 
    185.javascript .kw3 {color: #000066;} 
    19 .javascript .co1 {color: #009900; font-style: italic;} 
    20 .javascript .coMULTI {color: #009900; font-style: italic;} 
    21 .javascript .es0 {color: #000099; font-weight: bold;} 
     6.javascript .kw4 {color: #f63333;} 
     7.javascript .co1, .javascript .co2, .javascript .coMULTI {color: #808080;} 
     8.javascript .es0 {color: #000033; font-weight: bold;} 
    229.javascript .br0 {color: #66cc66;} 
    23 .javascript .st0 {color: #3366CC;} 
    24 .javascript .nu0 {color: #CC0000;} 
    25 .javascript .me1 {color: #006600;} 
    26 .javascript .sc0 {} 
    27 .javascript .sc1 {} 
    28 .javascript .sc2 {} 
    29 .javascript .sc3 {} 
    30 .javascript .re0 {color: #0066FF;} 
    31 /** 
    32  * GeSHi Dynamically Generated Stylesheet 
    33  * -------------------------------------- 
    34  * Dynamically generated stylesheet for javascript 
    35  * CSS class: javascript, CSS id:  
    36  * GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) 
    37  */ 
    38 .javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} 
    39 .javascript  {} 
    40 .javascript .head {} 
    41 .javascript .foot {} 
    42 .javascript .imp {font-weight: bold; color: red;} 
    43 .javascript .ln-xtra {color: #cc0; background-color: #ffc;} 
    44 .javascript li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;} 
    45 .javascript li.li2 {font-weight: bold;} 
    46 .javascript .kw1 {color: #000066; font-weight: bold;} 
    47 .javascript .kw2 {color: #003366; font-weight: bold;} 
    48 .javascript .kw3 {color: #000066;} 
    49 .javascript .kw4 {color: #600000;} 
    50 .javascript .co1 {color: #009900; font-style: italic;} 
    51 .javascript .coMULTI {color: #009900; font-style: italic;} 
    52 .javascript .es0 {color: #000099; font-weight: bold;} 
    53 .javascript .br0 {color: #66cc66;} 
    54 .javascript .st0 {color: #3366CC;} 
    55 .javascript .nu0 {color: #CC0000;} 
    56 .javascript .me1 {color: #006600;} 
    57 .javascript .sc0 {} 
    58 .javascript .sc1 {} 
    59 .javascript .sc2 {} 
    60 .javascript .sc3 {} 
    61 .javascript .re0 {color: #0066FF;} 
    62 /** 
    63  * GeSHi Dynamically Generated Stylesheet 
    64  * -------------------------------------- 
    65  * Dynamically generated stylesheet for javascript 
    66  * CSS class: javascript, CSS id:  
    67  * GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) 
    68  */ 
    69 .javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} 
    70 .javascript  {} 
    71 .javascript .head {} 
    72 .javascript .foot {} 
    73 .javascript .imp {font-weight: bold; color: red;} 
    74 .javascript .ln-xtra {color: #cc0; background-color: #ffc;} 
    75 .javascript li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;} 
    76 .javascript li.li2 {font-weight: bold;} 
    77 .javascript .kw1 {color: #000066; font-weight: bold;} 
    78 .javascript .kw2 {color: #003366; font-weight: bold;} 
    79 .javascript .kw3 {color: #000066;} 
    80 .javascript .co1 {color: #009900; font-style: italic;} 
    81 .javascript .coMULTI {color: #009900; font-style: italic;} 
    82 .javascript .es0 {color: #000099; font-weight: bold;} 
    83 .javascript .br0 {color: #66cc66;} 
    84 .javascript .st0 {color: #3366CC;} 
    85 .javascript .nu0 {color: #CC0000;} 
    86 .javascript .me1 {color: #006600;} 
    87 .javascript .sc0 {} 
    88 .javascript .sc1 {} 
    89 .javascript .sc2 {} 
    90 .javascript .sc3 {} 
    91 .javascript .re0 {color: #0066FF;} 
    92 /** 
    93  * GeSHi Dynamically Generated Stylesheet 
    94  * -------------------------------------- 
    95  * Dynamically generated stylesheet for javascript 
    96  * CSS class: javascript, CSS id:  
    97  * GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) 
    98  */ 
    99 .javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} 
    100 .javascript  {} 
    101 .javascript .head {} 
    102 .javascript .foot {} 
    103 .javascript .imp {font-weight: bold; color: red;} 
    104 .javascript .ln-xtra {color: #cc0; background-color: #ffc;} 
    105 .javascript li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;} 
    106 .javascript li.li2 {font-weight: bold;} 
    107 .javascript .kw1 {color: #000066; font-weight: bold;} 
    108 .javascript .kw2 {color: #003366; font-weight: bold;} 
    109 .javascript .kw3 {color: #000066;} 
    110 .javascript .co1 {color: #009900; font-style: italic;} 
    111 .javascript .coMULTI {color: #009900; font-style: italic;} 
    112 .javascript .es0 {color: #000099; font-weight: bold;} 
    113 .javascript .br0 {color: #66cc66;} 
    114 .javascript .st0 {color: #3366CC;} 
    115 .javascript .nu0 {color: #CC0000;} 
    116 .javascript .me1 {color: #006600;} 
    117 .javascript .sc0 {} 
    118 .javascript .sc1 {} 
    119 .javascript .sc2 {} 
    120 .javascript .sc3 {} 
    121 .javascript .re0 {color: #0066FF;} 
     10.javascript .st0 {color: #ff0000;} 
     11.javascript .nu0 {color: #ff33ff;} 
     12.javascript .me0 {color: #006600;} 
     13 
     14.html4strict .de1, .html4strict .de2 {font-weight:normal;background:transparent;color:#000; padding-left: 5px;} 
     15.html4strict .kw1 {color: #a1a100;} 
     16.html4strict .kw2 {color: #000; font-weight: bold;} 
     17.html4strict .kw3 {color: #000066;} 
     18.html4strict .kw4 {color: #f63333;} 
     19.html4strict .co1, .html4strict .co2, .html4strict .coMULTI {color: #808080;} 
     20.html4strict .es0 {color: #000033; font-weight: bold;} 
     21.html4strict .br0 {color: #66cc66;} 
     22.html4strict .st0 {color: #ff0000;} 
     23.html4strict .nu0 {color: #ff33ff;} 
     24.html4strict .me0 {color: #006600;} 
  • util/branches/dev/jsdoc/jsdoc.install

    r11930 r12601  
    139139        parent_vid integer NOT NULL REFERENCES {node_revisions} (vid), 
    140140        parent_nid integer NOT NULL REFERENCES {node} (vid), -- node-type: jsdoc_variable 
    141         type enum('normal', 'prototype', 'instance', 'alias', 'chain', 'mixin'), -- The type of join 
     141        type enum('normal', 'cascading', 'prototype', 'instance', 'alias', 'chain', 'mixin'), -- The type of join 
    142142        subtype enum('call', 'prototype', '') DEFAULT '', -- The subtype of the join 
    143143        version integer NOT NULL REFERENCES {node} (nid), -- node-type: jsdoc_version 
     
    180180        weight integer NOT NULL, 
    181181        example longtext NOT NULL, 
     182        markedup longtext NOT NULL, 
    182183      PRIMARY KEY (vid, weight) 
    183184      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); 
  • util/branches/dev/jsdoc/jsdoc.module

    r12599 r12601  
    407407    else { 
    408408      _jsdoc_init(); 
     409 
     410      $ignores = array(); 
     411      $query = db_query("SELECT parent.title FROM jsdoc_variable_hierarchy AS jvh JOIN node AS child ON (child.vid = jvh.vid) JOIN jsdoc_objects AS jschild ON (jschild.vid = jvh.nid) JOIN node AS parent ON (parent.vid = jvh.parent_vid) WHERE jvh.type NOT IN ('cascading', 'normal', 'alias') AND (parent.title LIKE 'dojo.%'  OR parent.title LIKE 'dojox.%' OR parent.title LIKE 'dijit.%') AND jschild.private = 0 AND jschild.private_parent = 0 GROUP BY BINARY parent.title ORDER BY parent.title"); 
     412      while ($result = db_fetch_object($query)) { 
     413        $ignores[] = $result->title; 
     414      } 
     415      $namespaces = array(); 
     416      $query = db_query("SELECT parent.title FROM jsdoc_variable_hierarchy AS jvh JOIN node AS child ON (child.vid = jvh.vid) JOIN jsdoc_objects AS jschild ON (jschild.vid = jvh.nid) JOIN node AS parent ON (parent.vid = jvh.parent_vid) WHERE jvh.type = 'normal' AND (parent.title LIKE 'dojo.%'  OR parent.title LIKE 'dojox.%' OR parent.title LIKE 'dijit.%') AND jschild.private = 0 AND jschild.private_parent = 0 GROUP BY BINARY parent.title ORDER BY parent.title"); 
     417      while ($result = db_fetch_object($query)) { 
     418        $found = false; 
     419        foreach ($ignores as $ignore) { 
     420          if (strpos($ignore, $result->title . '.') === 0 || $ignore == $result->title) { 
     421            $found = true; 
     422            break; 
     423          } 
     424        } 
     425        if (!$found) { 
     426          $namespaces[] = $result->title; 
     427        } 
     428      } 
     429      cache_set('jsdoc_namespaces', 'cache', serialize($namespaces)); 
    409430 
    410431      $timestamp = variable_get('jsdoc_cron_time', 0); 
     
    9951016  if (is_array(jsdoc_get_examples($node))) { 
    9961017    foreach (jsdoc_get_examples($node) as $weight => $example) { 
    997       $example = _jsdoc_markup_text($example, jsdoc_get_version($node)->nid); 
    998       db_query("INSERT INTO {jsdoc_examples} (vid, nid, weight, example) VALUES (%d, %d, %d, '%s')", $node->vid, $node->nid, $weight, $example); 
     1018      $example = preg_replace('%^([\s]*)\n%', '', $example); 
     1019      db_query("INSERT INTO {jsdoc_examples} (vid, nid, weight, example, markedup) VALUES (%d, %d, %d, '%s', '%s')", $node->vid, $node->nid, $weight, $example, _jsdoc_markup_text($example, jsdoc_get_version($node)->nid)); 
    9991020    } 
    10001021  } 
     
    10301051  if (is_array(jsdoc_get_examples($node))) { 
    10311052    foreach (jsdoc_get_examples($node) as $weight => $example) { 
    1032       $example = _jsdoc_markup_text($example, jsdoc_get_version($node)->nid); 
    1033       db_query("INSERT INTO {jsdoc_examples} (vid, nid, weight, example) VALUES (%d, %d, %d, '%s')", $node->vid, $node->nid, $weight, $example); 
     1053      $example = preg_replace('%^([\s]*)\n%', '', $example); 
     1054      db_query("INSERT INTO {jsdoc_examples} (vid, nid, weight, example, markedup) VALUES (%d, %d, %d, '%s', '%s')", $node->vid, $node->nid, $weight, $example, _jsdoc_markup_text($example, jsdoc_get_version($node)->nid)); 
    10341055    } 
    10351056  } 
     
    13411362} 
    13421363 
    1343 function jsdoc_get_examples(&$node) { 
     1364function jsdoc_get_examples(&$node, $markedup=false) { 
    13441365  if (isset($node->jsdoc_examples)) { 
    13451366    return $node->jsdoc_examples; 
     
    13471368 
    13481369  $node->jsdoc_examples = array(); 
    1349   $query = db_query("SELECT example FROM {jsdoc_examples} WHERE vid = %d ORDER BY weight", $node->vid); 
     1370  $query = db_query("SELECT example, markedup FROM {jsdoc_examples} WHERE vid = %d ORDER BY weight", $node->vid); 
    13501371  while ($example = db_fetch_object($query)) { 
    1351     $node->jsdoc_examples[] = $example->example; 
     1372    $node->jsdoc_examples[] = ($markedup) ? $example->markedup : $example->example; 
    13521373  } 
    13531374 
     
    23062327      } 
    23072328    } 
     2329  } 
     2330 
     2331  $examples = array(); 
     2332  foreach (jsdoc_get_examples($node, true) as $weight => $example) { 
     2333    $examples[] = theme('jsdoc_object_example', $example, $weight + 1); 
     2334  } 
     2335  if (!empty($examples)) { 
     2336    $form['examples'] = array( 
     2337      '#value' => theme('jsdoc_object_examples', $examples), 
     2338      '#weight' => 35 
     2339    ); 
    23082340  } 
    23092341 
     
    28852917      db_query("INSERT INTO {jsdoc_variable_hierarchy} (vid, nid, parent_vid, parent_nid, type, version) VALUES (%d, %d, %d, %d, '%s', %d)", $node->vid, $node->nid, $parent->vid, $parent->nid, 'instance', jsdoc_get_version($node)->nid); 
    28862918       
    2887       // If object foo has function foo.bar and foo.bar uses the variable this.baz and is uninstantiated, 
    2888       // `this` would refer to foo, making baz a property of foo 
    2889       // So we create a normal join from foo.bar.baz to foo.baz by removing the second to last object section 
    2890       if (preg_match('%^([^.]+)\.[^.]+\.([^.]+)$%', $node->jsdoc_instance, $match)) { 
     2919      // If object foo has function foo.bar and foo.bar uses the variable 
     2920      // this.baz and is uninstantiated, `this` would refer to foo, 
     2921      // making baz a property of foo. So we create a normal join 
     2922      // from foo.bar.baz to foo.baz by removing the second to last object section 
     2923      if (preg_match('%^([^.]+)\.[^.]+\.([^.]+)$%', $node->title, $match)) { 
    28912924        $parent = _jsdoc_variable_get_or_create($match[1] . '.' . $match[2], jsdoc_get_project($node), false); 
    2892         db_query("INSERT INTO {jsdoc_variable_hierarchy} (vid, nid, parent_vid, parent_nid, type, version) VALUES (%d, %d, %d, %d, '%s', %d)", $node->vid, $node->nid, $parent->vid, $parent->nid, 'normal', jsdoc_get_version($node)->nid); 
     2925        db_query("INSERT INTO {jsdoc_variable_hierarchy} (vid, nid, parent_vid, parent_nid, type, version) VALUES (%d, %d, %d, %d, '%s', %d)", $node->vid, $node->nid, $parent->vid, $parent->nid, 'cascading', jsdoc_get_version($node)->nid); 
    28932926      } 
    28942927    } 
     
    29202953        } 
    29212954      } 
    2922     }     
     2955    } 
    29232956    if ($node->jsdoc_chains) { 
    29242957      foreach ($node->jsdoc_chains as $subtype => $chain) { 
     
    33883421 
    33893422  _jsdoc_init(); 
    3390   $highlighter =& new GeSHi($text, 'javascript'); 
     3423  $language = 'javascript'; 
     3424  if (preg_match('%(^\W*<|>\W*$)%', $text)) { 
     3425    $language = 'html4strict'; 
     3426    print $language; 
     3427  } 
     3428  $highlighter =& new GeSHi($text, $language); 
    33913429  $highlighter->enable_classes(); 
     3430  $highlighter->enable_keyword_links(false); 
    33923431  $highlighter->set_overall_style('color: #666;', true); 
    33933432  $highlighter->set_tab_width(4); 
     
    35013540    $format = variable_get('jsdoc_input_format', 1); 
    35023541  } 
    3503    
     3542 
    35043543  $text = check_markup($text, $format, FALSE); 
    3505   if (preg_match_all('%<code>(.*?)</code>%s', $text, $matches, PREG_SET_ORDER)) { 
     3544  if (preg_match_all('%(?:\s*(?:<pre>|<code>)\s*)+(.*?)(?:\s*(?:</pre>|</code>)\s*)+%s', $text, $matches, PREG_SET_ORDER)) { 
    35063545    foreach ($matches as $match) { 
     3546      $match[1] = str_replace('&lt;', '<', str_replace('&gt;', '>', $match[1])); 
    35073547      $text = str_replace($match[0], _jsdoc_markup_code($match[1], $version), $text); 
    35083548    } 
     
    37013741function theme_jsdoc_function_parameters($parameters) { 
    37023742  $output = '<div class="jsdoc_function_parameters">'; 
    3703   $output .= '<fieldset class="collapsible">'; 
     3743  $output .= '<fieldset>'; 
    37043744  $output .= '<legend>' . 'Parameters' . '</legend>'; 
    37053745  $output .= '<div class="fieldset-wrapper">'; 
     
    37763816  return $summary . $description; 
    37773817} 
     3818 
     3819function theme_jsdoc_object_example($example, $weight) { 
     3820  return '<div class="form-item"><label>Example #' . $weight . '</label>' . $example . '</div>'; 
     3821} 
     3822 
     3823function theme_jsdoc_object_examples($examples) { 
     3824  $output = '<div class="jsdoc_object_examples">'; 
     3825  $output .= '<fieldset>'; 
     3826  $output .= '<legend>Examples</legend>'; 
     3827  $output .= '<div class="fieldset-wrapper">'; 
     3828  $output .= implode('', $examples); 
     3829  $output .= '</div></fieldset></div>'; 
     3830  return $output; 
     3831} 
  • util/trunk/docscripts/includes/dojo.inc

    r12444 r12601  
    225225      $object->setName($name); 
    226226      $object->setAnonymous(true); 
     227      $object->addBlockCommentKeySet('example'); 
    227228      $values = $object->getValues(); 
    228229      foreach ($values as $key => $value) { 
     
    246247      $keys = $object->getBlockCommentKeys(); 
    247248      foreach ($keys as $key) { 
    248         if ($key == 'summary') { 
     249        if ($key == 'example') { 
     250          $output[$name]['examples'] = $object->getBlockComment('example'); 
     251        } 
     252        elseif ($key == 'summary') { 
    249253          $output[$name]['summary'] = $object->getBlockComment('summary'); 
    250254        } 
  • util/trunk/docscripts/lib/parser/DojoObject.php

    r12450 r12601  
    4848    return $this->body->addBlockCommentKey($key); 
    4949  } 
    50    
     50 
     51  public function addBlockCommentKeySet($key){ 
     52    return $this->body->addBlockCOmmentKeySet($key); 
     53  } 
     54 
    5155  public function build(){ 
    5256    if(!$this->start){