[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/apidoc/ Fixed the way sub-directives are referenced. This removes a lot of broken

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


Log message for revision 39716:
  Fixed the way sub-directives are referenced. This removes a lot of broken 
  link during static apidoc generation.
  

Changed:
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/directive.pt
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/zcml.py
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/zcml.py
  U   Zope3/trunk/src/zope/app/apidoc/zcmlmodule/index.pt

-=-
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/directive.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/directive.pt	2005-10-29 09:06:37 UTC (rev 39715)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/directive.pt	2005-10-29 09:09:48 UTC (rev 39716)
@@ -11,7 +11,7 @@
       <span class="attributeName" tal:content="attr/name">
         name
       </span>="<a tal:attributes="href attr/url"><span
-           class="attributeValue" 
+           class="attributeValue"
            tal:content="attr/value">value</span></a>"
     </span>
     <span tal:condition="attr/values">
@@ -21,7 +21,7 @@
       <div tal:repeat="entry attr/values">
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <a tal:attributes="href entry/url"><span
-           class="attributeValue" 
+           class="attributeValue"
            tal:content="entry/value">value</span></a>
      </div>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
@@ -31,7 +31,7 @@
   &nbsp;&nbsp;&nbsp;
   <span tal:condition="view/hasSubDirectives">&gt;</span>
   <span tal:condition="not:view/hasSubDirectives">/&gt;</span>
-</div>  
+</div>
 
 <div style="margin-left: 1.5em;">
   <tal:block repeat="element view/getElements">
@@ -41,7 +41,7 @@
 
 <div class="directive"
      tal:condition="view/hasSubDirectives">
-  &lt;/<span class="tagName" 
+  &lt;/<span class="tagName"
              tal:content="view/fullTagName" />&gt;
 
 </div>

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/zcml.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/zcml.py	2005-10-29 09:06:37 UTC (rev 39715)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/zcml.py	2005-10-29 09:09:48 UTC (rev 39716)
@@ -28,6 +28,7 @@
 from zope.app.apidoc.interfaces import IDocumentationModule
 from zope.app.apidoc.utilities import getPythonPath
 
+from zope.app.apidoc.zcmlmodule import quoteNS
 from zope.app.apidoc.codemodule.interfaces import IRootDirective
 
 def findDocModule(obj):
@@ -68,15 +69,24 @@
         return ''
 
     def url(self):
-        context = removeSecurityProxy(self.context)
-        ns, name = context.name
-        ns = ns.replace(':', '_co_')
-        ns = ns.replace('/', '_sl_')
+        directive = removeSecurityProxy(self.context)
+        subDirective = None
+        # Sub-directives are not directly documented, so use parent
+        parent = zapi.getParent(directive)
+        if not (IRootDirective.providedBy(parent) or
+                IRootDirective.providedBy(directive)):
+            subDirective = directive
+            directive = parent
+        ns, name = directive.name
+        ns = quoteNS(ns)
         zcml = zapi.getUtility(IDocumentationModule, 'ZCML')
         if name not in zcml[ns]:
             ns = 'ALL'
-        return '%s/../ZCML/%s/%s/index.html' %(
+        link = '%s/../ZCML/%s/%s/index.html' %(
             zapi.absoluteURL(findDocModule(self), self.request), ns, name)
+        if subDirective:
+            link += '#' + subDirective.name[1]
+        return link
 
     def ifaceURL(self, value, field, rootURL):
         bound = field.bind(self.context.context)

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/zcml.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/zcml.py	2005-10-29 09:06:37 UTC (rev 39715)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/zcml.py	2005-10-29 09:09:48 UTC (rev 39716)
@@ -65,7 +65,7 @@
             self.rootElement = element
         else:
             self.currentElement.subs.append(element)
-            
+
         element.__parent__ = self.currentElement
         self.currentElement = element
 
@@ -78,7 +78,7 @@
 class Directive(object):
     """Representation of a ZCML directive."""
     implements(IDirective)
-        
+
     def __init__(self, name, schema, attrs, context, info, prefixes):
         self.name = name
         self.schema = schema
@@ -110,7 +110,7 @@
         context.package = self.package
 
         # Since we want to use a custom configuration handler, we need to
-        # instantiate the parser object ourselves 
+        # instantiate the parser object ourselves
         parser = make_parser()
         handler = MyConfigHandler(context)
         parser.setContentHandler(handler)

Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/index.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/index.pt	2005-10-29 09:06:37 UTC (rev 39715)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/index.pt	2005-10-29 09:09:48 UTC (rev 39716)
@@ -5,7 +5,7 @@
                   rootURL string:../../..">
 
   <h1 class="details-header">
-    <span tal:replace="context/zope:name" /> 
+    <span tal:replace="context/zope:name" />
     (<span tal:replace="structure view/getNamespaceName" />)
   </h1>
 
@@ -38,7 +38,7 @@
        tal:condition="handler">
     <i i18n:translate="">Handler:</i>
     <a href=""
-       tal:attributes="href 
+       tal:attributes="href
            string:../../../Code/${handler/url}/index.html"
        tal:content="handler/path">
     </a>
@@ -47,7 +47,7 @@
   <h2 class="details-section" i18n:translate="">Schema</h2>
 
   <div class="indent">
-    <a href="" tal:attributes="href 
+    <a href="" tal:attributes="href
            string:../../../Interface/${schema/getId}/apiindex.html">
       <h3 tal:content="schema/getId">zope.fields.Schema</h3>
     </a>
@@ -56,9 +56,9 @@
   <div class="indent"
       tal:define="fields schema/getFields">
 
-  <ul class="attr-list" 
+  <ul class="attr-list"
       tal:condition="fields">
-  
+
     <li tal:repeat="field fields">
       <metal:block use-macro="context/@@interface_macros/field" />
     </li>
@@ -79,8 +79,10 @@
 
   <div class="indent"
        tal:repeat="dir view/getSubdirectives">
+  <a name="dirname"
+     tal:attributes="name dir/name" />
 
-  <h3 tal:content="dir/name"> 
+  <h3 tal:content="dir/name">
     directive
   </h3>
 
@@ -90,11 +92,11 @@
 
   <br />
 
-  <div class="indent" 
+  <div class="indent"
        tal:condition="dir/handler">
     <i i18n:translate="">Handler:</i>
     <a href=""
-       tal:attributes="href 
+       tal:attributes="href
            string:../../../Code/${dir/handler/url}/index.html"
        tal:content="dir/handler/path">
     </a>
@@ -102,7 +104,7 @@
 
   <div class="indent">
     <a href=""
-       tal:attributes="href 
+       tal:attributes="href
            string:../../../Interface/${dir/schema/getId}/apiindex.html">
       <h3 tal:content="dir/schema/getId">zope.fields.Schema</h3>
     </a>
@@ -111,15 +113,15 @@
   <div class="indent"
       tal:define="fields dir/schema/getFields">
 
-    <ul class="attr-list" 
+    <ul class="attr-list"
         tal:condition="fields">
-    
+
       <li tal:repeat="field fields">
         <metal:block use-macro="context/@@interface_macros/field" />
       </li>
-    
+
     </ul>
-    
+
     <p tal:condition="not: fields">
       <em i18n:translate="">There are no fields specified.</em>
     </p>



More information about the Zope3-Checkins mailing list