Skip to content

Commit 5e41763

Browse files
committed
Added interactive stuff to make usage easier on Windows
1 parent 120aeb0 commit 5e41763

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

check_tools/find_bad_doxy_references.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,35 @@
44
import sys
55
import re
66
import requests
7+
from subprocess import check_output
8+
from builtins import input, open
79

810
PATTERN = (
911
"\[!\[View code\]\(https://www\.mbed\.com/embed/\?type=library\)\]"
1012
"\((.*)\)"
1113
)
1214

13-
def main(path):
15+
def main(path=None):
1416
bad = False
17+
interactive = False
18+
19+
if not path:
20+
interactive = True
21+
22+
# Go to root to make paths easier
23+
root = check_output(['git', 'rev-parse', '--show-toplevel']).strip()
24+
os.chdir(root)
25+
26+
# Ask for path in case user is unfamiliar with command line
27+
path = input('What directory should I check? ')
1528

1629
for dir, dirs, files in os.walk(path):
1730
for file in files:
1831
if not file.endswith('.md'):
1932
continue
2033

2134
path = os.path.join(dir, file)
22-
with open(path) as file:
35+
with open(path, encoding='utf-8') as file:
2336
for i, line in enumerate(file):
2437
for match in re.findall(PATTERN, line):
2538
if match.startswith('https:'):
@@ -45,6 +58,9 @@ def main(path):
4558
dirs.remove(dir)
4659

4760
sys.stdout.write('\nDone!\n')
61+
if interactive:
62+
input('Hit any key to continue ')
63+
4864
return 0 if not bad else 1
4965

5066

0 commit comments

Comments
 (0)