diff extensions/kwarchive.py @ 78:743dd4a77b4a

Implemented a "--reST" option for printing reST substitution definitions from keywords
author Franz Glasner <hg@dom66.de>
date Fri, 23 Feb 2018 09:48:46 +0100
parents b72672ca2de9
children 53c9f2f6a13e
line wrap: on
line diff
--- a/extensions/kwarchive.py	Fri Feb 23 09:35:52 2018 +0100
+++ b/extensions/kwarchive.py	Fri Feb 23 09:48:46 2018 +0100
@@ -182,6 +182,7 @@
      ('', 'path', 'default', _('the canonical repository to use'), _('PATH')),
      ('', "no-shorten-path", None, _("don't shorten the path urls")),
      ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER")),
+     ('', "reST", None, _("output in reST substitution definition syntax")),
     ] + cmdutil.subrepoopts + cmdutil.walkopts,
     _('[OPTION]...'))
 def kwprint(ui, repo, **opts):
@@ -205,6 +206,10 @@
     :``email``:   the email address
     :``none``:    the complete user information w/o filtering
 
+    Use --reST to output the keyword in a format suitable for including
+    in reStructuredText (reST) documents by using it's substitution feature.
+    All revision keyword names have a ``VCS`` prefix.
+
     Returns 0 on success.
 
     '''
@@ -223,7 +228,10 @@
         shorten_path_url=not opts.get("no_shorten_path"),
         user_filter=get_checked_user_filter(opts))
     for key in sorted(keywords.keys()):
-        ui.write("$%s: %s $\n" % (key, keywords[key]))
+        if opts.get("reST"):
+            ui.write(".. |VCS%s| replace:: %s\n" % (key, keywords[key]))
+        else:
+            ui.write("$%s: %s $\n" % (key, keywords[key]))
 
 
 def patch_archiver_class(archivername, filter):