Skip to content

Commit e9387e4

Browse files
Add Kotlin support to CodeWiki documentation and analysis tools
1 parent 87b96f5 commit e9387e4

File tree

11 files changed

+546
-6
lines changed

11 files changed

+546
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ codewiki generate --github-pages --create-branch
7676

7777
## What is CodeWiki?
7878

79-
CodeWiki is an open-source framework for **automated repository-level documentation** across seven programming languages. It generates holistic, architecture-aware documentation that captures not only individual functions but also their cross-file, cross-module, and system-level interactions.
79+
CodeWiki is an open-source framework for **automated repository-level documentation** across eight programming languages. It generates holistic, architecture-aware documentation that captures not only individual functions but also their cross-file, cross-module, and system-level interactions.
8080

8181
### Key Innovations
8282

@@ -88,7 +88,7 @@ CodeWiki is an open-source framework for **automated repository-level documentat
8888

8989
### Supported Languages
9090

91-
**🐍 Python****☕ Java****🟨 JavaScript****🔷 TypeScript****⚙️ C****🔧 C++****🪟 C#**
91+
**🐍 Python****☕ Java****🟨 JavaScript****🔷 TypeScript****⚙️ C****🔧 C++****🪟 C#****🎯 Kotlin**
9292

9393
---
9494

codewiki/cli/utils/repo_validator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
'.php', # PHP
3131
'.phtml', # PHP templates
3232
'.inc', # PHP includes
33+
'.kt', # Kotlin
34+
'.kts', # Kotlin Scripts
3335
}
3436

3537

codewiki/cli/utils/validation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def detect_supported_languages(directory: Path) -> List[Tuple[str, int]]:
172172
'C++': ['.cpp', '.hpp', '.cc', '.hh', '.cxx', '.hxx'],
173173
'C#': ['.cs'],
174174
'PHP': ['.php', '.phtml', '.inc'],
175+
'Kotlin': ['.kt', '.kts'],
175176
}
176177

177178
# Directories to exclude from counting

codewiki/src/be/dependency_analyzer/analysis/analysis_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ def _filter_supported_languages(self, code_files: List[Dict]) -> List[Dict]:
310310
"php",
311311
"go",
312312
"rust",
313+
"kotlin",
313314
}
314315

315316
return [
@@ -320,7 +321,7 @@ def _filter_supported_languages(self, code_files: List[Dict]) -> List[Dict]:
320321

321322
def _get_supported_languages(self) -> List[str]:
322323
"""Get list of currently supported languages for analysis."""
323-
return ["python", "javascript", "typescript", "java", "csharp", "c", "cpp", "php"]
324+
return ["python", "javascript", "typescript", "java", "csharp", "c", "cpp", "php", "kotlin"]
324325

325326
def _cleanup_repository(self, temp_dir: str):
326327
"""Clean up cloned repository."""

codewiki/src/be/dependency_analyzer/analysis/call_graph_analyzer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def _analyze_code_file(self, repo_dir: str, file_info: Dict):
126126
self._analyze_typescript_file(file_path, content, repo_dir)
127127
elif language == "java":
128128
self._analyze_java_file(file_path, content, repo_dir)
129+
elif language == "kotlin":
130+
self._analyze_kotlin_file(file_path, content, repo_dir)
129131
elif language == "csharp":
130132
self._analyze_csharp_file(file_path, content, repo_dir)
131133
elif language == "c":
@@ -280,6 +282,27 @@ def _analyze_java_file(self, file_path: str, content: str, repo_dir: str):
280282
except Exception as e:
281283
logger.error(f"Failed to analyze Java file {file_path}: {e}", exc_info=True)
282284

285+
def _analyze_kotlin_file(self, file_path: str, content: str, repo_dir: str):
286+
"""
287+
Analyze Kotlin file using tree-sitter based analyzer.
288+
289+
Args:
290+
file_path: Relative path to the Kotlin file
291+
content: File content string
292+
repo_dir: Repository base directory
293+
"""
294+
from codewiki.src.be.dependency_analyzer.analyzers.kotlin import analyze_kotlin_file
295+
296+
try:
297+
functions, relationships = analyze_kotlin_file(file_path, content, repo_path=repo_dir)
298+
for func in functions:
299+
func_id = func.id if func.id else f"{file_path}:{func.name}"
300+
self.functions[func_id] = func
301+
302+
self.call_relationships.extend(relationships)
303+
except Exception as e:
304+
logger.error(f"Failed to analyze Kotlin file {file_path}: {e}", exc_info=True)
305+
283306
def _analyze_csharp_file(self, file_path: str, content: str, repo_dir: str):
284307
"""
285308
Analyze C# file using tree-sitter based analyzer.
@@ -408,6 +431,8 @@ def _generate_visualization_data(self) -> Dict:
408431
node_classes.append("lang-c")
409432
elif file_ext in [".cpp", ".cc", ".cxx", ".hpp", ".hxx"]:
410433
node_classes.append("lang-cpp")
434+
elif file_ext in [".kt", ".kts"]:
435+
node_classes.append("lang-kotlin")
411436
elif file_ext in [".php", ".phtml", ".inc"]:
412437
node_classes.append("lang-php")
413438

0 commit comments

Comments
 (0)