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

Method visit_Expr

sphinx/pycode/parser.py:440–459  ·  view source on GitHub ↗

Handles Expr node and pick up a comment if string.

(self, node: ast.Expr)

Source from the content-addressed store, hash-verified

438 self._handle_assignment(node)
439
440 def visit_Expr(self, node: ast.Expr) -> None:
441 """Handles Expr node and pick up a comment if string."""
442 if (
443 isinstance(self.previous, AssignmentLikeType)
444 and isinstance(node.value, ast.Constant)
445 and isinstance(node.value.value, str)
446 ):
447 try:
448 targets = get_assign_targets(self.previous)
449 varnames = get_lvar_names(targets[0], self.get_self())
450 for varname in varnames:
451 if isinstance(node.value.value, str):
452 docstring = node.value.value
453 else:
454 docstring = node.value.value.decode(self.encoding or 'utf-8')
455
456 self.add_variable_comment(varname, dedent_docstring(docstring))
457 self.add_entry(varname)
458 except TypeError:
459 pass # this assignment is not new definition!
460
461 def visit_Try(self, node: ast.Try) -> None:
462 """Handles Try node and processes body and else-clause.

Callers

nothing calls this directly

Calls 6

get_selfMethod · 0.95
add_variable_commentMethod · 0.95
add_entryMethod · 0.95
get_assign_targetsFunction · 0.85
get_lvar_namesFunction · 0.85
dedent_docstringFunction · 0.85

Tested by

no test coverage detected