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