module

Noir::PythonRouteExtractor

Pure line-level helper for Python decorator-based framework adapters: locates the def/class that a route decorator applies to. Route decorators themselves are read by TreeSitterPythonRouteExtractor.

Instance methods

find_def_line(lines : Array(String), line_index : Int32, direction : Symbol = :down) : Int32

Locate the def/async def/class that a decorator applies to.

direction: :down walks forward past additional decorators and blank lines, stopping at the first non-decorator line (the one we want, or something that breaks the decorator chain). direction: :up walks backward, used when the decorator sits on a method whose enclosing class was found elsewhere.

Returns the index of the def/class line, or the original line_index when nothing matches.

Source