MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / method_params

Function method_params

scripts/describe.py:203–250  ·  view source on GitHub ↗

Document the parameters of a method. Args: doc: string, The method's docstring. Returns: The method signature as a string.

(doc)

Source from the content-addressed store, hash-verified

201
202
203def method_params(doc):
204 """Document the parameters of a method.
205
206 Args:
207 doc: string, The method's docstring.
208
209 Returns:
210 The method signature as a string.
211 """
212 doclines = doc.splitlines()
213 if "Args:" in doclines:
214 begin = doclines.index("Args:")
215 if "Returns:" in doclines[begin + 1 :]:
216 end = doclines.index("Returns:", begin)
217 args = doclines[begin + 1 : end]
218 else:
219 args = doclines[begin + 1 :]
220
221 parameters = []
222 sorted_parameters = []
223 pname = None
224 desc = ""
225
226 def add_param(pname, desc):
227 if pname is None:
228 return
229 if "(required)" not in desc:
230 pname = pname + "=None"
231 parameters.append(pname)
232 else:
233 # required params should be put straight into sorted_parameters
234 # to maintain order for positional args
235 sorted_parameters.append(pname)
236
237 for line in args:
238 m = re.search(r"^\s+([a-zA-Z0-9_]+): (.*)", line)
239 if m is None:
240 desc += line
241 continue
242 add_param(pname, desc)
243 pname = m.group(1)
244 desc = m.group(2)
245 add_param(pname, desc)
246 sorted_parameters.extend(sorted(parameters))
247 sorted_parameters = ", ".join(sorted_parameters)
248 else:
249 sorted_parameters = ""
250 return sorted_parameters
251
252
253def method(name, doc):

Callers 2

methodFunction · 0.70
document_collectionFunction · 0.70

Calls 1

add_paramFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…