Skip to content

Commit 1e77b07

Browse files
author
razvan
committed
refactor(docs): remove CSS/SCSS/SQL/SH/Svelte from docs parser
These file types are not documentation - they are code that was incorrectly classified as docs. Removing them from the docs parser: - SQL: query language - SH: shell scripts - Svelte: frontend framework components This reduces docs from 551 to ~49 files on the barou Laravel project, making the language sort put PHP/JS first and dramatically reducing indexing time for documentation. Updated tests to verify these extensions are no longer handled by docs.
1 parent e0b6ba9 commit 1e77b07

2 files changed

Lines changed: 10 additions & 24 deletions

File tree

pkg/parser/docs/analyzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func (a *Analyzer) CanHandle(path string) bool {
3636
// Markdown
3737
case ".md", ".markdown":
3838
return true
39-
// Tree-sitter supported structured / config / markup / scripts
40-
case ".yaml", ".yml", ".json", ".xml", ".toml", ".rst", ".css", ".scss", ".sql", ".sh", ".svelte":
39+
// Tree-sitter supported structured / config / markup
40+
case ".yaml", ".yml", ".json", ".xml", ".toml", ".rst":
4141
return true
4242
default:
4343
return false

pkg/parser/docs/analyzer_test.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
func TestAnalyzer_CanHandle(t *testing.T) {
1414
analyzer := NewAnalyzer()
1515

16-
validExts := []string{"test.md", "README.markdown", "config.yaml", "data.json", "conf.toml", "index.xml", "doc.rst", "style.css", "main.scss", "query.sql", "script.sh"}
17-
invalidExts := []string{"main.go", "script.js", "style.less", "data.csv"}
16+
validExts := []string{"test.md", "README.markdown", "config.yaml", "data.json", "conf.toml", "index.xml", "doc.rst"}
17+
invalidExts := []string{"main.go", "script.js", "style.css", "main.scss", "style.less", "query.sql", "script.sh", "app.svelte", "data.csv"}
1818

1919
for _, ext := range validExts {
2020
assert.True(t, analyzer.CanHandle(ext), "Should handle %s", ext)
@@ -126,25 +126,11 @@ func TestAnalyzer_TreesitterParsing_JSON(t *testing.T) {
126126
assert.Greater(t, len(result.Symbols), 0, "Should extract symbols from json via treesitter")
127127
}
128128

129-
func TestAnalyzer_TreesitterParsing_CSS(t *testing.T) {
129+
func TestAnalyzer_DoesNotHandle_CSS(t *testing.T) {
130130
analyzer := NewAnalyzer()
131-
132-
tmpDir := t.TempDir()
133-
cssFile := filepath.Join(tmpDir, "style.css")
134-
135-
cssContent := `
136-
body {
137-
background-color: red;
138-
}
139-
.header {
140-
font-size: 24px;
141-
}
142-
`
143-
err := os.WriteFile(cssFile, []byte(cssContent), 0644)
144-
require.NoError(t, err)
145-
146-
result, err := analyzer.Analyze(context.Background(), cssFile)
147-
require.NoError(t, err)
148-
require.NotNil(t, result)
149-
assert.Greater(t, len(result.Symbols), 0, "Should extract symbols from css via treesitter")
131+
assert.False(t, analyzer.CanHandle("style.css"), "CSS should NOT be handled by docs parser")
132+
assert.False(t, analyzer.CanHandle("main.scss"), "SCSS should NOT be handled by docs parser")
133+
assert.False(t, analyzer.CanHandle("query.sql"), "SQL should NOT be handled by docs parser")
134+
assert.False(t, analyzer.CanHandle("script.sh"), "Shell should NOT be handled by docs parser")
135+
assert.False(t, analyzer.CanHandle("app.svelte"), "Svelte should NOT be handled by docs parser")
150136
}

0 commit comments

Comments
 (0)