MCPcopy Index your code
hub / github.com/sphinx-doc/sphinx / parse

Method parse

sphinx/pycode/parser.py:220–236  ·  view source on GitHub ↗

Parse the code and obtain comment after assignment.

(self)

Source from the content-addressed store, hash-verified

218 return tokens
219
220 def parse(self) -> None:
221 """Parse the code and obtain comment after assignment."""
222 # skip lvalue (or whole of AnnAssign)
223 while (tok := self.fetch_token()) and not tok.match(
224 [OP, '='], NEWLINE, COMMENT
225 ):
226 assert tok
227 assert tok is not None
228
229 # skip rvalue (if exists)
230 if tok == [OP, '=']:
231 self.fetch_rvalue()
232 tok = self.current
233 assert tok is not None
234
235 if tok == COMMENT:
236 self.comment = tok.value
237
238
239class VariableCommentPicker(ast.NodeVisitor):

Callers 1

_collect_doc_commentMethod · 0.95

Calls 3

fetch_rvalueMethod · 0.95
fetch_tokenMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected