Commits

Yosuke Ikeda committed 83fb5e4

First commit

Comments (0)

Files changed (2)

+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+"""Hatena document writer
+"""
+from docutils import writers, nodes
+
+class Writer(writers.UnfilteredWriter):
+
+    supported = ('hatena',)
+    """Formats this writer supports."""
+
+    config_section = 'hatena writer'
+    config_section_dependencies = ('writers',)
+
+    def translate(self):
+        visitor = HatenaTranslator(self.document)
+        self.document.walk(visitor)
+        self.output = "hoge"
+
+
+class HatenaTranslator(nodes.NodeVisitor):
+    """
+    """
+    def dispatch_visit(self, node):
+        print node.__class__.__name__
+
+    def visit_document(self, node):
+        pass
+
+    def visit_paragraph(self, node):
+        pass
+
+    def visit_Text(self, node):
+        text = node.astext()
+        pass
+    
+    def visit_emphasis(self, node):
+        pass
+    
+    def visit_reference(self, node):
+        pass
+    
+    def visit_target(self, node):
+        pass
+    
+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+import unittest
+from docutils.core import publish_string
+
+from growltestrunner import GrowlTestRunner
+
+import hatena_writer
+
+SRC_TXT = """\
+My *favorite* language is Python_.
+
+.. _Python: http://www.python.org/
+"""
+
+class WriterTest(unittest.TestCase):
+    """
+    """
+    def setUp(self):
+        self.writer = hatena_writer.Writer()
+
+    def test_run(self):
+        output = publish_string(source=SRC_TXT, writer=self.writer)
+        print output
+        
+        self.assert_(True)
+
+if __name__ == '__main__':
+    suite = unittest.TestLoader().loadTestsFromTestCase(WriterTest)
+    GrowlTestRunner().run(suite)
+
+