[Checkins] SVN: z3c.pagelet/trunk/ Add sphinx-based documentation.

Dan Korostelev nadako at gmail.com
Thu Feb 26 10:59:05 EST 2009


Log message for revision 97313:
  Add sphinx-based documentation.

Changed:
  _U  z3c.pagelet/trunk/
  U   z3c.pagelet/trunk/buildout.cfg
  U   z3c.pagelet/trunk/setup.py
  U   z3c.pagelet/trunk/src/z3c/pagelet/README.txt
  A   z3c.pagelet/trunk/src/z3c/pagelet/index.txt

-=-

Property changes on: z3c.pagelet/trunk
___________________________________________________________________
Modified: svn:ignore
   - .installed.cfg
bin
build
develop-eggs
dist
eggs
parts

   + .installed.cfg
bin
build
develop-eggs
dist
eggs
parts
docs


Modified: z3c.pagelet/trunk/buildout.cfg
===================================================================
--- z3c.pagelet/trunk/buildout.cfg	2009-02-26 15:49:41 UTC (rev 97312)
+++ z3c.pagelet/trunk/buildout.cfg	2009-02-26 15:59:04 UTC (rev 97313)
@@ -1,6 +1,6 @@
 [buildout]
 develop = .
-parts = test
+parts = test docs
 
 [test]
 recipe = zc.recipe.testrunner
@@ -11,3 +11,9 @@
 CHAMELEON_DEBUG = False
 CHAMELEON_CACHE = False
 
+[docs]
+recipe = z3c.recipe.sphinxdoc
+eggs = z3c.pagelet [docs]
+build-dir = ${buildout:directory}/docs
+default.css =
+layout.html =

Modified: z3c.pagelet/trunk/setup.py
===================================================================
--- z3c.pagelet/trunk/setup.py	2009-02-26 15:49:41 UTC (rev 97312)
+++ z3c.pagelet/trunk/setup.py	2009-02-26 15:59:04 UTC (rev 97313)
@@ -62,6 +62,7 @@
                 'z3c.pt>=1.0b4',
                 'z3c.ptcompat',
                 ],
+        docs = ['z3c.recipe.sphinxdoc'],
         ),
     install_requires = [
         'setuptools',

Modified: z3c.pagelet/trunk/src/z3c/pagelet/README.txt
===================================================================
--- z3c.pagelet/trunk/src/z3c/pagelet/README.txt	2009-02-26 15:49:41 UTC (rev 97312)
+++ z3c.pagelet/trunk/src/z3c/pagelet/README.txt	2009-02-26 15:59:04 UTC (rev 97313)
@@ -2,6 +2,8 @@
 Pagelets
 ========
 
+.. contents::
+
 This package provides a very flexible base implementation that can be used
 to write view components which can be higly customized later in custom projects.
 This is needed if you have to write reusable components like those needed
@@ -40,7 +42,6 @@
 method returns a IContentTemplate and the __call__ method a ILayoutTemplate
 defined in the z3c.layout package.
 
-  # some test stuff
   >>> import os, tempfile
   >>> temp_dir = tempfile.mkdtemp()
 
@@ -214,6 +215,81 @@
   </html>
 
 
+Context-specific templates
+--------------------------
+
+Pagelets are also able to lookup templates using their context object
+as an additional discriminator, via (self, self.request, self.context)
+lookup. It's useful when you want to provide a custom template for
+some specific content objects. Let's check that out.
+
+First, let's define a custom content type and make an object to work with:
+
+  >>> class IContent(zope.interface.Interface):
+  ...     pass
+  >>> class Content(object):
+  ...     zope.interface.implements(IContent)
+
+  >>> content = Content()
+
+Let's use our view class we defined earlier. Currently, it will use
+the layout and content templates we defined for (view, request) before:
+
+  >>> myView = MyView(content, request)
+  >>> print myView()
+  <html>
+    <body>
+      <div class="layout">
+        <div class="content">
+          my template content
+        </div>
+      </div>
+    </body>
+  </html>
+
+Let's create context-specific layout and content templates and register
+them for our IContent interface:
+
+  >>> contextLayoutTemplate = os.path.join(temp_dir, 'contextLayoutTemplate.pt')
+  >>> open(contextLayoutTemplate, 'w').write('''
+  ...   <html>
+  ...     <body>
+  ...       <div class="context-layout" tal:content="structure provider:pagelet">
+  ...         here comes the context-specific content
+  ...       </div>
+  ...     </body>
+  ...   </html>
+  ... ''')
+  >>> factory = TemplateFactory(contextLayoutTemplate, 'text/html')
+  >>> zope.component.provideAdapter(
+  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer, IContent),
+  ...     ILayoutTemplate)
+ 
+  >>> contextContentTemplate = os.path.join(temp_dir, 'contextContentTemplate.pt')
+  >>> open(contextContentTemplate, 'w').write('''
+  ...   <div class="context-content">
+  ...     my context-specific template content
+  ...   </div>
+  ... ''')
+  >>> factory = TemplateFactory(contextContentTemplate, 'text/html')
+  >>> zope.component.provideAdapter(
+  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer, IContent),
+  ...     IContentTemplate)
+
+Now, our view should use context-specific templates for rendering:
+
+  >>> print myView()
+  <html>
+    <body>
+      <div class="context-layout">
+        <div class="context-content">
+          my context-specific template content
+        </div>
+      </div>
+    </body>
+  </html>
+
+
 Add, Edit and Display forms (formlib)
 -------------------------------------
 
@@ -383,81 +459,6 @@
   </html>
 
 
-Context-specific templates
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Pagelets are also able to lookup templates using their context object
-as an additional discriminator, via (self, self.request, self.context)
-lookup. It's useful when you want to provide a custom template for
-some specific content objects. Let's check that out.
-
-First, let's define a custom content type and make an object to work with:
-
-  >>> class IContent(zope.interface.Interface):
-  ...     pass
-  >>> class Content(object):
-  ...     zope.interface.implements(IContent)
-
-  >>> content = Content()
-
-Let's use our view class we defined earlier. Currently, it will use
-the layout and content templates we defined for (view, request) before:
-
-  >>> myView = MyView(content, request)
-  >>> print myView()
-  <html>
-    <body>
-      <div class="layout">
-        <div class="content">
-          my template content
-        </div>
-      </div>
-    </body>
-  </html>
-
-Let's create context-specific layout and content templates and register
-them for our IContent interface:
-
-  >>> contextLayoutTemplate = os.path.join(temp_dir, 'contextLayoutTemplate.pt')
-  >>> open(contextLayoutTemplate, 'w').write('''
-  ...   <html>
-  ...     <body>
-  ...       <div class="context-layout" tal:content="structure provider:pagelet">
-  ...         here comes the context-specific content
-  ...       </div>
-  ...     </body>
-  ...   </html>
-  ... ''')
-  >>> factory = TemplateFactory(contextLayoutTemplate, 'text/html')
-  >>> zope.component.provideAdapter(
-  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer, IContent),
-  ...     ILayoutTemplate)
- 
-  >>> contextContentTemplate = os.path.join(temp_dir, 'contextContentTemplate.pt')
-  >>> open(contextContentTemplate, 'w').write('''
-  ...   <div class="context-content">
-  ...     my context-specific template content
-  ...   </div>
-  ... ''')
-  >>> factory = TemplateFactory(contextContentTemplate, 'text/html')
-  >>> zope.component.provideAdapter(
-  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer, IContent),
-  ...     IContentTemplate)
-
-Now, our view should use context-specific templates for rendering:
-
-  >>> print myView()
-  <html>
-    <body>
-      <div class="context-layout">
-        <div class="context-content">
-          my context-specific template content
-        </div>
-      </div>
-    </body>
-  </html>
-
-
 Cleanup
 -------
 

Added: z3c.pagelet/trunk/src/z3c/pagelet/index.txt
===================================================================
--- z3c.pagelet/trunk/src/z3c/pagelet/index.txt	                        (rev 0)
+++ z3c.pagelet/trunk/src/z3c/pagelet/index.txt	2009-02-26 15:59:04 UTC (rev 97313)
@@ -0,0 +1,17 @@
+Welcome to z3c.pagelet's documentation!
+=======================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 3
+
+   README
+   zcml
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`



More information about the Checkins mailing list