changeset 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 c6035785dbfc
children 0c3b811d2c26
files garcon/changelog.py garcon/changelog/category_title.md garcon/changelog/category_title.rst garcon/changelog/header.md garcon/changelog/version_title.md
diffstat 5 files changed, 22 insertions(+), 6 deletions(-) [+]
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
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/garcon/changelog/category_title.md	Thu Jun 02 20:21:36 2016 -0700
@@ -0,0 +1,3 @@
+
+### %num%.%sub_num% %category%
+
--- a/garcon/changelog/category_title.rst	Thu Jun 02 13:01:08 2016 -0700
+++ b/garcon/changelog/category_title.rst	Thu Jun 02 20:21:36 2016 -0700
@@ -1,4 +1,4 @@
 
-1.%sub_num% %category%
+%num%.%sub_num% %category%
 ----------------------
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/garcon/changelog/header.md	Thu Jun 02 20:21:36 2016 -0700
@@ -0,0 +1,7 @@
+---
+title: Changelog
+layout: simple
+---
+
+# Changelog
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/garcon/changelog/version_title.md	Thu Jun 02 20:21:36 2016 -0700
@@ -0,0 +1,3 @@
+
+## %num%. PieCrust %version% (%date%)
+