MCPcopy Create free account
hub / github.com/sphinx-doc/sphinx / parse_definition

Method parse_definition

sphinx/pycode/parser.py:557–576  ·  view source on GitHub ↗

Parse AST of definition.

(self, typ: str)

Source from the content-addressed store, hash-verified

555 self.finalize_block()
556
557 def parse_definition(self, typ: str) -> None:
558 """Parse AST of definition."""
559 name = self.fetch_token()
560 self.context.append(name.value) # type: ignore[union-attr]
561 funcname = '.'.join(self.context)
562
563 if self.decorator:
564 start_pos = self.decorator.start[0]
565 self.decorator = None
566 else:
567 start_pos = name.start[0] # type: ignore[union-attr]
568
569 self.fetch_until([OP, ':'])
570 if self.fetch_token().match(COMMENT, NEWLINE): # type: ignore[union-attr]
571 self.fetch_until(INDENT)
572 self.indents.append((typ, funcname, start_pos))
573 else:
574 # one-liner
575 self.add_definition(funcname, (typ, start_pos, name.end[0])) # type: ignore[union-attr]
576 self.context.pop()
577
578 def finalize_block(self) -> None:
579 """Finalize definition block."""

Callers 1

parseMethod · 0.95

Calls 7

add_definitionMethod · 0.95
fetch_tokenMethod · 0.80
fetch_untilMethod · 0.80
popMethod · 0.80
appendMethod · 0.45
joinMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected