MCPcopy Create free account
hub / github.com/fastapi/fastapi / extract_code_includes

Function extract_code_includes

scripts/doc_parsing_utils.py:81–94  ·  view source on GitHub ↗

Extract lines that contain code includes. Return list of CodeIncludeInfo, where each dict contains: - `line_no` - line number (1-based) - `line` - text of the line

(lines: list[str])

Source from the content-addressed store, hash-verified

79
80
81def extract_code_includes(lines: list[str]) -> list[CodeIncludeInfo]:
82 """
83 Extract lines that contain code includes.
84
85 Return list of CodeIncludeInfo, where each dict contains:
86 - `line_no` - line number (1-based)
87 - `line` - text of the line
88 """
89
90 includes: list[CodeIncludeInfo] = []
91 for line_no, line in enumerate(lines, start=1):
92 if CODE_INCLUDE_RE.match(line):
93 includes.append(CodeIncludeInfo(line_no=line_no, line=line))
94 return includes
95
96
97def replace_code_includes_with_placeholders(text: list[str]) -> list[str]:

Callers 2

check_translationFunction · 0.85

Calls 1

CodeIncludeInfoClass · 0.85

Tested by

no test coverage detected