[Checkins] SVN: z3c.recipe.sphinxdoc/trunk/ add a way to specify custom layout template and css file from buildout config.

Paul Carduner paulcarduner at gmail.com
Mon Jan 19 14:42:39 EST 2009


Log message for revision 94852:
  add a way to specify custom layout template and css file from buildout config.

Changed:
  _U  z3c.recipe.sphinxdoc/trunk/
  U   z3c.recipe.sphinxdoc/trunk/CHANGES.txt
  U   z3c.recipe.sphinxdoc/trunk/src/z3c/recipe/sphinxdoc/__init__.py
  U   z3c.recipe.sphinxdoc/trunk/src/z3c/recipe/sphinxdoc/index.txt

-=-

Property changes on: z3c.recipe.sphinxdoc/trunk
___________________________________________________________________
Modified: svn:ignore
   - bin
develop-eggs
parts

   + bin
develop-eggs
parts
.installed.cfg


Modified: z3c.recipe.sphinxdoc/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.sphinxdoc/trunk/CHANGES.txt	2009-01-19 19:40:40 UTC (rev 94851)
+++ z3c.recipe.sphinxdoc/trunk/CHANGES.txt	2009-01-19 19:42:39 UTC (rev 94852)
@@ -5,7 +5,8 @@
 0.0.6 (unreleased)
 ------------------
 
-- ...
+- Feature: Allow you to specify a url or local file path to your own
+  default.css and layout.html files.
 
 0.0.5 (2008-05-11)
 ------------------

Modified: z3c.recipe.sphinxdoc/trunk/src/z3c/recipe/sphinxdoc/__init__.py
===================================================================
--- z3c.recipe.sphinxdoc/trunk/src/z3c/recipe/sphinxdoc/__init__.py	2009-01-19 19:40:40 UTC (rev 94851)
+++ z3c.recipe.sphinxdoc/trunk/src/z3c/recipe/sphinxdoc/__init__.py	2009-01-19 19:42:39 UTC (rev 94852)
@@ -12,6 +12,7 @@
 #
 ##############################################################################
 
+import urllib2
 import sys
 import os
 from os.path import join, dirname, isdir
@@ -47,6 +48,13 @@
                                  options.get('script', self.name))
         self.egg = zc.recipe.egg.Egg(self.buildout, self.name, self.options)
 
+    def openfile(self, fn):
+        try:
+            f = open(fn)
+        except IOError:
+            f = urllib2.urlopen(fn)
+        return f
+
     def install(self):
         installed = []
         eggs, workingSet = self.egg.working_set()
@@ -75,18 +83,28 @@
             if not isdir(staticDir):
                 os.mkdir(staticDir)
             installed.append(staticDir)
-            shutil.copy(join(recipeDir,'default.css'),
-                        join(staticDir, 'default.css'))
-            installed.append(join(staticDir, 'default.css'))
+            if 'default.css' not in self.options:
+                shutil.copy(join(recipeDir,'default.css'),
+                            join(staticDir, 'default.css'))
+                installed.append(join(staticDir, 'default.css'))
+            elif self.options['default.css']:
+                f = self.openfile(self.options['default.css'])
+                open(join(staticDir,'default.css'), 'w').write(f.read())
+                installed.append(join(staticDir, 'default.css'))
 
-            #create tempaltes directory
+            #create templates directory
             templatesDir = join(partDir, '.templates')
             if not isdir(templatesDir):
                 os.mkdir(templatesDir)
             installed.append(templatesDir)
-            shutil.copy(join(recipeDir,'layout.html'),
-                        join(templatesDir, 'layout.html'))
-            installed.append(join(templatesDir, 'layout.html'))
+            if 'layout.html' not in self.options:
+                shutil.copy(join(recipeDir,'layout.html'),
+                            join(templatesDir, 'layout.html'))
+                installed.append(join(templatesDir, 'layout.html'))
+            elif self.options['layout.html']:
+                f = self.openfile(self.options['layout.html'])
+                open(join(staticDir,'layout.html'), 'w').write(f.read())
+                installed.append(join(staticDir, 'layout.html'))
 
             metadata = dict(parser.Parser().parsestr('\n'.join(doc._get_metadata('PKG-INFO'))).items())
 

Modified: z3c.recipe.sphinxdoc/trunk/src/z3c/recipe/sphinxdoc/index.txt
===================================================================
--- z3c.recipe.sphinxdoc/trunk/src/z3c/recipe/sphinxdoc/index.txt	2009-01-19 19:40:40 UTC (rev 94851)
+++ z3c.recipe.sphinxdoc/trunk/src/z3c/recipe/sphinxdoc/index.txt	2009-01-19 19:42:39 UTC (rev 94852)
@@ -73,4 +73,36 @@
 
   $ firefox parts/docs/z3c.form/build/index.html
 
-And that's it!
\ No newline at end of file
+Additional Options
+------------------
+
+By default, this recipe generates documentation that looks like the
+new zope website ( http://new.zope.org ) by ovveriding the default
+layout template and css file used by sphinx.  You can modify this
+behavior with options in your buildout configuration.
+
+Give me back Sphinx's default look!
+...................................
+
+To get back the default look of sphinx, you could use a configuration
+like this::
+
+  [docs]
+  recipe = z3c.recipe.sphinxdoc
+  eggs = z3c.form [docs]
+  default.css =
+  layout.html =
+
+I want my own custom look
+.........................
+
+You can also specify your own layout template and css like so::
+
+  [docs]
+  recipe = z3c.recipe.sphinxdoc
+  eggs = z3c.form [docs]
+  default.css = http://my.own.website.com/mystyles/some-theme.css
+  layout.html = /path/to/layout.html
+
+Note that you can either specify a path on the local file system or a
+url to an external css file.
\ No newline at end of file



More information about the Checkins mailing list