[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/apidoc/ Improved apidoc generation quiet a bit:

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Oct 29 04:09:00 EDT 2005


Log message for revision 39713:
  Improved apidoc generation quiet a bit:
  
  - Fixed function documentation page and added test.
  
  - The logic for creating links in ZCML files were broken; fixed that.
  
  - Improved utility display; fixed some final bugs in the name handling.
  
  - Use configuration context instead of file for the ZCML module. This 
    makes the initial use of the ZCML module a lot faster.
  
  Now the static apidoc generator only loads 16k links and runs in about an 
  hour.
  
  

Changed:
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/function.py
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/function_index.pt
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/module.py
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/zcml.py
  U   Zope3/trunk/src/zope/app/apidoc/component.py
  U   Zope3/trunk/src/zope/app/apidoc/component.txt
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/component_macros.pt
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/iface_macros.pt
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/ifacemodule.py
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/index.pt
  U   Zope3/trunk/src/zope/app/apidoc/static.py
  U   Zope3/trunk/src/zope/app/apidoc/utilitymodule/utilitymodule.py
  U   Zope3/trunk/src/zope/app/apidoc/zcmlmodule/README.txt
  U   Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py
  U   Zope3/trunk/src/zope/app/apidoc/zcmlmodule/tests.py

-=-
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt	2005-10-29 08:08:59 UTC (rev 39713)
@@ -218,7 +218,18 @@
    'type_link': '__builtin__/bool',
    'value': 'True'}
 
+`getBaseURL()`
+~~~~~~~~~~~~~~
 
+Return the URL for the API Documentation Tool.
+
+Note that the following output is a bit different than usual, since
+we have not setup all path elements.
+
+  >>> details.getBaseURL()
+  'http://127.0.0.1'
+
+
 Text File Details
 -----------------
 

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/function.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/function.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/function.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -17,6 +17,7 @@
 """
 __docformat__ = 'restructuredtext'
 from zope.app import zapi
+from zope.app.apidoc.interfaces import IDocumentationModule
 from zope.app.apidoc.utilities import getPythonPath, renderText
 
 class FunctionDetails(object):
@@ -34,5 +35,11 @@
                  'value': `attr`,
                  'type': type(attr).__name__,
                  'type_link': getPythonPath(type(attr)).replace('.', '/')}
-                
+
                 for name, attr in self.context.getAttributes()]
+
+
+    def getBaseURL(self):
+        """Return the URL for the API Documentation Tool."""
+        m = zapi.getUtility(IDocumentationModule, "Code")
+        return zapi.absoluteURL(zapi.getParent(m), self.request)

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/function_index.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/function_index.pt	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/function_index.pt	2005-10-29 08:08:59 UTC (rev 39713)
@@ -25,7 +25,7 @@
     </div>
   </div>
 
-  <div 
+  <div
       tal:define="attributes view/getAttributes"
       tal:condition="attributes">
 

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/module.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/module.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/module.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -66,7 +66,7 @@
 
         We cannot reuse the the system's bread crumbs, since they go all the
         way up to the root, but we just want to go to the root module."""
-        names = self.context.getPath().split('.') 
+        names = self.context.getPath().split('.')
         crumbs = []
         module = self.context
         # I really need the class here, so remove the proxy.

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/zcml.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/zcml.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/zcml.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -77,16 +77,25 @@
             ns = 'ALL'
         return '%s/../ZCML/%s/%s/index.html' %(
             zapi.absoluteURL(findDocModule(self), self.request), ns, name)
-        
+
     def ifaceURL(self, value, field, rootURL):
         bound = field.bind(self.context.context)
         iface = bound.fromUnicode(value)
+        if iface is None:
+            return
         return rootURL+'/../Interface/%s/apiindex.html' %(getPythonPath(iface))
-  
+
     def objectURL(self, value, field, rootURL):
         bound = field.bind(self.context.context)
         obj = bound.fromUnicode(value)
-        if IInterface.providedBy(obj):
+        if obj is None:
+            return
+        try:
+            isInterface = IInterface.providedBy(obj)
+        except AttributeError:
+            # probably an object that does not like to play nice with the CA
+            isInterface = False
+        if isInterface:
             return rootURL+'/../Interface/%s/apiindex.html' %(
                 getPythonPath(obj))
         try:
@@ -109,7 +118,7 @@
             field = context.schema.get(name)
             if zapi.isinstance(field, GlobalInterface):
                 attr['url'] = self.ifaceURL(attr['value'], field, rootURL)
-                
+
             elif zapi.isinstance(field, GlobalObject):
                 attr['url'] = self.objectURL(attr['value'], field, rootURL)
 
@@ -122,17 +131,15 @@
                         attr['url'] = self.ifaceURL(values[0], field, rootURL)
                     elif zapi.isinstance(field, GlobalObject):
                         attr['url'] = self.objectURL(values[0], field, rootURL)
-                    break
-                    
-                for value in values: 
-                    if zapi.isinstance(field, GlobalInterface):
-                        url = self.ifaceURL(value, field, rootURL)
-                    elif zapi.isinstance(field, GlobalObject):
-                        url = self.objectURL(value, field, rootURL)
-                    else:
-                        break
-                    attr['values'].append({'value': value, 'url': url})
-                    
+                else:
+                    for value in values:
+                        if zapi.isinstance(field, GlobalInterface):
+                            url = self.ifaceURL(value, field, rootURL)
+                        elif zapi.isinstance(field, GlobalObject):
+                            url = self.objectURL(value, field, rootURL)
+                        else:
+                            break
+                        attr['values'].append({'value': value, 'url': url})
 
         # Make sure that the attributes are in the same order they are defined
         # in the schema.

Modified: Zope3/trunk/src/zope/app/apidoc/component.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/component.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/component.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -26,9 +26,10 @@
 
 from zope.app import zapi
 from zope.app.i18n import ZopeMessageFactory as _
+from zope.app.apidoc.classregistry import classRegistry
 from zope.app.apidoc.utilities import relativizePath, truncateSysPath
 from zope.app.apidoc.utilities import getPythonPath, renderText
-from zope.app.apidoc.classregistry import classRegistry
+from zope.app.apidoc.utilitymodule import utilitymodule
 
 SPECIFIC_INTERFACE_LEVEL = 1
 EXTENDED_INTERFACE_LEVEL = 2
@@ -219,8 +220,12 @@
     else:
         klass = reg.component.__class__
 
+    # provided interface id
+    iface_id = '%s.%s' % (reg.provided.__module__, reg.provided.getName())
+
     path = getPythonPath(klass)
     return {'name': reg.name or _('<i>no name</i>'),
-            'url_name': reg.name or '__noname__',
+            'url_name': utilitymodule.encodeName(reg.name or '__noname__'),
+            'iface_id': iface_id,
             'path': path,
             'url': path.replace('.', '/')}

Modified: Zope3/trunk/src/zope/app/apidoc/component.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/component.txt	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/component.txt	2005-10-29 08:08:59 UTC (rev 39713)
@@ -6,7 +6,7 @@
 interacts with other components in Zope 3. The functions in
 
   >>> from zope.app.apidoc import component
- 
+
 provide you with utilities to make those discoveries. The functions are
 explained in detail in this document. Before we start though, we have to have
 some interfaces to work with:
@@ -44,7 +44,7 @@
   >>> regs = list(component.getRequiredAdapters(IFoo))
   >>> regs.sort()
   >>> regs
-  [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''), 
+  [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
    AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
    SubscriptionRegistration(('IFoo',), None, 'stubFactory', '')]
 
@@ -55,8 +55,8 @@
   >>> regs = list(component.getRequiredAdapters(IFoo, withViews=True))
   >>> regs.sort()
   >>> regs
-  [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''), 
-   AdapterRegistration(('IFoo', 'IRequest'), 'ISpecialResult', '', None, ''), 
+  [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
+   AdapterRegistration(('IFoo', 'IRequest'), 'ISpecialResult', '', None, ''),
    AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
    SubscriptionRegistration(('IFoo',), None, 'stubFactory', '')]
 
@@ -66,7 +66,7 @@
   >>> regs = list(component.getRequiredAdapters(IFoo))
   >>> regs.sort()
   >>> regs
-  [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''), 
+  [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
    AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
    SubscriptionRegistration(('IFoo',), None, 'stubFactory', '')]
 
@@ -158,7 +158,7 @@
   >>> from zope.component.interfaces import IFactory
   >>> ztapi.provideUtility(IFactory, Factory(MyFoo), 'MyFoo')
   >>> ztapi.provideUtility(IFactory, Factory(MyBar), 'MyBar')
-  >>> ztapi.provideUtility(IFactory, 
+  >>> ztapi.provideUtility(IFactory,
   ...     Factory(MyFooBar, 'MyFooBar', 'My Foo Bar'), 'MyFooBar')
 
 Let's see whether we will be able to get them:
@@ -166,15 +166,15 @@
   >>> regs = list(component.getFactories(IFooBar))
   >>> regs.sort()
   >>> regs
-  [UtilityRegistration('IFactory', 'MyFooBar', 
+  [UtilityRegistration('IFactory', 'MyFooBar',
                        <Factory for <class 'MyFooBar'>>, '')]
 
   >>> regs = list(component.getFactories(IFoo))
   >>> regs.sort()
   >>> regs
-  [UtilityRegistration('IFactory', 'MyFoo', 
+  [UtilityRegistration('IFactory', 'MyFoo',
                        <Factory for <class 'MyFoo'>>, ''),
-   UtilityRegistration('IFactory', 'MyFooBar', 
+   UtilityRegistration('IFactory', 'MyFooBar',
                        <Factory for <class 'MyFooBar'>>, '')]
 
 
@@ -200,7 +200,7 @@
   >>> regs = list(component.getUtilities(IFoo))
   >>> regs.sort()
   >>> regs #doctest:+ELLIPSIS
-  [UtilityRegistration('IFoo', '', <MyFoo object at ...>, ''), 
+  [UtilityRegistration('IFoo', '', <MyFoo object at ...>, ''),
    UtilityRegistration('IFooBar', '', <MyFooBar object at ...>, '')]
 
 
@@ -295,7 +295,8 @@
 
   >>> pprint(component.getUtilityInfoDictionary(
   ...     component.getUtilities(IFooBar).next()))
-  {'name': u'<i>no name</i>',
+  {'iface_id': '__builtin__.IFooBar',
+   'name': u'<i>no name</i>',
    'path': '__builtin__.MyFooBar',
    'url': '__builtin__/MyFooBar',
-   'url_name': '__noname__'}
+   'url_name': 'X19ub25hbWVfXw=='}

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt	2005-10-29 08:08:59 UTC (rev 39713)
@@ -102,25 +102,25 @@
 
   >>> class IFoo(zope.interface.Interface):
   ...     """This is the Foo interface
-  ... 
+  ...
   ...     More description here...
   ...     """
   ...     foo = zope.interface.Attribute('This is foo.')
   ...     bar = zope.interface.Attribute('This is bar.')
-  ... 
+  ...
   ...     title = zope.schema.TextLine(
-  ...         description=u'Title', 
-  ...         required=True, 
+  ...         description=u'Title',
+  ...         required=True,
   ...         default=u'Foo')
   ...
   ...     description = zope.schema.Text(
-  ...         description=u'Desc', 
+  ...         description=u'Desc',
   ...         required=False,
   ...         default=u'Foo.')
-  ... 
+  ...
   ...     def blah():
   ...         """This is blah."""
-  ...     
+  ...
   ...     def get(key, default=None):
   ...         """This is get."""
 
@@ -347,7 +347,8 @@
 Return all utilities that provide this interface.
 
   >>> pprint(details.getUtilities())
-  [{'name': 'The Foo',
+  [{'iface_id': '__builtin__.IFoo',
+    'name': 'The Foo',
     'path': '__builtin__.Foo',
     'url': '__builtin__/Foo',
-    'url_name': 'The Foo'}]
\ No newline at end of file
+    'url_name': 'VGhlIEZvbw=='}]
\ No newline at end of file

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/component_macros.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/component_macros.pt	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/component_macros.pt	2005-10-29 08:08:59 UTC (rev 39713)
@@ -1,10 +1,10 @@
 <metal:block define-macro="ifacename"
-  ><span tal:replace="iface/module" />.<u tal:content="iface/name" 
+  ><span tal:replace="iface/module" />.<u tal:content="iface/name"
 /></metal:block>
 
 <metal:block define-macro="zcml" i18n:domain="zope">
   <a href=""
-      tal:attributes="href 
+      tal:attributes="href
         string:../../Code/${zcml/url}/index.html?line=${zcml/line}#${zcml/line}"
       tal:content="zcml/file">
     zope/app/configure.zcml
@@ -19,10 +19,10 @@
     <b><code>
       <a href=""
             tal:attributes="href
-                string:$rootURL/Code/${adapter/factory_url}/index.html" 
-            tal:content="adapter/factory" 
+                string:$rootURL/Code/${adapter/factory_url}/index.html"
+            tal:content="adapter/factory"
             tal:condition="adapter/factory_url" />
-      <span tal:content="adapter/factory" 
+      <span tal:content="adapter/factory"
             tal:condition="not: adapter/factory_url" />
     </code></b>
     <span tal:condition="adapter/name" i18n:translate="">
@@ -30,20 +30,20 @@
     </span>
   </div>
 
-  <div tal:condition="adapter/zcml" 
+  <div tal:condition="adapter/zcml"
        tal:define="zcml adapter/zcml">
-    <i i18n:translate="">registered:</i> 
+    <i i18n:translate="">registered:</i>
     <metal:block use-macro="context/@@interface_macros/zcml" />
   </div>
 
   <div>
-    <i i18n:translate="">requires:</i> 
+    <i i18n:translate="">requires:</i>
     <tal:block repeat="iface adapter/required">
       <a href=""
           tal:condition="iface"
-          tal:attributes="href 
+          tal:attributes="href
               string:../${iface/module}.${iface/name}/apiindex.html">
-        <metal:block use-macro="context/@@interface_macros/ifacename" 
+        <metal:block use-macro="context/@@interface_macros/ifacename"
         /></a><tal:block condition="not:repeat/iface/end">, </tal:block>
     </tal:block>
     <span tal:condition="not:adapter/required" i18n:translate="">
@@ -52,20 +52,20 @@
   </div>
 
   <div tal:define="iface adapter/provided">
-    <i i18n:translate="">provides:</i> 
+    <i i18n:translate="">provides:</i>
     <a href=""
         tal:condition="iface"
         tal:attributes="href
               string:../${iface/module}.${iface/name}/apiindex.html">
       <metal:block use-macro="context/@@interface_macros/ifacename" />
-    </a>  
+    </a>
     <span tal:condition="not:iface" i18n:translate="">
       No interface provided.
     </span>
   </div>
 
   <div tal:condition="adapter/doc">
-    <i i18n:translate="">registration info:</i> 
+    <i i18n:translate="">registration info:</i>
     <span tal:content="adapter/doc">reg info</span>
   </div>
 
@@ -82,15 +82,16 @@
 
 <metal:block define-macro="utility" i18n:domain="zope">
   <a href=""
-     tal:attributes="href 
-         string:$rootURL/Utility/${view/getId}/${utility/url_name}/index.html"
+     tal:attributes="href
+   string:${rootURL}/Utility/${utility/iface_id}/${utility/url_name}/index.html"
      tal:content="structure utility/name" />
   <br />
-  <div><span i18n:translate="">Class:</span> <code>
+  <div style="padding-bottom: 3pt;"><span class="small">
+    <span i18n:translate="">Class:</span> <code style="font-size: 100%">
     <a href=""
        tal:attributes="href string:$rootURL/Code/${utility/url}/index.html"
        tal:content="utility/path" />
-  </code></div>              
+  </code></span></div>
 </metal:block>
 
 

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/iface_macros.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/iface_macros.pt	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/iface_macros.pt	2005-10-29 08:08:59 UTC (rev 39713)
@@ -28,7 +28,7 @@
 
 
 <metal:block define-macro="method">
-  <b><code 
+  <b><code
       tal:content="string:${method/name}${method/signature}" />
   </b><br>
   <div class="inline-documentation" tal:content="structure method/doc">

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/ifacemodule.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/ifacemodule.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/ifacemodule.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -66,7 +66,7 @@
     def get(self, key, default=None):
         """See zope.app.interfaces.container.IReadContainer"""
         iface = queryInterface(key, default)
-        if iface is default: 
+        if iface is default:
             # Yeah, we find more items than we claim to have! This way we can
             # handle all interfaces using this module. :-)
             parts = key.split('.')

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/index.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/index.pt	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/index.pt	2005-10-29 08:08:59 UTC (rev 39713)
@@ -8,12 +8,12 @@
   </h1>
 
   <h3 tal:condition="view/getTypes">
-    Type: 
+    Type:
     <tal:omit-tag tal:repeat="type view/getTypes" >
       <a href=""
-          tal:attributes="href 
+          tal:attributes="href
               string:${rootURL}/Interface/${type/path}/apiindex.html"
-          tal:content="type/name"/><tal:block 
+          tal:content="type/name"/><tal:block
           condition="not:repeat/type/end">, </tal:block>
     </tal:omit-tag>
   </h3>
@@ -30,20 +30,20 @@
 
   <div class="indent"
          tal:define="bases view/getBases">
-    
+
     <ul class="attr-list" tal:condition="bases">
       <li tal:repeat="base bases">
         <a href=""
-           tal:attributes="href 
+           tal:attributes="href
                string:${rootURL}/Interface/$base/apiindex.html"
            tal:content="base" />
       </li>
     </ul>
-    
+
     <p tal:condition="not: bases">
       <em i18n:translate="">There are no base interfaces.</em>
     </p>
-    
+
   </div>
 
 
@@ -57,17 +57,17 @@
   </tal:block>
 
   <h2 class="details-section" i18n:translate="">Adapters</h2>
-  
+
   <div tal:define="specific_adapters view/getSpecificRequiredAdapters;
                    extended_adapters view/getExtendedRequiredAdapters;
                    generic_adapters view/getGenericRequiredAdapters;
                    provided_adapters view/getProvidedAdapters">
 
-    <div class="indent" 
+    <div class="indent"
          tal:condition="python: specific_adapters or generic_adapters">
-    
+
       <h3 i18n:translate="">Adapters where this interface is required:</h3>
-    
+
       <div tal:define="
   elementId string:adapters.required.specific;
   show context/++preferences++apidoc/InterfaceDetails/showSpecificRequiredAdapters">
@@ -78,20 +78,20 @@
         </h4>
         <metal:block use-macro="context/@@apidoc_macros/display" >
         <div metal:fill-slot="content">
-          <ul class="attr-list" 
+          <ul class="attr-list"
               tal:condition="specific_adapters">
             <li tal:repeat="adapter specific_adapters">
               <metal:block use-macro="context/@@interface_macros/adapter" />
             </li>
           </ul>
           <p tal:condition="not:specific_adapters">
-            <em i18n:translate="">There are no specific adapters registered 
+            <em i18n:translate="">There are no specific adapters registered
                 for this interface.</em>
           </p>
         </div>
         </metal:block>
       </div>
-    
+
       <div tal:define="
   elementId string:adapters.required.extended;
   show context/++preferences++apidoc/InterfaceDetails/showExtendedRequiredAdapters">
@@ -102,7 +102,7 @@
         </h4>
         <metal:block use-macro="context/@@apidoc_macros/display" >
         <div metal:fill-slot="content">
-          <ul class="attr-list" 
+          <ul class="attr-list"
               tal:condition="extended_adapters">
             <li tal:repeat="adapter extended_adapters">
               <metal:block use-macro="context/@@interface_macros/adapter" />
@@ -140,21 +140,21 @@
         </div>
         </metal:block>
       </div>
-    
+
     </div>
-    
-    <div class="indent" 
+
+    <div class="indent"
          tal:condition="provided_adapters">
-    
+
       <h3 i18n:translate="">Adapters that provide this interface:</h3>
       <ul>
         <li tal:repeat="adapter provided_adapters">
           <metal:block use-macro="context/@@interface_macros/adapter" />
         </li>
       </ul>
-    
+
     </div>
-    
+
     <p tal:condition="
        python: not (specific_adapters or extended_adapters or generic_adapters
                     or provided_adapters)">
@@ -174,9 +174,9 @@
         specific_views view/specificBrowserViews;
         extended_views view/extendedBrowserViews;
         generic_views view/genericBrowserViews;
-        show 
+        show
         context/++preferences++apidoc/InterfaceDetails/showBrowserViews;
-        show_specific 
+        show_specific
         context/++preferences++apidoc/InterfaceDetails/showSpecificBrowserViews;
         show_extended
         context/++preferences++apidoc/InterfaceDetails/showExtendedBrowserViews;
@@ -193,9 +193,9 @@
         specific_views view/specificXMLRPCViews;
         extended_views view/extendedXMLRPCViews;
         generic_views view/genericXMLRPCViews;
-        show 
+        show
         context/++preferences++apidoc/InterfaceDetails/showXMLRPCViews;
-        show_specific 
+        show_specific
         context/++preferences++apidoc/InterfaceDetails/showSpecificXMLRPCViews;
         show_extended
         context/++preferences++apidoc/InterfaceDetails/showExtendedXMLRPCViews;
@@ -212,9 +212,9 @@
           specific_views view/specificHTTPViews;
           extended_views view/extendedHTTPViews;
           generic_views view/genericHTTPViews;
-          show 
+          show
           context/++preferences++apidoc/InterfaceDetails/showHTTPViews;
-          show_specific 
+          show_specific
           context/++preferences++apidoc/InterfaceDetails/showSpecificHTTPViews;
           show_extended
           context/++preferences++apidoc/InterfaceDetails/showExtendedHTTPViews;
@@ -231,9 +231,9 @@
           specific_views view/specificFTPViews;
           extended_views view/extendedFTPViews;
           generic_views view/genericFTPViews;
-          show 
+          show
           context/++preferences++apidoc/InterfaceDetails/showFTPViews;
-          show_specific 
+          show_specific
           context/++preferences++apidoc/InterfaceDetails/showSpecificFTPViews;
           show_extended
           context/++preferences++apidoc/InterfaceDetails/showExtendedFTPViews;
@@ -250,9 +250,9 @@
           specific_views view/specificOtherViews;
           extended_views view/extendedOtherViews;
           generic_views view/genericOtherViews;
-          show 
+          show
           context/++preferences++apidoc/InterfaceDetails/showOtherViews;
-          show_specific 
+          show_specific
           context/++preferences++apidoc/InterfaceDetails/showSpecificOtherViews;
           show_extended
           context/++preferences++apidoc/InterfaceDetails/showExtendedOtherViews;
@@ -273,9 +273,9 @@
        tal:condition="python: factories or utilities or classes">
 
     <h2 class="details-section" i18n:translate="">Other Information</h2>
-    
+
     <div class="indent">
-    
+
       <tal:block condition="factories">
         <h3 class="details-section" i18n:translate="">Factories</h3>
         <div class="indent">
@@ -290,12 +290,12 @@
           </ul>
         </div>
       </tal:block>
-    
+
       <tal:block condition="utilities">
         <h3 class="details-section" i18n:translate="">Utilities</h3>
         <div class="indent">
           <div class="small" i18n:translate="">
-            A list of utilities that are registered to provide this 
+            A list of utilities that are registered to provide this
             interface.
           </div>
           <ul>
@@ -305,13 +305,13 @@
           </ul>
         </div>
       </tal:block>
-    
+
       <tal:block condition="classes">
         <h3 class="details-section" i18n:translate="">Classes</h3>
         <div class="indent">
           <div class="small" i18n:translate="">
             A list of classes that implement this interface. This might
-            duplicate the entries in Utilities. 
+            duplicate the entries in Utilities.
           </div>
           <ul>
             <li tal:repeat="klass classes">
@@ -320,7 +320,7 @@
           </ul>
         </div>
       </tal:block>
-    
+
     </div>
   </div>
 

Modified: Zope3/trunk/src/zope/app/apidoc/static.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/static.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/static.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -30,7 +30,7 @@
 from zope.app.testing import functional
 
 # Setup the user feedback detail level.
-VERBOSITY = 4
+VERBOSITY = 2
 
 VERBOSITY_MAP = {1: 'ERROR', 2: 'WARNING', 3: 'INFO'}
 
@@ -185,6 +185,7 @@
             self.linkQueue.append(link)
         self.rootDir = os.path.join(os.path.dirname(__file__), BASE_DIR)
         self.maxWidth = getMaxWidth()-13
+        self.needNewLine = False
 
     def start(self):
         """Start the retrieval of the apidoc."""
@@ -226,14 +227,17 @@
             sys.stdout.write('\r' + ' '*(self.maxWidth+13))
             sys.stdout.write('\rLink %5d: %s' % (self.counter, url))
             sys.stdout.flush()
+            self.needNewLine = True
 
     def sendMessage(self, msg, verbosity=4):
         if VERBOSITY >= verbosity:
-            sys.stdout.write('\n')
+            if self.needNewLine:
+                sys.stdout.write('\n')
             sys.stdout.write(VERBOSITY_MAP.get(verbosity, 'INFO')+': ')
             sys.stdout.write(msg)
             sys.stdout.write('\n')
             sys.stdout.flush()
+            self.needNewLine = False
 
     def processLink(self, link):
         """Process a link."""
@@ -249,10 +253,12 @@
             # Something went wrong with retrieving the page.
             self.sendMessage(
                 '%s (%i): %s' % (error.msg, error.code, link.callableURL), 2)
+            self.sendMessage('+-> Reference: ' + link.referenceURL, 2)
             return
-        except ValueError:
+        except (urllib2.URLError, ValueError):
             # We had a bad URL running the publisher browser
             self.sendMessage('Bad URL: ' + link.callableURL, 2)
+            self.sendMessage('+-> Reference: ' + link.referenceURL, 2)
             return
 
         # Make sure the directory exists and get a file path.

Modified: Zope3/trunk/src/zope/app/apidoc/utilitymodule/utilitymodule.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/utilitymodule.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/utilitymodule.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -33,7 +33,9 @@
 NONAME = '__noname__'
 
 def encodeName(name):
-    return base64.encodestring(name.encode('utf-8')).strip()
+    # base64 strings can have lines at most 76 chars long; so make sure we get
+    # rid of all newline chars. See RFC-3548.
+    return base64.encodestring(name.encode('utf-8')).replace('\n', '')
 
 def decodeName(name):
     try:

Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/README.txt	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/README.txt	2005-10-29 08:08:59 UTC (rev 39713)
@@ -3,7 +3,7 @@
 =============================
 
 This documentation module provides you with a complete reference of all
-directives available on your Zope 3 installation. 
+directives available on your Zope 3 installation.
 
 
 `ZCMLModule` class

Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -16,7 +16,7 @@
 The ZCML documentation module reads all of the meta directives (but does not
 execute them) and uses the collected data to generate the tree. The result of
 the evaluation is stored in thread-global variables, so that we have to parse
-the files only once. 
+the files only once.
 
 $Id$
 """
@@ -45,7 +45,7 @@
     """Un-quotes a namespace from a URL-secure version."""
     ns = ns.replace('_sl_', '/')
     ns = ns.replace('_co_', ':')
-    return ns    
+    return ns
 
 
 class Namespace(ReadContainerBase):
@@ -84,7 +84,7 @@
         sd = subdirs.get((ns, key), [])
         directive = Directive(self, key, schema, handler, info, sd)
         return directive
-    
+
     def items(self):
         """See zope.app.container.interfaces.IReadContainer"""
         list = []
@@ -92,8 +92,8 @@
             list.append((key, self.get(key)))
         list.sort()
         return list
-        
 
+
 class Directive(object):
     """Represents a ZCML Directive."""
 
@@ -106,8 +106,8 @@
         self.handler = handler
         self.info = info
         self.subdirs = subdirs
-    
 
+
 class ZCMLModule(ReadContainerBase):
     r"""Represent the Documentation of all ZCML namespaces.
 
@@ -137,9 +137,7 @@
         # Some trivial caching
         global namespaces
         global subdirs
-        context = xmlconfig.file(
-            zope.app.appsetup.appsetup.getConfigSource(),
-            execute=False)
+        context = zope.app.appsetup.appsetup.getConfigContext()
         namespaces, subdirs = docutils.makeDocStructures(context)
 
         # Empty keys are not so good for a container
@@ -152,7 +150,7 @@
         """See zope.app.container.interfaces.IReadContainer
 
         Get the namespace by name; long and abbreviated names work.
-        """        
+        """
         if namespaces is None or subdirs is None:
             self._makeDocStructure()
 
@@ -162,8 +160,8 @@
 
         full_key = 'http://namespaces.zope.org/' + key
         if namespaces.has_key(full_key):
-            return Namespace(self, full_key)        
-        
+            return Namespace(self, full_key)
+
         return default
 
 
@@ -185,6 +183,6 @@
     global subdirs
     namespaces = None
     subdirs = None
-    
+
 from zope.testing.cleanup import addCleanUp
 addCleanUp(_clear)

Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/tests.py	2005-10-29 08:02:08 UTC (rev 39712)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/tests.py	2005-10-29 08:08:59 UTC (rev 39713)
@@ -17,6 +17,7 @@
 """
 import os
 import unittest
+from zope.configuration import xmlconfig
 from zope.testing import doctest, doctestunit
 from zope.app.testing import placelesssetup, ztapi
 from zope.app.apidoc.tests import Root
@@ -25,7 +26,7 @@
 from zope.app.location.traversing import LocationPhysicallyLocatable
 from zope.app.traversing.interfaces import IPhysicallyLocatable
 from zope.app.tree.interfaces import IUniqueId
-from zope.app.tree.adapters import LocationUniqueId 
+from zope.app.tree.adapters import LocationUniqueId
 
 from zope.app.apidoc.zcmlmodule import Namespace, Directive
 from zope.app.apidoc.zcmlmodule import ZCMLModule
@@ -39,15 +40,17 @@
     ztapi.provideAdapter(None, IPhysicallyLocatable,
                          LocationPhysicallyLocatable)
 
+    config_file = os.path.join(os.path.dirname(zope.app.__file__), 'meta.zcml')
+
     # Fix up path for tests.
-    global old_source_file
-    old_source_file = zope.app.appsetup.appsetup.__config_source
-    zope.app.appsetup.appsetup.__config_source = os.path.join(
-        os.path.dirname(zope.app.__file__), 'meta.zcml')
+    global old_context
+    old_context = zope.app.appsetup.appsetup.getConfigContext()
+    zope.app.appsetup.appsetup.__config_context = xmlconfig.file(
+        config_file, execute=False)
 
 def tearDown(test):
     placelesssetup.tearDown()
-    zope.app.appsetup.appsetup.__config_source = old_source_file    
+    zope.app.appsetup.appsetup.__config_context = old_context
     from zope.app.apidoc import zcmlmodule
     zcmlmodule.namespaces = None
     zcmlmodule.subdirs = None
@@ -61,8 +64,8 @@
 
     ns = Namespace(module, 'http://namespaces.zope.org/browser')
     return Directive(ns, 'page', None, foo, None, ())
-    
 
+
 def test_suite():
     return unittest.TestSuite((
         doctest.DocFileSuite('README.txt',



More information about the Zope3-Checkins mailing list