Skip to content
This repository
Browse code

Updated toplone script generation

  • Loading branch information...
commit 78e233608ae03b6269e971352144aaf71c5e4f26 1 parent f73f4ca
authored April 18, 2010
2  Makefile
@@ -3,7 +3,7 @@
3 3
 
4 4
 # You can set these variables from the command line.
5 5
 SPHINXOPTS    =
6  
-SPHINXBUILD   = sphinx-build
  6
+SPHINXBUILD   = bin/sphinx-build
7 7
 PAPER         =
8 8
 
9 9
 # Internal variables.
45  buildout.cfg
... ...
@@ -1,3 +1,6 @@
  1
+#
  2
+# Buildout to create toplone command which uploads Sphinx documentation to Plone site
  3
+#
1 4
 [buildout]
2 5
 parts = sphinx zope2  instance  test toplone 
3 6
 extends =
@@ -13,31 +16,49 @@ sources = sources
13 16
 sources-dir = ${buildout:directory}/src
14 17
 auto-checkout =
15 18
 
16  
-# Just set repo pointer here
  19
+# Set transmogrify package repository pointer here to allow easy switching between private and public repos
17 20
 # Final repo URLs are format git://github.com/djay/transmogrify.htmltesting.git
18 21
 [transmogrify]
19 22
 git-repo = git://github.com/djay
20 23
 
21 24
 [sources]
22 25
 transmogrify.webcrawler = git ${transmogrify:git-repo}/transmogrify.webcrawler.git
23  
-transmogrify.htmlcontentextractor = git ${transmogrify:git-repo}/transmogrify.htmlcontentextractor.git
24 26
 transmogrify.pathsorter = git ${transmogrify:git-repo}/transmogrify.pathsorter.git
25 27
 transmogrify.htmltesting = git ${transmogrify:git-repo}/transmogrify.htmltesting.git
26 28
 transmogrify.siteanalyser = git ${transmogrify:git-repo}/transmogrify.siteanalyser.git
27  
-transmogrify.ploneremote = git ${transmogrify:git-repo}/transmogrify.ploneremote.git
  29
+
  30
+# Following have been patched
  31
+
  32
+#transmogrify.ploneremote = git ${transmogrify:git-repo}/transmogrify.ploneremote.git
  33
+transmogrify.ploneremote = git git://github.com/miohtama/transmogrify.ploneremote.git
  34
+
  35
+#transmogrify.htmlcontentextractor = git ${transmogrify:git-repo}/transmogrify.htmlcontentextractor.git
  36
+transmogrify.htmlcontentextractor = git git://github.com/miohtama/transmogrify.htmlcontentextractor.git
28 37
 
29 38
 [sphinx]
30 39
 recipe = collective.recipe.sphinxbuilder
31 40
 #doc-directory = .
32 41
 outputs = html
33 42
 source = ${buildout:directory}/source
34  
-build = ${buildout:directory}/docs
  43
+build = ${buildout:directory}/build
35 44
 eggs =
36 45
   Sphinx==0.6.4
37 46
   Docutils
38 47
   roman
39  
-
40  
-
  48
+  Pygments
  49
+
  50
+
  51
+#
  52
+# Recipe to create toplone command.
  53
+# 
  54
+# It will walk through all blueprints defined
  55
+# in pipeline.cfg and override their target parameter
  56
+# to be a remote Plone site given on the command line.
  57
+# This all happeins in initialization= magic.
  58
+#
  59
+# Also Python logger is initialized to give us verbose
  60
+# output. Some blueprints use logging module for the output.
  61
+#
41 62
 [toplone]
42 63
 recipe = zc.recipe.egg
43 64
 eggs =
@@ -48,13 +69,21 @@ eggs =
48 69
   transmogrify.pathsorter
49 70
   transmogrify.ploneremote
50 71
   Products.CMFCore
  72
+  
  73
+# This initialization script sets remote site argument
  74
+# for remote blueprints defined in pipeline.cfg
51 75
 initialization =
52 76
   from urllib import pathname2url as url
53 77
   from sys import argv
54  
-  args = dict(webcrawler=dict(site_url=url('docs/html')),
  78
+  import logging
  79
+  
  80
+  logging.basicConfig(level=logging.DEBUG)
  81
+  args = dict(webcrawler=dict(site_url=url('build/html')),
55 82
       localconstructor=dict(output=url('ploneout')),
56 83
       ploneuploader=dict(target=argv[1]),
57  
-      schemaupdater=dict(target=argv[1])
  84
+      schemaupdater=dict(target=argv[1]),
  85
+      publish=dict(target=argv[1]),
  86
+      excludefromnavigation=dict(target=argv[1])
58 87
       )
59 88
 arguments = 'pipeline.cfg', args
60 89
 entry-points = toplone=transmogrify.htmltesting.runner:runner
137  pipeline.cfg
... ...
@@ -1,24 +1,27 @@
1 1
 [transmogrifier]
2 2
 pipeline =
3  
-	webcrawler
  3
+    webcrawler
4 4
     typerecognitor
5  
-    todrop
  5
+    drop-resources
  6
+    drop-unneeded-html
6 7
     templatefinder
7 8
 # isindex is before moves. not sure why but it has to be
8  
-    isindex
9  
-	makedoc1
10  
-#	makeattachments
11  
-# want titles before relinker so get original ids
  9
+    set-folder-default-page
  10
+    makedoc1
12 11
     title_from_link
13 12
     relinker
14 13
 # treeserializer before contructor to put in right order again
15 14
     treeserializer
16 15
     encode-all
17  
-    tosection
18  
-    topage
19  
-#    localconstructor
  16
+    mark-image-folders-to-navigation-exclusion
  17
+    mark-container-remote-content-type
  18
+    mark-page-remote-content-type
  19
+    topublish
  20
+#   localconstructor
20 21
     ploneuploader
21 22
     schemaupdater
  23
+    publish
  24
+    excludefromnavigation
22 25
 
23 26
 
24 27
 [webcrawler]
@@ -28,10 +31,17 @@ ignore =
28 31
 	cgi-bin
29 32
 	javascript:
30 33
 
31  
-[todrop]
  34
+# Do not consider media files in Sphinx documentation tree
  35
+[drop-resources]
32 36
 blueprint = collective.transmogrifier.sections.condition
33 37
 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']
34 38
 
  39
+# Do not consider HTML files which are unndeeded in Plone
  40
+# getindex.html is Sphinx's automatically generated index and it is not needed with this manual
  41
+[drop-unneeded-html]
  42
+blueprint = collective.transmogrifier.sections.condition
  43
+condition: python:not "genindex" in item.get("_path","")
  44
+
35 45
 [treeserializer]
36 46
 blueprint = transmogrify.pathsorter
37 47
 
@@ -43,17 +53,31 @@ blueprint = transmogrify.webcrawler.typerecognitor
43 53
 blueprint = transmogrify.siteanalyser.relinker
44 54
 #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']
45 55
 
  56
+#
  57
+# Extract title, description and content text from Sphinx generated HTML page
  58
+#
  59
+# Title is the first <h1> element
  60
+#
  61
+# Description is reST "admonition" with name Description 
  62
+#
  63
+# Text is what is left to <body> after removing title and description 
  64
+#
  65
+# Note that spaces in XPaths must be escaped as &#32;
  66
+#
  67
+# See
  68
+#  http://www.w3schools.com/xpath/default.asp
  69
+#  http://blog.browsermob.com/2009/04/test-your-selenium-xpath-easily-with-firebug/
  70
+# for XPath info
  71
+#
46 72
 [templatefinder]
47 73
 blueprint = transmogrify.htmlcontentextractor
48 74
 auto=False
49 75
 1-title = text //div[@class='body']//h1[1]
50  
-1-permalink = text //div[@class='body']//a[@class='headerlink']
51  
-1-description = text //div[@class='body']/div[@class='section']/p[1]
  76
+# Permalinks are not used in Plone. We have this dummy rule here to parse 
  77
+# them out from body so that they do not corrupt "text" field
  78
+# 1-permalink = text //div[@class='body']//a[@class='headerlink']
  79
+1-description = text //div[contains(@class,'admonition-description')]//p[@class='last'] //div[contains(@class,'admonition-description')] soft
52 80
 1-text = html //div[@class='body']
53  
-2-title = text //div[@class='body']//h1[1]
54  
-2-permalink = text //div[@class='body']//a[@class='headerlink']
55  
-2-text = html //div[@class='body']
56  
-3-text = html //div[@class='body']
57 81
 
58 82
 
59 83
 
@@ -69,25 +93,53 @@ ignore =
69 93
 	click
70 94
 	read more
71 95
 
72  
-#[title_from_id]
73  
-#blueprint = collective.transmogrifier.sections.inserter
74  
-#key = string:title
75  
-#value = python: item['_path'].split('/')[-1]
76  
-#condition = python:'title' not in item and '_path' in item
77 96
 
78  
-[tosection]
  97
+#
  98
+# Set hint so that that directiories are converted to HelpCenterReferenceManualSection
  99
+# Plone content type when uploaded
  100
+#
  101
+[mark-container-remote-content-type]
79 102
 blueprint = collective.transmogrifier.sections.inserter
80 103
 key = string:_type
81 104
 value = string:HelpCenterReferenceManualSection
82 105
 condition = python:item.get('_type')=='Folder' and not options.get('disabled')
83 106
 
84 107
 
85  
-[topage]
  108
+#
  109
+# Set hint so that that .HTML files are converted to HelpCenterLeafPage
  110
+# Plone content type when uploaded
  111
+#
  112
+[mark-page-remote-content-type]
86 113
 blueprint = collective.transmogrifier.sections.inserter
87 114
 key = string:_type
88 115
 value = string:HelpCenterLeafPage
89 116
 condition = python:item.get('_type')=='Document' and not options.get('disabled')
90 117
 
  118
+
  119
+# 
  120
+# Hide remote images folder from the navigation tree,
  121
+# as images are refered only in <img src=""> 
  122
+#
  123
+[mark-image-folders-to-navigation-exclusion]
  124
+blueprint = collective.transmogrifier.sections.inserter
  125
+key = string:_exclude-from-navigation
  126
+value = python:True
  127
+condition = python:"images" in item.get("_path","") and item.get('_type')=='Folder' 
  128
+
  129
+#
  130
+# Set the workflow transition key hint which will be used publish the item.
  131
+# This value is later read by [publish] and we can have conditions
  132
+# to have different WF transitions for different content types 
  133
+#
  134
+# Note that images do not have workflow and they inherit
  135
+# permission settings of the parent container
  136
+#
  137
+[topublish]
  138
+blueprint = collective.transmogrifier.sections.inserter
  139
+key = string:_transitions
  140
+value = python:["publish"]
  141
+condition = python:item.get('_type') != 'Image' and not options.get('disabled')
  142
+
91 143
 [encode-all]
92 144
 blueprint = collective.transmogrifier.sections.codec
93 145
 keys =
@@ -99,24 +151,45 @@ blueprint = transmogrify.webcrawler.cache
99 151
 target = ploneout
100 152
 output = ploneout
101 153
 
102  
-
  154
+#
  155
+# Create remote item on Plone site
  156
+#
103 157
 [ploneuploader]
104 158
 blueprint = transmogrify.ploneremote.remoteconstructor
105  
-target=http://admin:admin@localhost:8080/plone/manual/
106  
-
107 159
 
  160
+#
  161
+# Update the remote item with new extracted content from Sphinx documentation
  162
+# 
108 163
 [schemaupdater]
109 164
 blueprint = transmogrify.ploneremote.remoteschemaupdater
110  
-target=http://admin:admin@localhost:8080/plone/manual/
111 165
 
112  
-
113  
-
114  
-[isindex]
  166
+#
  167
+# Set index.html as the default page of the folder
  168
+#
  169
+#  Determines an item is a default page for a container if it has many links
  170
+#  to items in that container. 
  171
+#
  172
+[set-folder-default-page]
115 173
 blueprint = transmogrify.siteanalyser.defaultpage
116 174
 
117  
-
118  
-
119 175
 [makeattachments]
120 176
 blueprint = transmogrify.siteanalyser.attach
121 177
 condition = python: subitem.get('_type') in ['Image']
122 178
 defaultpage = index-html
  179
+
  180
+#
  181
+# Publish the uploaded documentation (if not public yet)
  182
+#
  183
+[publish]
  184
+blueprint = transmogrify.ploneremote.remoteworkflowupdater
  185
+transitions = submit publish
  186
+transitions-key = _transitions
  187
+
  188
+#
  189
+# Hide items from the navigation
  190
+# (hints to which items should be hidden are set earlier in pipeline)
  191
+#
  192
+[excludefromnavigation]
  193
+blueprint = transmogrify.ploneremote.remotenavigationexcluder
  194
+
  195
+
122  sphinx.css
... ...
@@ -0,0 +1,122 @@
  1
+/**
  2
+ * CSS styles for Sphinx and Plone integration
  3
+ * 
  4
+ * Copyright 2010 mFabrik Research OY
  5
+ * 
  6
+ * @author Mikko Ohtamaa
  7
+ * 
  8
+ * http://mfabrik.com http://mfabrik.mobi
  9
+ * 
  10
+ * http://blog.mfabrik.com
  11
+ * 
  12
+ * 
  13
+ * We assume that all Sphinx HTML content is nested inside sphinx-content CSS 
  14
+ * class. This class is given by special page.html Sphinx template,
  15
+ * residing in _template folder of collective.developermanual.
  16
+ * 
  17
+ */
  18
+
  19
+ /* Resolve conflicting CSS class "sectiion" 
  20
+  * 
  21
+  * Both Plone and Sphinx use .section, but 
  22
+  * have different meaning for this CSS class.
  23
+  * 
  24
+  */
  25
+.sphinx-content .section div {
  26
+	padding-top: 0;
  27
+	padding-bottom: 0;
  28
+}
  29
+
  30
+
  31
+/* Make sure that nested table of contents list don't have bad looking top and bottom item margins */
  32
+.contents ul,
  33
+.contents ol,
  34
+.template-referencemanual_view #content ol {
  35
+        list-style-type: none;
  36
+        list-style-image: none;
  37
+        margin-top: 0;
  38
+        margin-bottom: 0;
  39
+}
  40
+
  41
+/* Make permalink anchors visible on subheadings on hover */
  42
+
  43
+a.headerlink {
  44
+        visibility:hidden;
  45
+}
  46
+
  47
+h1:hover > a.headerlink, 
  48
+h2:hover > a.headerlink, 
  49
+h3:hover > a.headerlink, 
  50
+h4:hover > a.headerlink, 
  51
+h5:hover > a.headerlink, 
  52
+h6:hover > a.headerlink, 
  53
+dt:hover > a.headerlink {
  54
+        visibility:visible;
  55
+}
  56
+
  57
+/* Following are taken from build/static/pygments.css after Sphinx has been run.
  58
+ * Pygments styles are generated during the each build, so these
  59
+ * might mismatch. 
  60
+ */
  61
+
  62
+.hll { background-color: #ffffcc }
  63
+.c { color: #408090; font-style: italic } /* Comment */
  64
+.err { border: 1px solid #FF0000 } /* Error */
  65
+.k { color: #007020; font-weight: bold } /* Keyword */
  66
+.o { color: #666666 } /* Operator */
  67
+.cm { color: #408090; font-style: italic } /* Comment.Multiline */
  68
+.cp { color: #007020 } /* Comment.Preproc */
  69
+.c1 { color: #408090; font-style: italic } /* Comment.Single */
  70
+.cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
  71
+.gd { color: #A00000 } /* Generic.Deleted */
  72
+.ge { font-style: italic } /* Generic.Emph */
  73
+.gr { color: #FF0000 } /* Generic.Error */
  74
+.gh { color: #000080; font-weight: bold } /* Generic.Heading */
  75
+.gi { color: #00A000 } /* Generic.Inserted */
  76
+.go { color: #303030 } /* Generic.Output */
  77
+.gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
  78
+.gs { font-weight: bold } /* Generic.Strong */
  79
+.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
  80
+.gt { color: #0040D0 } /* Generic.Traceback */
  81
+.kc { color: #007020; font-weight: bold } /* Keyword.Constant */
  82
+.kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
  83
+.kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
  84
+.kp { color: #007020 } /* Keyword.Pseudo */
  85
+.kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
  86
+.kt { color: #902000 } /* Keyword.Type */
  87
+.m { color: #208050 } /* Literal.Number */
  88
+.s { color: #4070a0 } /* Literal.String */
  89
+.na { color: #4070a0 } /* Name.Attribute */
  90
+.nb { color: #007020 } /* Name.Builtin */
  91
+.nc { color: #0e84b5; font-weight: bold } /* Name.Class */
  92
+.no { color: #60add5 } /* Name.Constant */
  93
+.nd { color: #555555; font-weight: bold } /* Name.Decorator */
  94
+.ni { color: #d55537; font-weight: bold } /* Name.Entity */
  95
+.ne { color: #007020 } /* Name.Exception */
  96
+.nf { color: #06287e } /* Name.Function */
  97
+.nl { color: #002070; font-weight: bold } /* Name.Label */
  98
+.nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
  99
+.nt { color: #062873; font-weight: bold } /* Name.Tag */
  100
+.nv { color: #bb60d5 } /* Name.Variable */
  101
+.ow { color: #007020; font-weight: bold } /* Operator.Word */
  102
+.w { color: #bbbbbb } /* Text.Whitespace */
  103
+.mf { color: #208050 } /* Literal.Number.Float */
  104
+.mh { color: #208050 } /* Literal.Number.Hex */
  105
+.mi { color: #208050 } /* Literal.Number.Integer */
  106
+.mo { color: #208050 } /* Literal.Number.Oct */
  107
+.sb { color: #4070a0 } /* Literal.String.Backtick */
  108
+.sc { color: #4070a0 } /* Literal.String.Char */
  109
+.sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
  110
+.s2 { color: #4070a0 } /* Literal.String.Double */
  111
+.se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
  112
+.sh { color: #4070a0 } /* Literal.String.Heredoc */
  113
+.si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
  114
+.sx { color: #c65d09 } /* Literal.String.Other */
  115
+.sr { color: #235388 } /* Literal.String.Regex */
  116
+.s1 { color: #4070a0 } /* Literal.String.Single */
  117
+.ss { color: #517918 } /* Literal.String.Symbol */
  118
+.bp { color: #007020 } /* Name.Builtin.Pseudo */
  119
+.vc { color: #bb60d5 } /* Name.Variable.Class */
  120
+.vg { color: #bb60d5 } /* Name.Variable.Global */
  121
+.vi { color: #bb60d5 } /* Name.Variable.Instance */
  122
+.il { color: #208050 } /* Literal.Number.Integer.Long */

0 notes on commit 78e2336

Please sign in to comment.
Something went wrong with that request. Please try again.