##// END OF EJS Templates
docchecker: scan for missing space before :hg:
timeless -
r27733:3d1baa70 default
parent child Browse files
Show More
@@ -1,50 +1,54 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 #
2 #
3 # docchecker - look for problematic markup
3 # docchecker - look for problematic markup
4 #
4 #
5 # Copyright 2016 timeless <timeless@mozdev.org> and others
5 # Copyright 2016 timeless <timeless@mozdev.org> and others
6 #
6 #
7 # This software may be used and distributed according to the terms of the
7 # This software may be used and distributed according to the terms of the
8 # GNU General Public License version 2 or any later version.
8 # GNU General Public License version 2 or any later version.
9 import sys
9 import sys
10 import re
10 import re
11
11
12 leadingline = re.compile(r'(^\s*)(\S.*)$')
12 leadingline = re.compile(r'(^\s*)(\S.*)$')
13 hg_backtick = re.compile(r""":hg:`[^`]*'[^`]*`""")
13 hg_backtick = re.compile(r""":hg:`[^`]*'[^`]*`""")
14 hg_cramped = re.compile(r'\w:hg:`')
14
15
15 def check(line):
16 def check(line):
16 if hg_backtick.search(line):
17 if hg_backtick.search(line):
17 print(line)
18 print(line)
18 print("""warning: please avoid nesting ' in :hg:`...`""")
19 print("""warning: please avoid nesting ' in :hg:`...`""")
20 if hg_cramped.search(line):
21 print(line)
22 print('warning: please have a space before :hg:')
19
23
20 def work(file):
24 def work(file):
21 (llead, lline) = ('', '')
25 (llead, lline) = ('', '')
22
26
23 for line in file:
27 for line in file:
24 # this section unwraps lines
28 # this section unwraps lines
25 match = leadingline.match(line)
29 match = leadingline.match(line)
26 if not match:
30 if not match:
27 check(lline)
31 check(lline)
28 (llead, lline) = ('', '')
32 (llead, lline) = ('', '')
29 continue
33 continue
30
34
31 lead, line = match.group(1), match.group(2)
35 lead, line = match.group(1), match.group(2)
32 if (lead == llead):
36 if (lead == llead):
33 if (lline != ''):
37 if (lline != ''):
34 lline += ' ' + line
38 lline += ' ' + line
35 else:
39 else:
36 lline = line
40 lline = line
37 else:
41 else:
38 check(lline)
42 check(lline)
39 (llead, lline) = (lead, line)
43 (llead, lline) = (lead, line)
40 check(lline)
44 check(lline)
41
45
42 def main():
46 def main():
43 for f in sys.argv[1:]:
47 for f in sys.argv[1:]:
44 try:
48 try:
45 with open(f) as file:
49 with open(f) as file:
46 work(file)
50 work(file)
47 except:
51 except:
48 print("failed to process %s" % f)
52 print("failed to process %s" % f)
49
53
50 main()
54 main()
@@ -1,64 +1,66 b''
1 #require docutils
1 #require docutils
2 #require gettext
2 #require gettext
3
3
4 Test document extraction
4 Test document extraction
5
5
6 $ HGENCODING=UTF-8
6 $ HGENCODING=UTF-8
7 $ export HGENCODING
7 $ export HGENCODING
8 $ { echo C; ls "$TESTDIR/../i18n"/*.po | sort; } | while read PO; do
8 $ { echo C; ls "$TESTDIR/../i18n"/*.po | sort; } | while read PO; do
9 > LOCALE=`basename "$PO" .po`
9 > LOCALE=`basename "$PO" .po`
10 > echo
10 > echo
11 > echo "% extracting documentation from $LOCALE"
11 > echo "% extracting documentation from $LOCALE"
12 > echo ".. -*- coding: utf-8 -*-" > gendoc-$LOCALE.txt
12 > echo ".. -*- coding: utf-8 -*-" > gendoc-$LOCALE.txt
13 > echo "" >> gendoc-$LOCALE.txt
13 > echo "" >> gendoc-$LOCALE.txt
14 > LANGUAGE=$LOCALE python "$TESTDIR/../doc/gendoc.py" >> gendoc-$LOCALE.txt 2> /dev/null || exit
14 > LANGUAGE=$LOCALE python "$TESTDIR/../doc/gendoc.py" >> gendoc-$LOCALE.txt 2> /dev/null || exit
15 >
15 >
16 > if [ $LOCALE != C ]; then
16 > if [ $LOCALE != C ]; then
17 > cmp -s gendoc-C.txt gendoc-$LOCALE.txt && echo '** NOTHING TRANSLATED **'
17 > cmp -s gendoc-C.txt gendoc-$LOCALE.txt && echo '** NOTHING TRANSLATED **'
18 > fi
18 > fi
19 >
19 >
20 > echo "checking for parse errors"
20 > echo "checking for parse errors"
21 > python "$TESTDIR/../doc/docchecker" gendoc-$LOCALE.txt
21 > python "$TESTDIR/../doc/docchecker" gendoc-$LOCALE.txt
22 > # We call runrst without adding "--halt warning" to make it report
22 > # We call runrst without adding "--halt warning" to make it report
23 > # all errors instead of stopping on the first one.
23 > # all errors instead of stopping on the first one.
24 > python "$TESTDIR/../doc/runrst" html gendoc-$LOCALE.txt /dev/null
24 > python "$TESTDIR/../doc/runrst" html gendoc-$LOCALE.txt /dev/null
25 > done
25 > done
26
26
27 % extracting documentation from C
27 % extracting documentation from C
28 checking for parse errors
28 checking for parse errors
29
29
30 % extracting documentation from da
30 % extracting documentation from da
31 checking for parse errors
31 checking for parse errors
32
32
33 % extracting documentation from de
33 % extracting documentation from de
34 checking for parse errors
34 checking for parse errors
35 Die Dateien werden dem Projektarchiv beim n\xc3\xa4chsten \xc3\x9cbernehmen (commit) hinzugef\xc3\xbcgt. Um dies vorher r\xc3\xbcckg\xc3\xa4ngig zu machen, siehe:hg:`forget`. (esc)
36 warning: please have a space before :hg:
35
37
36 % extracting documentation from el
38 % extracting documentation from el
37 checking for parse errors
39 checking for parse errors
38
40
39 % extracting documentation from fr
41 % extracting documentation from fr
40 checking for parse errors
42 checking for parse errors
41
43
42 % extracting documentation from it
44 % extracting documentation from it
43 checking for parse errors
45 checking for parse errors
44
46
45 % extracting documentation from ja
47 % extracting documentation from ja
46 checking for parse errors
48 checking for parse errors
47
49
48 % extracting documentation from pt_BR
50 % extracting documentation from pt_BR
49 checking for parse errors
51 checking for parse errors
50
52
51 % extracting documentation from ro
53 % extracting documentation from ro
52 checking for parse errors
54 checking for parse errors
53
55
54 % extracting documentation from ru
56 % extracting documentation from ru
55 checking for parse errors
57 checking for parse errors
56
58
57 % extracting documentation from sv
59 % extracting documentation from sv
58 checking for parse errors
60 checking for parse errors
59
61
60 % extracting documentation from zh_CN
62 % extracting documentation from zh_CN
61 checking for parse errors
63 checking for parse errors
62
64
63 % extracting documentation from zh_TW
65 % extracting documentation from zh_TW
64 checking for parse errors
66 checking for parse errors
General Comments 0
You need to be logged in to leave comments. Login now