Commits

hideki nara  committed e076dcf

now, .. yummy-list:: tags generates Delicios links for tags(underway)

  • Participants
  • Parent commits a44266f

Comments (0)

Files changed (2)

File docs/source/index.rst

 Welcome to yummy's documentation!
 =================================
 
-.. yummy_list::
+.. yummy_list:: sphinx
 
 Contents:
 

File src/yummy/spx.py

 from sphinx.util.nodes import set_source_info
 from sphinx.util.compat import Directive, make_admonition
 
+from yummy.api import Api
+
 #:Node class
 class yummylist(nodes.General, nodes.Element): pass
 
 class YummyList(Directive):
     """
     A list of URL bookmarks
+
+    .. yummy_list : delicious-tags
     """
+    required_arguments = 1  # for len(self.arguments)>0, must be larger than 0,
+    optional_arguments = 0  # or this must be larger than 0.
+
     def run(self):
-        return [yummylist('')]
+        node = yummylist('')
+        node['tags'] = self.arguments[0]  # 0: delicious-tags
+        return [ node ]
 
 
 #: Sphinx Evennt Handlers
 def on_doctree_resolved(app, doctree, fromdocname):
 
-    #: configuration check
-#    if not app.config['yummy_enable']:
-#        for node in doctree.traverse(todo_node):
-#            node.parent.remove(node)
+    for node in doctree.traverse(yummylist):
+        content = [
+            nodes.raw('','<div>',format='html',),
+            nodes.raw('','<h2>Links for tags :"%s" </h2>' % node['tags'],format='html',),
+            nodes.raw('','<ul>',format='html',),
+        ]
+        for post in Api().post( tag=node['tags'] ).documentElement.childNodes:
+            content.append(  
+                nodes.raw('',
+                    '<li><a href="%s">%s</a></li>' % (
+                    post.attributes['href'].value,
+                    post.attributes['description'].value
+                    ),
+                    format='html',)
+            )
+        content.append( nodes.raw('','</ul>',format='html',))
+        content.append( nodes.raw('','</div>',format='html',))
 
-    for node in doctree.traverse(yummylist):
-#        content = [nodes.literal_block('hoge','hoge',)]
-#        content = [
-#            nodes.literal('xxxxxxxx'),
-#            nodes.bullet_list('', classes=['yummy-list'])
-#        ]
-#        content[0].append( nodes.list_item('xxxx',classes=['yummy-item']) )
-#
-
-#        blist = nodes.bullet_list()
-#        for i in range(1, 6):
-#            item = nodes.list_item()
-#            for j in range(1, 4):
-#                item += nodes.paragraph('', 'Item %s, paragraph %s.' % (i, j))
-#            blist += item
-        content = [
-            nodes.raw('','<h2>Links</h2>',format='html',),
-            nodes.raw('','<ul>',format='html',),
-            nodes.raw('','<li><a href="http://google.com">Google.com</a></li>',format='html',),
-            nodes.raw('','<li><a href="http://amazon.com">Amazon.com</a></li>',format='html',),
-            nodes.raw('','</ul>',format='html',),
-        ]
         node.replace_self(content)
-
 #
 def setup(app):
 #    app.add_config_value('todo_include_todos', False, False)