Commits

W. Trevor King committed 6fdd2eb

Add :latest: option to feed's `latest` directive for limiting entries.

Comments (0)

Files changed (2)

feed/sphinxcontrib/feed/__init__.py

           for title, doc in entries
           if doc in feed_pub_dates]
         decorated_entries.sort(reverse=True)
-        
+        if node['latest'] >= 0:
+            decorated_entries = decorated_entries[:node['latest']]
+
         latest_list = nodes.bullet_list('',
           classes=['feed-latest-articles'])
         

feed/sphinxcontrib/feed/feeddirectives.py

 from docutils import nodes
 from docutils.parsers.rst import Directive, directives
 
+from sphinx.directives import other
 from sphinx.util.nodes import explicit_title_re, set_source_info
 from sphinx.util import url_re, docname_join
 from sphinx.util.matching import patfilter
         # 'hidden': directives.flag,
         # 'numbered': int_or_nothing,
         'titlesonly': directives.flag,
+        'latest': other.int_or_nothing,
     }
 
     def run(self):
         subnode['maxdepth'] = self.options.get('maxdepth', -1)
         subnode['glob'] = glob
         subnode['titlesonly'] = 'titlesonly' in self.options
+        subnode['latest'] = self.options.get('latest', -1)
         #what does this do?
         set_source_info(self, subnode)
         wrappernode = nodes.compound(classes=['feed-latest-wrapper'])