MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / analyze_doc

Function analyze_doc

ci/doc_link_checker.py:22–52  ·  view source on GitHub ↗
(home, path, args)

Source from the content-addressed store, hash-verified

20
21pattern = re.compile(r'\[.*?\]\(.*?\)')
22def 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
55def traverse(_dir, args):

Callers 1

traverseFunction · 0.85

Calls 2

accessibleFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected