Ronny Pfannschmidt committed 7130a4c

implement publishing html parts

Comments (0)

Files changed (2)


-from docutils.core import publish_doctree
+from docutils import io
+from docutils.core import publish_doctree, Publisher
+from docutils.readers.doctree import Reader
 from docutils.nodes import docinfo
 from datetime import datetime
 from logbook import Logger
             return datetime.strptime(date, '%Y-%m-%d').date()
+    def build_html_parts(self):
+        reader = Reader(parser_name='null')
+        pub = Publisher(reader, None, None,
+                    source=io.DocTreeInput(self.document),
+                    destination_class=io.StringOutput)
+        pub.set_writer('html')
+        pub.process_programmatic_settings(None, None, None)
+        pub.set_destination(None, None)
+        pub.publish()
+        parts =
+        del parts['whole']
+        del parts['stylesheet']
+        return parts


 from articledump import load_rst
 import datetime
+import pprint
 content = """\
 Test something
 :date: 2011-10-10
-import pprint
 def test_load(tmpdir):
     testfile = tmpdir/'test.rst'
     assert info.title == 'Test something'
     assert info.slug == 'shortone'
     assert ==, 10, 10)
+    pprint.pprint(info.build_html_parts())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.