MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / identifiers_info

Function identifiers_info

pywebio/platform/path_deploy.py:26–50  ·  view source on GitHub ↗

Get the identifiers and theirs docstring from python source code. :return dict:

(code)

Source from the content-addressed store, hash-verified

24
25
26def identifiers_info(code):
27 """Get the identifiers and theirs docstring from python source code.
28
29 :return dict:
30 """
31 try:
32 tree = ast.parse(code)
33 except Exception:
34 return {}
35
36 if not isinstance(tree, ast.Module):
37 return {}
38
39 identifier2doc = {}
40 for node in tree.body:
41 if isinstance(node, ast.Assign):
42 for name in node.targets:
43 if hasattr(name, 'id'):
44 identifier2doc[name.id] = ''
45 elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
46 doc_string = ast.get_docstring(node) or ''
47 title = doc_string.split('\n\n')[0]
48 identifier2doc[node.name] = title
49
50 return identifier2doc
51
52
53def valid_and_norm_path(base, subpath):

Callers 1

default_index_pageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…