diff garcon/changelog.py @ 740:3ab6f7a3a2c7

cm: Add generation of Mardown changelog suitable for the online documentation.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 02 Jun 2016 20:21:36 -0700
parents e6d9eed35c8e
children be8b233cc69a
line wrap: on
line diff
--- a/garcon/changelog.py	Thu Jun 02 13:01:08 2016 -0700
+++ b/garcon/changelog.py	Thu Jun 02 20:21:36 2016 -0700
@@ -45,7 +45,8 @@
         '--template', hg_log_template])
     hglog = hglog.decode('utf8')
 
-    templates = _get_templates()
+    _, out_ext = os.path.splitext(out_file)
+    templates = _get_templates(out_ext)
 
     with open(out_file, 'w', encoding='utf8', newline='') as fp:
         fp.write(templates['header'])
@@ -129,6 +130,7 @@
             continue
 
         tokens = {
+                'num': str(version),
                 'sub_num': str(i),
                 'category': cat_name.title()}
         tpl = _multi_replace(templates['category_title'], tokens)
@@ -146,13 +148,14 @@
     return s
 
 
-def _get_templates():
+def _get_templates(extension):
     tpl_dir = os.path.join(os.path.dirname(__file__), 'changelog')
     tpls = {}
     for name in os.listdir(tpl_dir):
-        tpl = _get_template(os.path.join(tpl_dir, name))
-        name_no_ext, _ = os.path.splitext(name)
-        tpls[name_no_ext] = tpl
+        if name.endswith(extension):
+            tpl = _get_template(os.path.join(tpl_dir, name))
+            name_no_ext, _ = os.path.splitext(name)
+            tpls[name_no_ext] = tpl
     return tpls