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

Function _parse_comment

engine/docs/script_doc.py:351–398  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

349 return element
350
351def _parse_comment(text):
352 text = _strip_comment_stars(text)
353 # The regexp means match all strings that:
354 # * begins with line start, possible whitespace and an @
355 # * followed by non-white-space (the tag)
356 # * followed by possible spaces
357 # * followed by every character that is not an @ or is an @ but not preceded by a new line (the value)
358 lst = re.findall(r'^\s*@(\S+) *((?:[^@]|(?<!\n)@)*)', text, re.MULTILINE)
359 tags = {
360 "path": "",
361 "language": "",
362 "param": [],
363 "tparam": [],
364 "note": [],
365 "return": [],
366 "member": [],
367 "examples": [],
368 }
369 for tag,value in lst:
370 tag = tag.strip()
371 value = value.strip()
372 v = tags.get(tag)
373 if type(v) is list:
374 v.append(value)
375 else:
376 tags[tag] = value
377
378 # @struct somename
379 if "struct" in tags and "name" not in tags:
380 logging.warning('Missing tag @name, using value %s from @struct' % tags["struct"])
381 tags["name"] = tags["struct"]
382
383 if "name" not in tags:
384 logging.warning('Missing tag @name in "%s"' % text)
385 return None
386
387 element = None
388 if "document" in tags:
389 element = _create_doc_info(tags)
390 else:
391 element = _create_doc_element(tags)
392
393 element.description, element.brief = _parse_description(text)
394 element.name = tags["name"]
395 element.language = tags["language"]
396 element.notes.extend(tags["note"])
397
398 return element
399
400def extract_type_from_docstr(s):
401 # try to extract the type information

Callers 1

parse_documentFunction · 0.70

Calls 8

_create_doc_infoFunction · 0.85
_create_doc_elementFunction · 0.85
appendMethod · 0.80
warningMethod · 0.80
_strip_comment_starsFunction · 0.70
_parse_descriptionFunction · 0.70
getMethod · 0.65
extendMethod · 0.45

Tested by

no test coverage detected