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

Method fetch_until

sphinx/pycode/parser.py:169–186  ·  view source on GitHub ↗

Fetch tokens until specified token appeared. .. note:: This also handles parenthesis well.

(self, condition: Any)

Source from the content-addressed store, hash-verified

167 return self.current
168
169 def fetch_until(self, condition: Any) -> list[Token]:
170 """Fetch tokens until specified token appeared.
171
172 .. note:: This also handles parenthesis well.
173 """
174 tokens = []
175 while current := self.fetch_token():
176 tokens.append(current)
177 if current == condition:
178 break
179 if current == [OP, '(']:
180 tokens += self.fetch_until([OP, ')'])
181 elif current == [OP, '{']:
182 tokens += self.fetch_until([OP, '}'])
183 elif current == [OP, '[']:
184 tokens += self.fetch_until([OP, ']'])
185
186 return tokens
187
188
189class AfterCommentParser(TokenProcessor):

Callers 3

fetch_rvalueMethod · 0.80
parse_definitionMethod · 0.80
fetch_type_param_specMethod · 0.80

Calls 2

fetch_tokenMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected