MCPcopy Create free account
hub / github.com/defold/defold / _create_doc_element

Function _create_doc_element

engine/docs/script_doc.py:292–349  ·  view source on GitHub ↗
(tags)

Source from the content-addressed store, hash-verified

290 return info
291
292def _create_doc_element(tags):
293 element = script_doc_ddf_pb2.Element()
294 element.type = tags_to_proto_type(tags)
295
296 for value in tags["return"]:
297 """ Some of the possible variations:
298 @return name
299 @return [type:type]
300 @return [type:type] doc
301 @return name [type:type] doc
302 """
303 tmp = value.split(' ', 1)
304 if len(tmp) < 2:
305 tmp = [tmp[0], '']
306 if '[type:' in tmp[0]:
307 tmp = ['', value]
308 ret = element.returnvalues.add()
309 ret.name = tmp[0]
310 types, ret.doc = extract_type_from_docstr(tmp[1])
311 if isinstance(types, str):
312 types = [types]
313 ret.types.extend(types)
314
315 for value in tags["param"]:
316 tmp = value.split(' ', 1)
317 if len(tmp) < 2:
318 tmp = [tmp[0], '']
319 parameter = element.parameters.add()
320 parameter.is_optional, parameter.name = is_optional(tmp[0])
321 types, parameter.doc = extract_type_from_docstr(tmp[1])
322 if isinstance(types, str):
323 types = [types]
324 parameter.types.extend(types)
325
326 for value in tags["tparam"]:
327 tmp = value.split(' ', 1)
328 if len(tmp) < 2:
329 tmp = [tmp[0], '']
330 tparam = element.tparams.add()
331 tparam.name = tmp[0]
332 tparam.doc = tmp[1]
333 tparam.type = ""
334
335 for value in tags["member"]:
336 tmp = value.split(' ', 1)
337 if len(tmp) < 2:
338 tmp = [tmp[0], '']
339 member = element.members.add()
340 member.name = tmp[0]
341 member.type, member.doc = extract_type_from_docstr(tmp[1])
342
343 if 'examples' in tags:
344 element.examples = "".join(tags["examples"])
345
346 if 'replaces' in tags:
347 element.replaces = tags["replaces"]
348
349 return element

Callers 1

_parse_commentFunction · 0.85

Calls 7

tags_to_proto_typeFunction · 0.85
extract_type_from_docstrFunction · 0.85
is_optionalFunction · 0.85
ElementMethod · 0.80
splitMethod · 0.65
addMethod · 0.65
extendMethod · 0.45

Tested by

no test coverage detected