MCPcopy
hub / github.com/pandas-dev/pandas / get_api_items

Function get_api_items

scripts/validate_docstrings.py:87–157  ·  view source on GitHub ↗

Yield information about all public API items. Parse api.rst file from the documentation, and extract all the functions, methods, classes, attributes... This should include all pandas public API. Parameters ---------- api_doc_fd : file descriptor A file descriptor o

(api_doc_fd)

Source from the content-addressed store, hash-verified

85
86
87def get_api_items(api_doc_fd):
88 """
89 Yield information about all public API items.
90
91 Parse api.rst file from the documentation, and extract all the functions,
92 methods, classes, attributes... This should include all pandas public API.
93
94 Parameters
95 ----------
96 api_doc_fd : file descriptor
97 A file descriptor of the API documentation page, containing the table
98 of contents with all the public API.
99
100 Yields
101 ------
102 name : str
103 The name of the object (e.g. 'pandas.Series.str.upper').
104 func : function
105 The object itself. In most cases this will be a function or method,
106 but it can also be classes, properties, cython objects...
107 section : str
108 The name of the section in the API page where the object item is
109 located.
110 subsection : str
111 The name of the subsection in the API page where the object item is
112 located.
113 """
114 current_module = "pandas"
115 previous_line = current_section = current_subsection = ""
116 position = None
117 for line in api_doc_fd:
118 line_stripped = line.strip()
119 if len(line_stripped) == len(previous_line):
120 if set(line_stripped) == set("-"):
121 current_section = previous_line
122 continue
123 if set(line_stripped) == set("~"):
124 current_subsection = previous_line
125 continue
126
127 if line_stripped.startswith(".. currentmodule::"):
128 current_module = line_stripped.replace(".. currentmodule::", "").strip()
129 continue
130
131 if line_stripped == ".. autosummary::":
132 position = "autosummary"
133 continue
134
135 if position == "autosummary":
136 if line_stripped == "":
137 position = "items"
138 continue
139
140 if position == "items":
141 if line_stripped == "":
142 position = None
143 continue
144 if line_stripped in IGNORE_VALIDATION:

Callers 1

get_all_api_itemsFunction · 0.85

Calls 4

stripMethod · 0.80
startswithMethod · 0.80
splitMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected