File tree Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change
1
+ import argparse
2
+ import json
3
+ from collections import defaultdict
4
+ from termcolor import colored
5
+
6
+ status_colors = dict (
7
+ broken = 'red' ,
8
+ redirected = 'yellow' ,
9
+ working = 'green' ,
10
+ ignored = 'white' ,
11
+ unchecked = 'white' ,
12
+ )
13
+
14
+ def create_parser ():
15
+ parser = argparse .ArgumentParser ('display_linkcheck' )
16
+ parser .add_argument ('linkcheck_json' )
17
+ return parser
18
+
19
+
20
+ def main ():
21
+ parser = create_parser ()
22
+ args = parser .parse_args ()
23
+ buffer = defaultdict (list )
24
+ with open (args .linkcheck_json ) as fh :
25
+ for line in fh :
26
+ data = json .loads (line )
27
+ buffer [data ['status' ]].append (data )
28
+
29
+ for status , color in status_colors .items ():
30
+ if status not in buffer :
31
+ continue
32
+ for data in buffer [status ]:
33
+
34
+ print_tokens = [
35
+ colored (f'[{ data ["status" ]} ]' , color ),
36
+ colored (data ['uri' ], 'magenta' ),
37
+ f'{ data ["filename" ]} :{ data ["lineno" ]} ' ,
38
+ ]
39
+ if data ['info' ] != '' :
40
+ print_tokens .append (f'({ data ["info" ]} )' )
41
+
42
+ print (* print_tokens )
43
+
44
+ if __name__ == '__main__' :
45
+ main ()
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ dependencies:
16
16
- python-dateutil
17
17
- pip
18
18
- python-rapidjson
19
+ - termcolor
19
20
# uncomment to restore search
20
21
# - elm
21
22
# - nodejs
Original file line number Diff line number Diff line change @@ -30,7 +30,10 @@ pushd src
30
30
# -W --keep-going: list all warnings but fail build in case there are any
31
31
# -n: check validity of all links
32
32
make html SPHINXOPTS=" -W --keep-going -n"
33
- make linkcheck
33
+ linkcheck_failed=0
34
+ make linkcheck > /dev/null || linkcheck_failed=1
35
+ python ../.ci_scripts/display_linkcheck.py _build/linkcheck/output.json
36
+ test " $linkcheck_failed " -eq 0
34
37
mv _build/html ../docs
35
38
rm -rf _build
36
39
popd
You can’t perform that action at this time.
0 commit comments