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

Method fetch_rvalue

sphinx/pycode/parser.py:200–218  ·  view source on GitHub ↗

Fetch right-hand value of assignment.

(self)

Source from the content-addressed store, hash-verified

198 self.comment: str | None = None
199
200 def fetch_rvalue(self) -> list[Token]:
201 """Fetch right-hand value of assignment."""
202 tokens = []
203 while current := self.fetch_token():
204 tokens.append(current)
205 if current == [OP, '(']:
206 tokens += self.fetch_until([OP, ')'])
207 elif current == [OP, '{']:
208 tokens += self.fetch_until([OP, '}'])
209 elif current == [OP, '[']:
210 tokens += self.fetch_until([OP, ']'])
211 elif current == INDENT:
212 tokens += self.fetch_until(DEDENT)
213 elif current == [OP, ';']: # NoQA: SIM114
214 break
215 elif current and current.kind not in {OP, NAME, NUMBER, STRING}:
216 break
217
218 return tokens
219
220 def parse(self) -> None:
221 """Parse the code and obtain comment after assignment."""

Callers 1

parseMethod · 0.95

Calls 3

fetch_tokenMethod · 0.80
fetch_untilMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected