This is an automated email from the ASF dual-hosted git repository.
shahar1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7e1a4504fcc Remove unused Sphinx snippet renderer (#75886)
7e1a4504fcc is described below
commit 7e1a4504fccffbba6fd5402915ba8804858988c3
Author: Hussein Awala <[email protected]>
AuthorDate: Thu Oct 29 06:19:43 2026 +0100
Remove unused Sphinx snippet renderer (#75886)
---
.../src/sphinx_exts/docs_build/code_utils.py | 45 ----------------------
1 file changed, 45 deletions(-)
diff --git a/devel-common/src/sphinx_exts/docs_build/code_utils.py
b/devel-common/src/sphinx_exts/docs_build/code_utils.py
index 78703f3d9d6..90c8498547d 100644
--- a/devel-common/src/sphinx_exts/docs_build/code_utils.py
+++ b/devel-common/src/sphinx_exts/docs_build/code_utils.py
@@ -17,7 +17,6 @@
from __future__ import annotations
import os
-from contextlib import suppress
from pathlib import Path
from sphinx_exts.provider_yaml_utils import load_package_data
@@ -35,50 +34,6 @@ PROCESS_TIMEOUT = 15 * 60 * 2
CONSOLE_WIDTH = 250
-def prepare_code_snippet(file_path: str, line_no: int, context_lines_count:
int = 5) -> str:
- """
- Prepares code snippet.
-
- :param file_path: file path
- :param line_no: line number
- :param context_lines_count: number of lines of context.
- """
-
- def guess_lexer_for_filename(filename):
- from pygments.lexers import get_lexer_for_filename
- from pygments.util import ClassNotFound
-
- try:
- lexer = get_lexer_for_filename(filename)
- except ClassNotFound:
- from pygments.lexers.special import TextLexer
-
- lexer = TextLexer()
- return lexer
-
- with open(file_path) as text_file:
- # Highlight code
- code = text_file.read()
- with suppress(ImportError):
- import pygments
- from pygments.formatters.terminal import TerminalFormatter
-
- code = pygments.highlight(
- code=code, formatter=TerminalFormatter(),
lexer=guess_lexer_for_filename(file_path)
- )
-
- code_lines = code.splitlines()
- # Prepend line number
- code_lines = [f"{line_no:4} | {line}" for line_no, line in
enumerate(code_lines, 1)]
- # # Cut out the snippet
- start_line_no = max(0, line_no - context_lines_count)
- end_line_no = line_no + context_lines_count
- code_lines = code_lines[start_line_no:end_line_no]
- # Join lines
- code = "\n".join(code_lines)
- return code
-
-
def pretty_format_path(path: str, start: str) -> str:
"""Formats path nicely."""
relpath = os.path.relpath(path, start)