fix(detect): classify Jinja templates as documents (#3427)
The bug:
Jinja2 templates were completely skipped by Graphify's detection phase because their extensions were not listed in the recognized document extensions. This resulted in the source for generated files being hidden from the graph.
The fix:
Added `.j2`, `.jinja`, and `.jinja2` to the `DOC_EXTENSIONS` set in `graphify/detect.py`.
Tests:
`tests/test_detect_jinja.py` added to verify the newly added Jinja extensions are accurately recognized as documents. This ensures the bug does not regress in future updates.
(cherry picked from commit 61f6a40a56)
This commit is contained in:
1 parent
8d5b139da4
commit
22124ba76d
3 files changed
+8
-1
No files matched your search
+1
-1
@@ -46,7 +46,7 @@ _MTIME_COARSE_S = 2.0
|
||||
_MTIME_SUBSECOND_S = 0.05
|
||||
|
||||
CODE_EXTENSIONS = {'.py', '.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs', '.ejs', '.ets', '.go', '.rs', '.vb', '.cbl', '.cob', '.cobol', '.cpy', '.java', '.groovy', '.gradle', '.cpp', '.cc', '.cxx', '.c', '.h', '.hpp', '.cu', '.cuh', '.metal', '.rb', '.rake', '.swift', '.kt', '.kts', '.cs', '.scala', '.php', '.lua', '.luau', '.toc', '.zig', '.ps1', '.psm1', '.psd1', '.ex', '.exs', '.m', '.mm', '.ml', '.mli', '.jl', '.vue', '.svelte', '.astro', '.dart', '.v', '.sv', '.svh', '.vh', '.sql', '.r', '.f', '.F', '.f90', '.F90', '.f95', '.F95', '.f03', '.F03', '.f08', '.F08', '.pas', '.pp', '.dpr', '.dpk', '.lpr', '.inc', '.dfm', '.lfm', '.lpk', '.sh', '.bash', '.json', '.tf', '.tfvars', '.hcl', '.dm', '.dme', '.dmi', '.dmm', '.dmf', '.sln', '.slnx', '.csproj', '.fsproj', '.vbproj', '.xaml', '.razor', '.cshtml', '.cls', '.trigger', '.lisp', '.cl', '.lsp', '.asd', '.robot', '.resource', '.sol', '.erl', '.hrl', '.escript'}
|
||||
DOC_EXTENSIONS = {'.md', '.mdx', '.qmd', '.skill', '.txt', '.rst', '.html', '.yaml', '.yml'}
|
||||
DOC_EXTENSIONS = {'.md', '.mdx', '.qmd', '.skill', '.txt', '.rst', '.html', '.yaml', '.yml', '.j2', '.jinja', '.jinja2'}
|
||||
PAPER_EXTENSIONS = {'.pdf'}
|
||||
IMAGE_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg'}
|
||||
OFFICE_EXTENSIONS = {'.docx', '.xlsx'}
|
||||
|
||||
@@ -40,6 +40,7 @@ from graphify.extractors.base import _read_source_text
|
||||
_SPLITTABLE_TEXT_SUFFIXES = frozenset({
|
||||
".md", ".mdx", ".markdown", ".txt", ".rst",
|
||||
".qmd", ".skill", ".html", ".yaml", ".yml",
|
||||
".j2", ".jinja", ".jinja2",
|
||||
})
|
||||
|
||||
# Document types whose BYTES are not what the model is shown. `llm._file_to_text`
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
from graphify.detect import DOC_EXTENSIONS
|
||||
|
||||
def test_jinja2_extensions_are_documents():
|
||||
assert '.j2' in DOC_EXTENSIONS
|
||||
assert '.jinja' in DOC_EXTENSIONS
|
||||
assert '.jinja2' in DOC_EXTENSIONS
|
||||
Reference in new issue
Block a user