[PATCH 7 of 9 STABLE?] gendoc: dispatch print document content by commandline arguments

Takumi IINO trot.thunder at gmail.com
Tue May 14 02:29:16 CDT 2013


# HG changeset patch
# User Takumi IINO <trot.thunder at gmail.com>
# Date 1368513072 -32400
#      Tue May 14 15:31:12 2013 +0900
# Branch stable
# Node ID 42006f62aa28528210c58d71b2a286507d3de62f
# Parent  0abe54a3f5aef2a88ac291d01ad6a4d1735d68d1
gendoc: dispatch print document content by commandline arguments

Before this patch, gendoc.py only prints hg.1.gendoc.txt content.
This adds any content print function.

diff --git a/doc/Makefile b/doc/Makefile
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -22,7 +22,7 @@
 	touch hg.1.txt
 
 hg.1.gendoc.txt: $(GENDOC)
-	${PYTHON} gendoc.py > $@.tmp
+	${PYTHON} gendoc.py hg.1.gendoc > $@.tmp
 	mv $@.tmp $@
 
 hgrc.5: ../mercurial/help/config.txt
diff --git a/doc/gendoc.py b/doc/gendoc.py
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -1,3 +1,8 @@
+"""usage: %s DOC ...
+
+where DOC is the name of a document
+"""
+
 import os, sys, textwrap
 # import from the live mercurial repo
 sys.path.insert(0, "..")
@@ -173,4 +178,16 @@
     return extensions.enabled().keys() + extensions.disabled().keys()
 
 if __name__ == "__main__":
-    show_doc_hg(sys.stdout)
+    if len(sys.argv) < 2:
+        sys.stderr.write(__doc__ % sys.argv[0])
+        sys.exit(1)
+
+    doc = sys.argv[1]
+    if doc == 'hg.1.gendoc':
+        show_doc_hg(sys.stdout)
+    elif doc == 'hgignore.5.gendoc':
+        show_doc_hgignore(sys.stdout)
+    elif doc == 'hgrc.5.gendoc':
+        show_doc_hgrc(sys.stdout)
+    else:
+        show_doc_topic(sys.stdout, sys.argv[1])


More information about the Mercurial-devel mailing list