(home, path, args)
| 20 | |
| 21 | pattern = re.compile(r'\[.*?\]\(.*?\)') |
| 22 | def analyze_doc(home, path, args): |
| 23 | problem_list = [] |
| 24 | with open(path) as f: |
| 25 | lines = f.readlines() |
| 26 | for line in lines: |
| 27 | if '[' in line and ']' in line and '(' in line and ')' in line: |
| 28 | all = pattern.findall(line) |
| 29 | for item in all: |
| 30 | start = item.find('(') |
| 31 | end = item.find(')') |
| 32 | ref = item[start+1: end] |
| 33 | if ref.endswith('.py') or ref.endswith('.rs'): |
| 34 | if not ref.startswith('http'): |
| 35 | problem_list.append(ref) |
| 36 | continue |
| 37 | if ref.startswith('http') or ref.startswith('#'): |
| 38 | if args.http == True and ref.startswith('http') and 'github' in ref and 'megengine' in ref.lower(): |
| 39 | if accessible(ref) == False: |
| 40 | problem_list.append(ref) |
| 41 | continue |
| 42 | fullpath = os.path.join(home, ref) |
| 43 | if not os.path.exists(fullpath): |
| 44 | problem_list.append(ref) |
| 45 | # print(f' {fullpath} in {path} not exist!') |
| 46 | else: |
| 47 | continue |
| 48 | if len(problem_list) > 0: |
| 49 | print(f'{path}:') |
| 50 | for item in problem_list: |
| 51 | print(f'\t {item}') |
| 52 | print('\n') |
| 53 | |
| 54 | |
| 55 | def traverse(_dir, args): |
no test coverage detected