9 path = os.path.dirname(os.path.realpath(__file__))
10 rstpath = os.path.join(path,
'../docs/source/')
11 pypath = os.path.join(path,
'../torch/_torch_docs.py')
12 r1 = re.compile(
r'\.\. autofunction:: (\w*)')
20 'set_printoptions',
'get_rng_state',
'is_storage',
'initial_seed',
21 'set_default_tensor_type',
'load',
'save',
'set_default_dtype',
22 'is_tensor',
'compiled_with_cxx11_abi',
'set_rng_state',
26 filename = os.path.join(rstpath,
'torch.rst')
27 with open(filename,
'r') as f: 33 everything.add(name[0])
34 everything -= set(whitelist)
36 whitelist2 = [
'product',
'inf',
'math',
'reduce',
'warnings',
'torch',
'annotate']
38 with open(pypath,
'r') as f: 39 body = ast.parse(f.read()).body 41 if not isinstance(i, _ast.Expr):
44 if not isinstance(i, _ast.Call):
46 if i.func.id !=
'add_docstr':
49 if i.value.id !=
'torch':
54 if not p.startswith(
'_')
and p[0].islower():
56 everything2 -= set(whitelist2)
59 self.assertIn(p, everything2,
'in torch.rst but not in python')
61 self.assertIn(p, everything,
'in python but not in torch.rst')
64 if __name__ ==
'__main__':