Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated toplone script generation

  • Loading branch information...
commit 78e233608ae03b6269e971352144aaf71c5e4f26 1 parent f73f4ca
miohtama authored
Showing with 265 additions and 41 deletions.
  1. +1 −1  Makefile
  2. +37 −8 buildout.cfg
  3. +105 −32 pipeline.cfg
  4. +122 −0 sphinx.css
View
2  Makefile
@@ -3,7 +3,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
-SPHINXBUILD = sphinx-build
+SPHINXBUILD = bin/sphinx-build
PAPER =
# Internal variables.
View
45 buildout.cfg
@@ -1,3 +1,6 @@
+#
+# Buildout to create toplone command which uploads Sphinx documentation to Plone site
+#
[buildout]
parts = sphinx zope2 instance test toplone
extends =
@@ -13,31 +16,49 @@ sources = sources
sources-dir = ${buildout:directory}/src
auto-checkout =
-# Just set repo pointer here
+# Set transmogrify package repository pointer here to allow easy switching between private and public repos
# Final repo URLs are format git://github.com/djay/transmogrify.htmltesting.git
[transmogrify]
git-repo = git://github.com/djay
[sources]
transmogrify.webcrawler = git ${transmogrify:git-repo}/transmogrify.webcrawler.git
-transmogrify.htmlcontentextractor = git ${transmogrify:git-repo}/transmogrify.htmlcontentextractor.git
transmogrify.pathsorter = git ${transmogrify:git-repo}/transmogrify.pathsorter.git
transmogrify.htmltesting = git ${transmogrify:git-repo}/transmogrify.htmltesting.git
transmogrify.siteanalyser = git ${transmogrify:git-repo}/transmogrify.siteanalyser.git
-transmogrify.ploneremote = git ${transmogrify:git-repo}/transmogrify.ploneremote.git
+
+# Following have been patched
+
+#transmogrify.ploneremote = git ${transmogrify:git-repo}/transmogrify.ploneremote.git
+transmogrify.ploneremote = git git://github.com/miohtama/transmogrify.ploneremote.git
+
+#transmogrify.htmlcontentextractor = git ${transmogrify:git-repo}/transmogrify.htmlcontentextractor.git
+transmogrify.htmlcontentextractor = git git://github.com/miohtama/transmogrify.htmlcontentextractor.git
[sphinx]
recipe = collective.recipe.sphinxbuilder
#doc-directory = .
outputs = html
source = ${buildout:directory}/source
-build = ${buildout:directory}/docs
+build = ${buildout:directory}/build
eggs =
Sphinx==0.6.4
Docutils
roman
-
-
+ Pygments
+
+
+#
+# Recipe to create toplone command.
+#
+# It will walk through all blueprints defined
+# in pipeline.cfg and override their target parameter
+# to be a remote Plone site given on the command line.
+# This all happeins in initialization= magic.
+#
+# Also Python logger is initialized to give us verbose
+# output. Some blueprints use logging module for the output.
+#
[toplone]
recipe = zc.recipe.egg
eggs =
@@ -48,13 +69,21 @@ eggs =
transmogrify.pathsorter
transmogrify.ploneremote
Products.CMFCore
+
+# This initialization script sets remote site argument
+# for remote blueprints defined in pipeline.cfg
initialization =
from urllib import pathname2url as url
from sys import argv
- args = dict(webcrawler=dict(site_url=url('docs/html')),
+ import logging
+
+ logging.basicConfig(level=logging.DEBUG)
+ args = dict(webcrawler=dict(site_url=url('build/html')),
localconstructor=dict(output=url('ploneout')),
ploneuploader=dict(target=argv[1]),
- schemaupdater=dict(target=argv[1])
+ schemaupdater=dict(target=argv[1]),
+ publish=dict(target=argv[1]),
+ excludefromnavigation=dict(target=argv[1])
)
arguments = 'pipeline.cfg', args
entry-points = toplone=transmogrify.htmltesting.runner:runner
View
137 pipeline.cfg
@@ -1,24 +1,27 @@
[transmogrifier]
pipeline =
- webcrawler
+ webcrawler
typerecognitor
- todrop
+ drop-resources
+ drop-unneeded-html
templatefinder
# isindex is before moves. not sure why but it has to be
- isindex
- makedoc1
-# makeattachments
-# want titles before relinker so get original ids
+ set-folder-default-page
+ makedoc1
title_from_link
relinker
# treeserializer before contructor to put in right order again
treeserializer
encode-all
- tosection
- topage
-# localconstructor
+ mark-image-folders-to-navigation-exclusion
+ mark-container-remote-content-type
+ mark-page-remote-content-type
+ topublish
+# localconstructor
ploneuploader
schemaupdater
+ publish
+ excludefromnavigation
[webcrawler]
@@ -28,10 +31,17 @@ ignore =
cgi-bin
javascript:
-[todrop]
+# Do not consider media files in Sphinx documentation tree
+[drop-resources]
blueprint = collective.transmogrifier.sections.condition
condition: python:item.get('_mimetype') not in ['application/x-javascript','text/css','text/plain','application/x-java-byte-code'] and item.get('_path','').split('.')[-1] not in ['class']
+# Do not consider HTML files which are unndeeded in Plone
+# getindex.html is Sphinx's automatically generated index and it is not needed with this manual
+[drop-unneeded-html]
+blueprint = collective.transmogrifier.sections.condition
+condition: python:not "genindex" in item.get("_path","")
+
[treeserializer]
blueprint = transmogrify.pathsorter
@@ -43,17 +53,31 @@ blueprint = transmogrify.webcrawler.typerecognitor
blueprint = transmogrify.siteanalyser.relinker
#link_expr = python:item.get('_type',None)=='Image' and item['_path'][:-1].endswith('image') and item['_path']+'_medium' or item.get('_type',None)=='Image' and item['_path']+'/image_web' or item['_path']
+#
+# Extract title, description and content text from Sphinx generated HTML page
+#
+# Title is the first <h1> element
+#
+# Description is reST "admonition" with name Description
+#
+# Text is what is left to <body> after removing title and description
+#
+# Note that spaces in XPaths must be escaped as &#32;
+#
+# See
+# http://www.w3schools.com/xpath/default.asp
+# http://blog.browsermob.com/2009/04/test-your-selenium-xpath-easily-with-firebug/
+# for XPath info
+#
[templatefinder]
blueprint = transmogrify.htmlcontentextractor
auto=False
1-title = text //div[@class='body']//h1[1]
-1-permalink = text //div[@class='body']//a[@class='headerlink']
-1-description = text //div[@class='body']/div[@class='section']/p[1]
+# Permalinks are not used in Plone. We have this dummy rule here to parse
+# them out from body so that they do not corrupt "text" field
+# 1-permalink = text //div[@class='body']//a[@class='headerlink']
+1-description = text //div[contains(@class,'admonition-description')]//p[@class='last'] //div[contains(@class,'admonition-description')] soft
1-text = html //div[@class='body']
-2-title = text //div[@class='body']//h1[1]
-2-permalink = text //div[@class='body']//a[@class='headerlink']
-2-text = html //div[@class='body']
-3-text = html //div[@class='body']
@@ -69,25 +93,53 @@ ignore =
click
read more
-#[title_from_id]
-#blueprint = collective.transmogrifier.sections.inserter
-#key = string:title
-#value = python: item['_path'].split('/')[-1]
-#condition = python:'title' not in item and '_path' in item
-[tosection]
+#
+# Set hint so that that directiories are converted to HelpCenterReferenceManualSection
+# Plone content type when uploaded
+#
+[mark-container-remote-content-type]
blueprint = collective.transmogrifier.sections.inserter
key = string:_type
value = string:HelpCenterReferenceManualSection
condition = python:item.get('_type')=='Folder' and not options.get('disabled')
-[topage]
+#
+# Set hint so that that .HTML files are converted to HelpCenterLeafPage
+# Plone content type when uploaded
+#
+[mark-page-remote-content-type]
blueprint = collective.transmogrifier.sections.inserter
key = string:_type
value = string:HelpCenterLeafPage
condition = python:item.get('_type')=='Document' and not options.get('disabled')
+
+#
+# Hide remote images folder from the navigation tree,
+# as images are refered only in <img src="">
+#
+[mark-image-folders-to-navigation-exclusion]
+blueprint = collective.transmogrifier.sections.inserter
+key = string:_exclude-from-navigation
+value = python:True
+condition = python:"images" in item.get("_path","") and item.get('_type')=='Folder'
+
+#
+# Set the workflow transition key hint which will be used publish the item.
+# This value is later read by [publish] and we can have conditions
+# to have different WF transitions for different content types
+#
+# Note that images do not have workflow and they inherit
+# permission settings of the parent container
+#
+[topublish]
+blueprint = collective.transmogrifier.sections.inserter
+key = string:_transitions
+value = python:["publish"]
+condition = python:item.get('_type') != 'Image' and not options.get('disabled')
+
[encode-all]
blueprint = collective.transmogrifier.sections.codec
keys =
@@ -99,24 +151,45 @@ blueprint = transmogrify.webcrawler.cache
target = ploneout
output = ploneout
-
+#
+# Create remote item on Plone site
+#
[ploneuploader]
blueprint = transmogrify.ploneremote.remoteconstructor
-target=http://admin:admin@localhost:8080/plone/manual/
-
+#
+# Update the remote item with new extracted content from Sphinx documentation
+#
[schemaupdater]
blueprint = transmogrify.ploneremote.remoteschemaupdater
-target=http://admin:admin@localhost:8080/plone/manual/
-
-
-[isindex]
+#
+# Set index.html as the default page of the folder
+#
+# Determines an item is a default page for a container if it has many links
+# to items in that container.
+#
+[set-folder-default-page]
blueprint = transmogrify.siteanalyser.defaultpage
-
-
[makeattachments]
blueprint = transmogrify.siteanalyser.attach
condition = python: subitem.get('_type') in ['Image']
defaultpage = index-html
+
+#
+# Publish the uploaded documentation (if not public yet)
+#
+[publish]
+blueprint = transmogrify.ploneremote.remoteworkflowupdater
+transitions = submit publish
+transitions-key = _transitions
+
+#
+# Hide items from the navigation
+# (hints to which items should be hidden are set earlier in pipeline)
+#
+[excludefromnavigation]
+blueprint = transmogrify.ploneremote.remotenavigationexcluder
+
+
View
122 sphinx.css
@@ -0,0 +1,122 @@
+/**
+ * CSS styles for Sphinx and Plone integration
+ *
+ * Copyright 2010 mFabrik Research OY
+ *
+ * @author Mikko Ohtamaa
+ *
+ * http://mfabrik.com http://mfabrik.mobi
+ *
+ * http://blog.mfabrik.com
+ *
+ *
+ * We assume that all Sphinx HTML content is nested inside sphinx-content CSS
+ * class. This class is given by special page.html Sphinx template,
+ * residing in _template folder of collective.developermanual.
+ *
+ */
+
+ /* Resolve conflicting CSS class "sectiion"
+ *
+ * Both Plone and Sphinx use .section, but
+ * have different meaning for this CSS class.
+ *
+ */
+.sphinx-content .section div {
+ padding-top: 0;
+ padding-bottom: 0;
+}
+
+
+/* Make sure that nested table of contents list don't have bad looking top and bottom item margins */
+.contents ul,
+.contents ol,
+.template-referencemanual_view #content ol {
+ list-style-type: none;
+ list-style-image: none;
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+/* Make permalink anchors visible on subheadings on hover */
+
+a.headerlink {
+ visibility:hidden;
+}
+
+h1:hover > a.headerlink,
+h2:hover > a.headerlink,
+h3:hover > a.headerlink,
+h4:hover > a.headerlink,
+h5:hover > a.headerlink,
+h6:hover > a.headerlink,
+dt:hover > a.headerlink {
+ visibility:visible;
+}
+
+/* Following are taken from build/static/pygments.css after Sphinx has been run.
+ * Pygments styles are generated during the each build, so these
+ * might mismatch.
+ */
+
+.hll { background-color: #ffffcc }
+.c { color: #408090; font-style: italic } /* Comment */
+.err { border: 1px solid #FF0000 } /* Error */
+.k { color: #007020; font-weight: bold } /* Keyword */
+.o { color: #666666 } /* Operator */
+.cm { color: #408090; font-style: italic } /* Comment.Multiline */
+.cp { color: #007020 } /* Comment.Preproc */
+.c1 { color: #408090; font-style: italic } /* Comment.Single */
+.cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
+.gd { color: #A00000 } /* Generic.Deleted */
+.ge { font-style: italic } /* Generic.Emph */
+.gr { color: #FF0000 } /* Generic.Error */
+.gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.gi { color: #00A000 } /* Generic.Inserted */
+.go { color: #303030 } /* Generic.Output */
+.gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
+.gs { font-weight: bold } /* Generic.Strong */
+.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.gt { color: #0040D0 } /* Generic.Traceback */
+.kc { color: #007020; font-weight: bold } /* Keyword.Constant */
+.kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
+.kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
+.kp { color: #007020 } /* Keyword.Pseudo */
+.kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
+.kt { color: #902000 } /* Keyword.Type */
+.m { color: #208050 } /* Literal.Number */
+.s { color: #4070a0 } /* Literal.String */
+.na { color: #4070a0 } /* Name.Attribute */
+.nb { color: #007020 } /* Name.Builtin */
+.nc { color: #0e84b5; font-weight: bold } /* Name.Class */
+.no { color: #60add5 } /* Name.Constant */
+.nd { color: #555555; font-weight: bold } /* Name.Decorator */
+.ni { color: #d55537; font-weight: bold } /* Name.Entity */
+.ne { color: #007020 } /* Name.Exception */
+.nf { color: #06287e } /* Name.Function */
+.nl { color: #002070; font-weight: bold } /* Name.Label */
+.nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
+.nt { color: #062873; font-weight: bold } /* Name.Tag */
+.nv { color: #bb60d5 } /* Name.Variable */
+.ow { color: #007020; font-weight: bold } /* Operator.Word */
+.w { color: #bbbbbb } /* Text.Whitespace */
+.mf { color: #208050 } /* Literal.Number.Float */
+.mh { color: #208050 } /* Literal.Number.Hex */
+.mi { color: #208050 } /* Literal.Number.Integer */
+.mo { color: #208050 } /* Literal.Number.Oct */
+.sb { color: #4070a0 } /* Literal.String.Backtick */
+.sc { color: #4070a0 } /* Literal.String.Char */
+.sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
+.s2 { color: #4070a0 } /* Literal.String.Double */
+.se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
+.sh { color: #4070a0 } /* Literal.String.Heredoc */
+.si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
+.sx { color: #c65d09 } /* Literal.String.Other */
+.sr { color: #235388 } /* Literal.String.Regex */
+.s1 { color: #4070a0 } /* Literal.String.Single */
+.ss { color: #517918 } /* Literal.String.Symbol */
+.bp { color: #007020 } /* Name.Builtin.Pseudo */
+.vc { color: #bb60d5 } /* Name.Variable.Class */
+.vg { color: #bb60d5 } /* Name.Variable.Global */
+.vi { color: #bb60d5 } /* Name.Variable.Instance */
+.il { color: #208050 } /* Literal.Number.Integer.Long */
Please sign in to comment.
Something went wrong with that request. Please try again.