test-gendoc: add tests for all languages
authorMartin Geisler <mg@lazybytes.net>
Sun, 27 Sep 2009 10:12:02 +0200
changeset 9485 7d6ac5d7917c
parent 9484 c96d73dd956d
child 9487 90ae579924e4
test-gendoc: add tests for all languages This ensures that we catch errors in the reST syntax early and for all languages. The only change needed in gendoc.py was to correct the computation of section underlines for Asian languages.
doc/gendoc.py
tests/test-gendoc
tests/test-gendoc.out
--- a/doc/gendoc.py	Sun Sep 27 10:04:51 2009 +0200
+++ b/doc/gendoc.py	Sun Sep 27 10:12:02 2009 +0200
@@ -4,6 +4,7 @@
 # fall back to pure modules if required C extensions are not available
 sys.path.append(os.path.join('..', 'mercurial', 'pure'))
 from mercurial import demandimport; demandimport.enable()
+from mercurial import encoding
 from mercurial.commands import table, globalopts
 from mercurial.i18n import _
 from mercurial.help import helptable
@@ -55,9 +56,9 @@
 
 def show_doc(ui):
     def section(s):
-        ui.write("%s\n%s\n\n" % (s, "-" * len(s)))
+        ui.write("%s\n%s\n\n" % (s, "-" * encoding.colwidth(s)))
     def subsection(s):
-        ui.write("%s\n%s\n\n" % (s, '"' * len(s)))
+        ui.write("%s\n%s\n\n" % (s, '"' * encoding.colwidth(s)))
 
     # print options
     section(_("OPTIONS"))
--- a/tests/test-gendoc	Sun Sep 27 10:04:51 2009 +0200
+++ b/tests/test-gendoc	Sun Sep 27 10:12:02 2009 +0200
@@ -3,10 +3,19 @@
 "$TESTDIR/hghave" rst2html || exit 80
 RST2HTML=$(which rst2html 2> /dev/null || which rst2html.py)
 
-echo "checking for syntax errors in gendoc.py"
-python $TESTDIR/../doc/gendoc.py > gendoc.txt || exit
+HGENCODING=UTF-8
+export HGENCODING
 
-# We run rst2html over the file without adding "--halt warning" to
-# make it report all errors instead of stopping on the first one.
-echo "checking for parse errors with rst2html"
-$RST2HTML gendoc.txt /dev/null
+for PO in C $TESTDIR/../i18n/*.po; do
+    LOCALE=$(basename $PO .po)
+    echo
+    echo "% extracting documentation from $LOCALE"
+    echo ".. -*- coding: utf-8 -*-" > gendoc-$LOCALE.txt
+    echo "" >> gendoc-$LOCALE.txt
+    LC_ALL=$LOCALE python $TESTDIR/../doc/gendoc.py >> gendoc-$LOCALE.txt || exit
+
+    # We run rst2html over the file without adding "--halt warning" to
+    # make it report all errors instead of stopping on the first one.
+    echo "checking for parse errors with rst2html"
+    $RST2HTML gendoc-$LOCALE.txt /dev/null
+done
--- a/tests/test-gendoc.out	Sun Sep 27 10:04:51 2009 +0200
+++ b/tests/test-gendoc.out	Sun Sep 27 10:12:02 2009 +0200
@@ -1,2 +1,30 @@
-checking for syntax errors in gendoc.py
+
+% extracting documentation from C
+checking for parse errors with rst2html
+
+% extracting documentation from da
+checking for parse errors with rst2html
+
+% extracting documentation from de
+checking for parse errors with rst2html
+
+% extracting documentation from el
+checking for parse errors with rst2html
+
+% extracting documentation from fr
 checking for parse errors with rst2html
+
+% extracting documentation from it
+checking for parse errors with rst2html
+
+% extracting documentation from ja
+checking for parse errors with rst2html
+
+% extracting documentation from pt_BR
+checking for parse errors with rst2html
+
+% extracting documentation from zh_CN
+checking for parse errors with rst2html
+
+% extracting documentation from zh_TW
+checking for parse errors with rst2html