[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/apidoc/ newly added static apidoc version available through ++apidoc++/static.html

Daniel Meier daniel at nook.ch
Sun Oct 9 06:00:48 EDT 2005


Log message for revision 38994:
  newly added static apidoc version available through ++apidoc++/static.html
  

Changed:
  U   Zope3/trunk/src/zope/app/apidoc/README.txt
  U   Zope3/trunk/src/zope/app/apidoc/bookmodule/configure.zcml
  A   Zope3/trunk/src/zope/app/apidoc/bookmodule/static_menu.pt
  U   Zope3/trunk/src/zope/app/apidoc/browser/configure.zcml
  U   Zope3/trunk/src/zope/app/apidoc/browser/macros.py
  A   Zope3/trunk/src/zope/app/apidoc/browser/static_index.pt
  A   Zope3/trunk/src/zope/app/apidoc/browser/static_menu.pt
  A   Zope3/trunk/src/zope/app/apidoc/browser/static_menu_macros.pt
  A   Zope3/trunk/src/zope/app/apidoc/browser/static_modules.pt
  U   Zope3/trunk/src/zope/app/apidoc/browser/utilities.js
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/configure.zcml
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/menu.py
  A   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/static_menu.pt
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/configure.zcml
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/menu.py
  A   Zope3/trunk/src/zope/app/apidoc/ifacemodule/static_menu.pt
  U   Zope3/trunk/src/zope/app/apidoc/typemodule/configure.zcml
  A   Zope3/trunk/src/zope/app/apidoc/typemodule/static_menu.pt
  U   Zope3/trunk/src/zope/app/apidoc/utilitymodule/configure.zcml
  A   Zope3/trunk/src/zope/app/apidoc/utilitymodule/static_menu.pt
  U   Zope3/trunk/src/zope/app/apidoc/zcmlmodule/configure.zcml
  A   Zope3/trunk/src/zope/app/apidoc/zcmlmodule/static_menu.pt

-=-
Modified: Zope3/trunk/src/zope/app/apidoc/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/README.txt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/README.txt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -82,3 +82,14 @@
 
 Note:  There are several modules that come with the product. Just look
 in them for some guidance.
+
+
+New Static APIDOC-Version
+-------------------------
+
+An alternative APIDOC-Version is available through ++apidoc++/static.html 
+Find and Tree is implemented in Javascript. So it should be possible to do a
+"wget" - Offline-Version of APIDOC
+
+
+

Modified: Zope3/trunk/src/zope/app/apidoc/bookmodule/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/bookmodule/configure.zcml	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/bookmodule/configure.zcml	2005-10-09 10:00:47 UTC (rev 38994)
@@ -24,6 +24,14 @@
       name="menu.html"
       template="menu.pt"
       />
+  
+    <browser:page
+      for=".book.IBookModule"
+      permission="zope.app.apidoc.UseAPIDoc"
+      class=".browser.Menu"
+      name="staticmenu.html"
+      template="static_menu.pt"
+      />
 
   <browser:page
       for="zope.app.onlinehelp.interfaces.IOnlineHelpTopic"

Added: Zope3/trunk/src/zope/app/apidoc/bookmodule/static_menu.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/bookmodule/static_menu.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/bookmodule/static_menu.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,5 @@
+<html metal:use-macro="views/apidoc_macros/static_menu">
+<body>
+
+</body>
+</html>


Property changes on: Zope3/trunk/src/zope/app/apidoc/bookmodule/static_menu.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/apidoc/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/configure.zcml	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/browser/configure.zcml	2005-10-09 10:00:47 UTC (rev 38994)
@@ -21,6 +21,13 @@
 
   <page 
       for="*"
+      name="static_menu_macros"
+      permission="zope.View"
+      template="static_menu_macros.pt"
+      />
+
+  <page 
+      for="*"
       name="details_macros"
       permission="zope.View"
       template="details_macros.pt"
@@ -61,9 +68,36 @@
     <page
       name="contents.html"
       template="contents.pt" />
+            
+  </pages>
 
+  <!-- Static apidoc -->
+
+  <pages
+    for="zope.app.apidoc.apidoc.APIDocumentation"
+    class=".apidoc.APIDocumentationView"
+    permission="zope.app.apidoc.UseAPIDoc">
+
+            
+    <page
+        name="static.html"
+        template="static_index.pt" />
+
+    <page
+      name="staticmodulelist.html"
+      template="static_modules.pt" />
+
+    <page
+      name="staticmenu.html"
+      template="static_menu.pt" />
+      
+    <page
+      name="staticcontents.html"
+      template="contents.pt" />
+
   </pages>
 
+
   <!-- Preference Views -->
 
   <page

Modified: Zope3/trunk/src/zope/app/apidoc/browser/macros.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/macros.py	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/browser/macros.py	2005-10-09 10:00:47 UTC (rev 38994)
@@ -21,4 +21,4 @@
 
 class APIDocumentationMacros(BaseMacros):
     """Page Template METAL macros for API Documentation"""
-    macro_pages = ('menu_macros', 'details_macros')
+    macro_pages = ('menu_macros', 'details_macros','static_menu_macros')

Added: Zope3/trunk/src/zope/app/apidoc/browser/static_index.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/static_index.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/browser/static_index.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,15 @@
+<html i18n:domain="zope">
+  <head>
+    <title i18n:translate="">Zope 3 API Documentation</title>
+    <link rel="icon" type="image/png"
+          tal:attributes="href context/++resource++favicon.png|default" />
+  </head>
+  <frameset cols="20%, *">
+    <frameset rows="140, *"> 
+      <frame name="modules" src="staticmodulelist.html">
+      <frame name="menu" src="staticmenu.html">
+    </frameset>
+    <frame name="main" src="staticcontents.html">
+  </frameset>
+
+</html>


Property changes on: Zope3/trunk/src/zope/app/apidoc/browser/static_index.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: Zope3/trunk/src/zope/app/apidoc/browser/static_menu.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/static_menu.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/browser/static_menu.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,11 @@
+<html metal:use-macro="views/apidoc_macros/static_menu"
+    i18n:domain="zope">
+<body>
+
+  <div metal:fill-slot="menu">
+    <p class="small" i18n:translate="">Click on one of the Documentation
+      Modules above and a menu for this module will appear.</p>
+  </div>
+
+</body>
+</html>


Property changes on: Zope3/trunk/src/zope/app/apidoc/browser/static_menu.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: Zope3/trunk/src/zope/app/apidoc/browser/static_menu_macros.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/static_menu_macros.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/browser/static_menu_macros.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,111 @@
+<metal:block define-macro="static_menu"><metal:block define-slot="doctype"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></metal:block>
+
+<html
+  xmlns="http://www.w3.org/1999/xhtml"
+  xml:lang="en"
+  lang="en" 
+  i18n:domain="zope">
+
+  <head>
+    <!-- Waaa -->
+    <title metal:define-slot="title" i18n:translate="">Z3 UI</title>
+
+
+    <style type="text/css" 
+           media="all"
+           tal:content=
+           "string: @import url(${context/++resource++apidoc.css});"
+           >
+      @import url(/++resource++apidoc.css);
+    </style>
+    <script type="text/javascript" src="utilities.js"
+            tal:attributes="src string:${context/++resource++utilities.js}" >
+    </script>
+    <metal:block define-slot="headers" />
+    <metal:block define-slot="style_slot" />
+    <metal:block define-slot="ecmascript_slot" />
+
+    <link rel="icon" type="image/png"
+          tal:attributes="href context/++resource++favicon.png|default" />
+  </head>
+
+<head>
+
+<body class="menu">
+
+  <metal:block define-slot="menu-title">
+    <div class="menu" i18n:translate="">Menu</div>
+  </metal:block>
+ 
+  <metal:block define-slot="pre_menu" />
+
+  <metal:block define-slot="menu">
+
+    <table cellspacing="0" cellpadding="0" class="menu" border="0" id="tree"
+           tal:define="root      context/@@cookie_tree;
+                       expandedTree python:root.expand(True);
+                       result    root/getFlatDicts;
+                       nodeDictList   python:result[0];
+                       maxDepth       python:result[1]">
+    <tr tal:repeat="nodeInfo nodeDictList" 
+	tal:attributes="id repeat/nodeInfo/index; treedepth python:len(nodeInfo['row-state'])+1; treehasChildren nodeInfo/node/hasChildren;"
+	style="display:block" treestate="block">
+    <tal:block tal:define="node nodeInfo/node">
+
+  <td style="width:16px" tal:repeat="state nodeInfo/row-state">
+    <img tal:attributes="src context/++resource++tree_images/vline.png"
+         tal:condition="state" alt="|" border="0" />
+  </td>
+
+  <td style="width:16px">
+    <a href="#"
+       tal:define="treeid repeat/nodeInfo/index"
+       tal:attributes="onClick string:javascript:treeClick($treeid);"
+       tal:condition="node/hasChildren">
+      <tal:block condition="not:nodeInfo/last-level-node">
+        <img tal:attributes="src context/++resource++tree_images/plus_vline.png; id string:i$treeid"
+             tal:condition="not:node/expanded" alt="+" border="0" />
+        <img tal:attributes="src context/++resource++tree_images/minus_vline.png; id string:i$treeid" 
+             tal:condition="node/expanded" alt="-" border="0" />
+      </tal:block>
+      <tal:block condition="nodeInfo/last-level-node">
+        <img tal:attributes="src context/++resource++tree_images/plus.png; id string:i$treeid" 
+             tal:condition="not:node/expanded" alt="+" border="0" />
+        <img tal:attributes="src context/++resource++tree_images/minus.png; id string:i$treeid" 
+             tal:condition="node/expanded" alt="-" border="0" />
+      </tal:block>
+    </a>
+
+    <tal:block condition="not:node/hasChildren">
+      <img tal:attributes="src context/++resource++tree_images/tline.png;"  
+           tal:condition="not:nodeInfo/last-level-node" alt="T" border="0" />
+      <img tal:attributes="src context/++resource++tree_images/lline.png;"  
+           tal:condition="nodeInfo/last-level-node" alt="L" border="0" />
+    </tal:block>
+  </td>
+
+  <td colspan="1" class="list-item"
+      tal:attributes="colspan python:maxDepth-len(nodeInfo['row-state'])+1">
+    &nbsp;<a href="" target="main"
+        tal:attributes="href python: view.getMenuLink(node)"
+        tal:content="python: view.getMenuTitle(node)"
+        tal:condition="python: view.getMenuLink(node) is not None"
+        i18n:translate="">
+      node/id
+    </a><tal:block 
+        replace="python: view.getMenuTitle(node)"
+        condition="python: view.getMenuLink(node) is None"
+        i18n:translate="" />
+  </td>
+
+    </tal:block>
+    </tr>
+    </table>
+
+  </metal:block>
+
+  <metal:block define-slot="post_menu" />
+
+</body>
+</html>
+</metal:block>


Property changes on: Zope3/trunk/src/zope/app/apidoc/browser/static_menu_macros.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: Zope3/trunk/src/zope/app/apidoc/browser/static_modules.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/static_modules.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/browser/static_modules.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,30 @@
+<html metal:use-macro="views/apidoc_macros/details"
+    i18n:domain="zope">
+<body metal:fill-slot="contents" 
+      style="padding: 0; margin: 0">
+
+  <div class="apihead">
+      <a href="contents.html" target="main" i18n:translate="">Zope
+            3 API Docs</a>
+  </div>
+
+  <div style="margin-left: 0.5em">
+    <ul class="modules">
+      <li tal:repeat="module view/getModuleList">
+        <a href="" target="menu"
+             tal:attributes="href string:${module/name}/@@staticmenu.html"
+             tal:content="module/title" i18n:translate="">
+          Interfaces
+        </a>
+      </li>
+    </ul>
+    <div id="preference_entry">
+      <a href="./++preferences++/apidoc/@@apidocMenu.html" target="menu"
+        i18n:translate="">
+        User Preferences
+      </a>
+    </div>
+  </div>
+
+</body>
+</html>


Property changes on: Zope3/trunk/src/zope/app/apidoc/browser/static_modules.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/apidoc/browser/utilities.js
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/utilities.js	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/browser/utilities.js	2005-10-09 10:00:47 UTC (rev 38994)
@@ -53,4 +53,132 @@
        var element = document.all[id+'.arrow'];
     }
     element.src = '/@@/'+name;
-}
\ No newline at end of file
+}
+
+/*
+search in list of hrefs to avoid requests to the backend
+
+*/
+var found_sets = new Array();   // init a global array that holds lists for
+							  // found elements
+
+function getSearchResult(searchtext)
+	{
+	if (searchtext.length == 0) found_sets = new Array();
+ 	var searchindex = searchtext.length - 1;
+ 	
+ 	// process backspace i.e search string gets shorter
+	if (found_sets.length > searchindex)
+	{  rubbish = found_sets.pop();
+	   var idlist = found_sets[searchindex];
+	   for (var n = 0 ; n < idlist.length ; n++)
+	   {
+	     element = document.getElementById(idlist[n]);
+	     element.style.display='block';
+	   }
+	   return;
+	}
+	
+	var reslist = document.getElementById('resultlist');
+	var children = reslist.getElementsByTagName('div') //reslist.childNodes;
+    var element;
+	var subelement;
+	var refelement;
+	var comparetext;
+	var compareresult;
+	var resultarray = new Array();
+	var itemcount = 0;
+	for (var n = 0 ; n < children.length ; n++)
+	{
+		element = children[n];                          // get one div element
+	    element.style.display='none' ;                  // reset visibility
+	    subelement = element.getElementsByTagName('a'); // get list of a subelements
+	    refelement = subelement[0];                     // get one a element
+	    comparetext = refelement.firstChild.nodeValue;  // get textnode of a element
+	    compareresult = comparetext.search(searchtext);
+	    
+		if (compareresult != -1)
+		   {element.style.display='block';
+		    resultarray[itemcount] = element.getAttribute("id");
+		    itemcount = itemcount + 1;
+		   }
+	}
+	found_sets[searchindex] = resultarray;
+	}
+
+function simplegetSearchResult(searchtext)
+	{
+	
+	var searchindex = searchtext.length - 1;
+	
+	var reslist = document.getElementById('resultlist');
+	var children = reslist.getElementsByTagName('div') //reslist.childNodes;
+    var element;
+	var subelement;
+	var refelement;
+	var comparetext;
+	var compareresult;
+	for (var n = 0 ; n < children.length ; n++)
+		{
+		element = children[n];                          // get one div element
+	    element.style.display='none'                    // reset visibility
+	    subelement = element.getElementsByTagName('a'); // get list of a subelements
+	    refelement = subelement[0];                     // get one a element
+	    comparetext = refelement.firstChild.nodeValue;  // get textnode of a element
+	    compareresult = comparetext.search(searchtext);
+		if (compareresult != -1)
+		   {element.style.display='block';}
+	
+		}
+}
+
+/*
+Do tree collapsing and expanding by setting table row elements style display to
+none or block and set the images appropriate
+
+
+*/
+function treeClick(treeid) {
+
+    var prent = document.getElementById(treeid).parentNode;
+    var children = prent.getElementsByTagName('tr');
+    var found = 0;
+    var action = "block";
+    var treeiddepth = 0;
+
+    for (var n = 0; n < children.length; n++) {
+         var element = children[n];
+         if (found==1) {
+             if ( treeiddepth < element.getAttribute("treedepth") ) {                
+		             element.style.display = action;
+	                var elid = element.getAttribute("id");
+	                if (document.getElementById("i"+elid) != null) { 
+			            var subimg = document.getElementById("i"+elid);
+	        
+	               
+			if (action=="none" && subimg.src.search('minus') != -1) {
+		             subimg.src = subimg.src.replace('minus', 'plus');
+			}
+	                if (action=="block" && subimg.src.search('plus') != -1) {
+		             subimg.src = subimg.src.replace('plus', 'minus');
+			}
+			}
+		     } else {
+		         return;
+		     }
+	         }
+	         if (element.getAttribute("id")==treeid) {
+	             found = 1;
+	             treeiddepth = element.getAttribute("treedepth")
+	             var img = document.getElementById("i"+treeid);
+	             if (img.src.search('minus') != -1) {
+		         img.src = img.src.replace('minus', 'plus');
+	                 action="none";
+		     } else {
+		         img.src = img.src.replace('plus', 'minus');
+	                 action="block";
+		     }
+		 }
+	   }
+}
+		

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/configure.zcml	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/configure.zcml	2005-10-09 10:00:47 UTC (rev 38994)
@@ -9,6 +9,13 @@
       class=".menu.Menu"
       name="menu.html"
       template="menu.pt" />
+      
+  <page
+      for="..codemodule.CodeModule"
+      permission="zope.app.apidoc.UseAPIDoc"
+      class=".menu.Menu"
+      name="staticmenu.html"
+      template="static_menu.pt" />      
 
   <page
       for="..interfaces.IModuleDocumentation"

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/menu.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/menu.py	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/menu.py	2005-10-09 10:00:47 UTC (rev 38994)
@@ -31,26 +31,29 @@
         """Find the classes that match a partial path.
 
         Examples::
+          >>> from zope.app import zapi
+          >>> from zope.app.apidoc.codemodule.class_ import Class
+          >>> from zope.app.apidoc.interfaces import IDocumentationModule
+      
+          
+          >>> cm = zapi.getUtility(IDocumentationModule, 'Code')
+          >>> mod = cm['zope']['app']['apidoc']['codemodule']['browser']
 
-          >>> from zope.app.apidoc.tests import pprint
-          >>> from zope.app.apidoc.classmodule import Class
-          >>> cm = zapi.getUtility(IDocumentationModule, 'Class')
-          >>> mod = cm['zope']['app']['apidoc']['classmodule']['browser']
-
           Setup a couple of classes and register them.
 
           >>> class Foo(object):
           ...     pass
-          >>> mod._Module__children['Foo'] = Class(mod, 'Foo', Foo)
+          >>> mod._children['Foo'] = Class(mod, 'Foo', Foo)
           >>> class Foo2(object):
           ...     pass
-          >>> mod._Module__children['Foo2'] = Class(mod, 'Foo2', Foo2)
+          >>> mod._children['Foo2'] = Class(mod, 'Foo2', Foo2)
           >>> class Blah(object):
           ...     pass
-          >>> mod._Module__children['Blah'] = Class(mod, 'Blah', Blah)
+          >>> mod._children['Blah'] = Class(mod, 'Blah', Blah)
 
           Setup the view.
 
+          >>> from zope.app.apidoc.codemodule.browser.menu import Menu
           >>> from zope.publisher.browser import TestRequest
           >>> menu = Menu()
           >>> menu.context = None
@@ -61,26 +64,24 @@
           >>> info = menu.findClasses()
 
           >>> pprint(info)
-          [[('path', 'zope.app.apidoc.classmodule.browser.Foo'),
-            ('url',
-             'http://127.0.0.1/zope/app/apidoc/classmodule/browser/Foo')],
-           [('path', 'zope.app.apidoc.classmodule.browser.Foo2'),
-            ('url',
-             'http://127.0.0.1/zope/app/apidoc/classmodule/browser/Foo2')]]
-          
+          [{'path': 'zope.app.apidoc.codemodule.browser.Foo',
+            'url': 'http://127.0.0.1/zope/app/apidoc/codemodule/browser/Foo'},
+           {'path': 'zope.app.apidoc.codemodule.browser.Foo2',
+            'url': 'http://127.0.0.1/zope/app/apidoc/codemodule/browser/Foo2'}]
+            
           >>> menu.request = TestRequest(form={'path': 'o2'})
           >>> info = menu.findClasses()
           >>> pprint(info)
-          [[('path', 'zope.app.apidoc.classmodule.browser.Foo2'),
-            ('url',
-             'http://127.0.0.1/zope/app/apidoc/classmodule/browser/Foo2')]]
+          [{'path': 'zope.app.apidoc.codemodule.browser.Foo2',
+            'url': 'http://127.0.0.1/zope/app/apidoc/codemodule/browser/Foo2'}]
+
           
           >>> menu.request = TestRequest(form={'path': 'Blah'})
           >>> info = menu.findClasses()
           >>> pprint(info)
-          [[('path', 'zope.app.apidoc.classmodule.browser.Blah'),
-            ('url',
-             'http://127.0.0.1/zope/app/apidoc/classmodule/browser/Blah')]]
+          [{'path': 'zope.app.apidoc.codemodule.browser.Blah',
+            'url': 'http://127.0.0.1/zope/app/apidoc/codemodule/browser/Blah'}]
+
         """
         path = self.request.get('path', None)
         if path is None:
@@ -96,3 +97,59 @@
                      })
         results.sort(lambda x, y: cmp(x['path'], y['path']))
         return results
+    
+    def findAllClasses(self):
+        
+        """Find all classes 
+
+        Examples::
+          >>> from zope.app import zapi
+          >>> from zope.app.apidoc.codemodule.class_ import Class
+          >>> from zope.app.apidoc.interfaces import IDocumentationModule
+      
+          
+          >>> cm = zapi.getUtility(IDocumentationModule, 'Code')
+          >>> mod = cm['zope']['app']['apidoc']['codemodule']['browser']
+
+          Setup a couple of classes and register them.
+
+          >>> class Foo(object):
+          ...     pass
+          >>> mod._children['Foo'] = Class(mod, 'Foo', Foo)
+          >>> class Foo2(object):
+          ...     pass
+          >>> mod._children['Foo2'] = Class(mod, 'Foo2', Foo2)
+          >>> class Blah(object):
+          ...     pass
+          >>> mod._children['Blah'] = Class(mod, 'Blah', Blah)
+
+          Setup the view.
+
+          >>> from zope.app.apidoc.codemodule.browser.menu import Menu
+          >>> from zope.publisher.browser import TestRequest
+          >>> menu = Menu()
+          >>> menu.context = None
+
+          Testing the method with various inputs.
+          
+          >>> menu.request = TestRequest(form={'path': 'Foo'})
+          >>> info = menu.findAllClasses()
+
+          >>> len(info) > 3
+          True
+        """
+        classModule = zapi.getUtility(IDocumentationModule, "Code")
+        classModule.setup() # run setup if not yet done
+        results = []
+        counter = 0
+        for p in classRegistry.keys():
+            klass = zapi.traverse(classModule, p.replace('.', '/'))
+            results.append(
+                {'path': p,
+                 'url': zapi.absoluteURL(klass, self.request),
+                 'counter': counter
+                 })
+            counter += 1
+            
+        results.sort(lambda x, y: cmp(x['path'], y['path']))
+        return results

Added: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/static_menu.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/static_menu.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/static_menu.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,51 @@
+<html metal:use-macro="views/apidoc_macros/static_menu"
+    i18n:domain="zope">
+<body>
+
+  <div metal:fill-slot="menu" class="small">
+
+    <div>
+      <span i18n:translate="">Class Finder:</span>
+      <span><i i18n:translate="">(Enter partial Python path)</i></span>
+	</div>
+    <form action="#" method="post" name="searchform" >
+	  <br />
+      <input type="text" name="path" 
+             style="font-size: 80%; width=95%" />
+		  
+	  <br />	  		
+      <input type="button" name="Find" value="Find" 
+		     onClick="javascript:simplegetSearchResult(document.searchform.path.value)"
+             i18n:attributes="value find-button" style="font-size: 80%"/>
+	
+<!--
+      <input type="submit" name="SUBMIT" value="Find" 
+             i18n:attributes="value find-button" style="font-size: 80%"/>
+  -->
+  </form>
+
+    <p style="font-size: 120%">
+      <a href="./index.html" target="main" i18n:translate="">Browse
+        Zope Source</a>
+    </p>
+
+	<div>
+      <span i18n:translate="">Search results:</span><br /><br />
+    </div>	
+	  
+    <div tal:define="pyclasses view/findAllClasses"
+         tal:condition="pyclasses" id="resultlist">
+
+      <div tal:repeat="info pyclasses" style="display:block" tal:attributes="id info/counter">
+        <a href="" target="main"
+           tal:attributes="href info/url"
+           tal:content="info/path">
+         /zope/app/Application
+        </a>
+      </div>
+    </div>
+
+  </div>
+
+</body>
+</html>


Property changes on: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/static_menu.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py	2005-10-09 10:00:47 UTC (rev 38994)
@@ -108,6 +108,10 @@
                              setUp=setUp, tearDown=tearDown,
                              globs={'pprint': doctestunit.pprint},
                              optionflags=doctest.NORMALIZE_WHITESPACE),
+       doctest.DocTestSuite('zope.app.apidoc.codemodule.browser.menu',
+                             setUp=setUp, tearDown=tearDown,
+                             globs={'pprint': doctestunit.pprint},
+                             optionflags=doctest.NORMALIZE_WHITESPACE),
         ))
 
 if __name__ == '__main__':

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/configure.zcml	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/configure.zcml	2005-10-09 10:00:47 UTC (rev 38994)
@@ -66,6 +66,14 @@
       template="menu.pt"
       />
 
+  <browser:page
+      for=".ifacemodule.InterfaceModule"
+      permission="zope.app.apidoc.UseAPIDoc"
+      class=".menu.Menu"
+      name="staticmenu.html"
+      template="static_menu.pt"
+      />
+
   <preferenceGroup
       id="apidoc.InterfaceDetails"
       schema=".interfaces.IInterfaceDetailsPreferences"

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/menu.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/menu.py	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/menu.py	2005-10-09 10:00:47 UTC (rev 38994)
@@ -17,7 +17,9 @@
 """
 __docformat__ = 'restructuredtext'
 from zope.security.proxy import removeSecurityProxy
+import re
 
+whitepattern = re.compile('\s{2,}')
 def getAllTextOfInterface(iface):
     """Get all searchable text from an interface"""
     iface = removeSecurityProxy(iface)
@@ -50,3 +52,29 @@
                      })
         results.sort(lambda x, y: cmp(x['name'], y['name']))
         return results
+
+    def findAllInterfaces(self):
+        """Find all interfaces."""
+        
+        #name_only = ('name_only' in self.request) and True or False
+        #search_str = self.request.get('search_str', None)
+        results = []
+        
+        #if search_str is None:
+        #    return results
+        counter = 0
+        for name, iface in self.context.items():
+            #if (search_str in name or
+            #    (not name_only and search_str in getAllTextOfInterface(iface))):
+            rtext = getAllTextOfInterface(iface)
+            
+            results.append(
+                {'name': name,
+                 'url': './%s/apiindex.html' %name,
+                 'counter': counter,
+                 'doc': whitepattern.sub(' ',getAllTextOfInterface(iface))
+                 })
+            counter += 1
+            
+        results.sort(lambda x, y: cmp(x['name'], y['name']))
+        return results    

Added: Zope3/trunk/src/zope/app/apidoc/ifacemodule/static_menu.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/static_menu.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/static_menu.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,51 @@
+<html metal:use-macro="views/apidoc_macros/static_menu"
+    i18n:domain="zope">
+<body>
+
+  <div metal:fill-slot="menu" class="small">
+
+
+    <div>
+      <span i18n:translate="">Interface Finder:</span>
+    </div>
+    <form action="" method="post"
+          tal:attributes="action request/URL" name="searchform">
+	<!--
+      <input type="checkbox" name="name_only" value="on" checked="checked" />
+      <tal:block i18n:translate="">name only search</tal:block>
+		-->
+      <br />
+      <input type="text" name="search_str" 
+             style="font-size: 80%; width=95%"
+             tal:attributes="value request/search_str|nothing" 
+		     onKeyup="javascript:simplegetSearchResult(document.searchform.search_str.value)" />
+	  <!--	
+      <input type="button" name="Find" value="Find" 
+		  onClick="javascript:getSearchResult(document.searchform.search_str.value)"
+             i18n:attributes="value find-button" style="font-size: 80%"/>
+	  -->
+    </form>
+
+    <div>
+      <span i18n:translate="">Search results:</span><br /><br />
+    </div>	  
+    <div tal:define="ifaces view/findAllInterfaces"
+         tal:condition="ifaces" id="resultlist">
+
+      <div tal:repeat="info ifaces" style="display:block" tal:attributes="id info/counter ; doc info/doc">
+        <a href="" target="main"
+           tal:attributes="href info/url"
+           tal:content="info/name">
+          zope.app.component.interfaces.ILocalSiteManager
+        </a>
+      </div>
+    </div>
+
+  </div>
+
+  <p metal:fill-slot="post_menu" class="small" i18n:translate="">
+    Note: These are only interfaces that are registered with the site manager.
+  </p>
+
+</body>
+</html>


Property changes on: Zope3/trunk/src/zope/app/apidoc/ifacemodule/static_menu.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/apidoc/typemodule/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/typemodule/configure.zcml	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/typemodule/configure.zcml	2005-10-09 10:00:47 UTC (rev 38994)
@@ -26,5 +26,13 @@
       name="menu.html"
       template="menu.pt"
       />
+      
+  <browser:page
+      for=".type.TypeModule"
+      permission="zope.app.apidoc.UseAPIDoc"
+      class=".browser.Menu"
+      name="staticmenu.html"
+      template="static_menu.pt"
+      />      
 
 </configure>

Added: Zope3/trunk/src/zope/app/apidoc/typemodule/static_menu.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/typemodule/static_menu.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/typemodule/static_menu.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,5 @@
+<html metal:use-macro="views/apidoc_macros/static_menu">
+<body>
+
+</body>
+</html>
\ No newline at end of file


Property changes on: Zope3/trunk/src/zope/app/apidoc/typemodule/static_menu.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/apidoc/utilitymodule/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/configure.zcml	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/configure.zcml	2005-10-09 10:00:47 UTC (rev 38994)
@@ -27,6 +27,13 @@
       class=".browser.Menu"
       name="menu.html"
       template="menu.pt" />
+      
+  <browser:page
+      for=".utilitymodule.UtilityModule"
+      permission="zope.app.apidoc.UseAPIDoc"
+      class=".browser.Menu"
+      name="staticmenu.html"
+      template="static_menu.pt" />      
 
   <browser:page
       for=".utilitymodule.Utility"

Added: Zope3/trunk/src/zope/app/apidoc/utilitymodule/static_menu.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/static_menu.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/static_menu.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,5 @@
+<html metal:use-macro="views/apidoc_macros/static_menu">
+<body>
+
+</body>
+</html>
\ No newline at end of file


Property changes on: Zope3/trunk/src/zope/app/apidoc/utilitymodule/static_menu.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/configure.zcml	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/configure.zcml	2005-10-09 10:00:47 UTC (rev 38994)
@@ -29,6 +29,13 @@
     template="menu.pt" />
 
   <browser:page
+    for=".ZCMLModule"
+    class=".browser.Menu"
+    permission="zope.app.apidoc.UseAPIDoc"
+    name="staticmenu.html"
+    template="static_menu.pt" />
+
+  <browser:page
     for=".Directive"
     class=".browser.DirectiveDetails"
     permission="zope.app.apidoc.UseAPIDoc"

Added: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/static_menu.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/static_menu.pt	2005-10-09 09:59:12 UTC (rev 38993)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/static_menu.pt	2005-10-09 10:00:47 UTC (rev 38994)
@@ -0,0 +1,10 @@
+<html metal:use-macro="views/apidoc_macros/static_menu"
+    i18n:domain="zope">
+<body>
+
+  <p metal:fill-slot="pre_menu" class="small" i18n:translate="">
+    Namespaces that are not full URLs start with "http://namespaces.zope.org/".
+  </p>
+
+</body>
+</html>


Property changes on: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/static_menu.pt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Zope3-Checkins mailing list