A powerful console application written in V (Vlang) that recursively analyzes source code directories across multiple programming languages, extracting code structure (modules, classes, methods, functions) and documentation.
- Multi-language Support: Built-in support for 20 programming languages
- Recursive Analysis: Scans directories and subdirectories automatically
- Documentation Extraction: Captures comments and docstrings before code elements
- Extensible: Add custom language support via configuration files
- Fast Performance: Efficiently handles projects with thousands of files
- Cross-platform: Works on Windows, Linux, and macOS
| Language | Extensions |
|---|---|
| Java | .java |
| JavaScript | .js, .jsx |
| TypeScript | .ts, .tsx |
| Dart | .dart |
| Rust | .rs |
| C++ | .cpp, .cc, .cxx, .hpp, .h, .hxx |
| Python | .py |
| C# | .cs |
| V (Vlang) | .v, .vv |
| C | .c |
| D | .d |
| Lua | .lua |
| Pascal | .pas, .pp, .inc |
| Swift | .swift |
| Ruby | .rb |
| Go | .go |
| Kotlin | .kt, .kts |
| Scala | .scala |
| PHP | .php |
| Zig | .zig |
- V (Vlang) compiler installed on your system
- Download from: https://vlang.io
# Clone the repository
git clone <repository-url>
cd code-analyzer
# Build the project
v -prod src/main.v -o code-analyzer
# Or simply run without building
v run src/main.v -- --help# Analyze a directory
code-analyzer --input ./my-project
# Analyze with verbose output
code-analyzer --input ./my-project --verbose
# Specify output file
code-analyzer --input ./my-project --output analysis.txt-i, --input <path> Root directory path (required)
-l, --lang <language> Programming language filter (optional)
-o, --output <file> Output file path (default: ./output.txt)
-c, --config <file> Custom config file path (YAML or JSON)
-v, --verbose Show progress and details
-h, --help Show help message
# Analyze a Python project
code-analyzer --input ./django-app --lang python --output results.txt
# Analyze all supported languages with progress
code-analyzer --input ./polyglot-project --verbose
# Use custom configuration for additional languages
code-analyzer --input ./src --config ./custom-config.yaml --verbose
# Analyze a specific directory structure
code-analyzer -i /path/to/source -o /path/to/output.txt -v
# Analyze Kotlin files
code-analyzer --input ./kotlin-app --output kotlin-analysis.txt
# Analyze Scala project
code-analyzer --input ./scala-project --verbose
# Analyze PHP application
code-analyzer --input ./wordpress-plugin --output php-output.txt
# Analyze Zig project
code-analyzer --input ./zig-program --verboseThe analyzer generates a text file with the following format:
path/to/file.extension
class ClassName [– inherited ParentClass] – brief documentation
public method methodName() – method documentation
function functionName() – function documentation
module ModuleName – module documentation
path/to/another/file.extension
...
src/animals/dog.py
class Dog – inherited Animal – Represents a domestic dog
public method bark() – Emits a loud sound
function feed(pet) – Provides food to the animal
src/utils/helper.js
class StringHelper – Utility class for string operations
public method capitalize() – Capitalizes first letter
function formatDate(date) – Formats a date to string
src/app/Calculator.kt
class Calculator – A simple calculator class
public method add(a Double, b Double) – Adds two numbers together
private method logOperation(op String) – Logs operation
data class Result – Calculation result with timestamp
src/core/Processor.scala
trait Processor – Interface for data processing
class TextProcessor – inherited Processor – Text processor
public method process(input String) – Processes input
object Factory – Factory for creating instances
src/model/User.php
class User – User class representing a user
public method __construct(name, email) – Constructor
private method validateEmail(email) – Validates email
interface UserRepository – Interface for user repos
src/utils/math.zig
pub const struct Point – 2D coordinate point
pub fn add(a f64, b f64) – Adds two numbers
fn square(x f64) – Calculates square of number
- Classes: First 5 lines of documentation before the class definition
- Methods/Functions: First 2 lines of documentation before the definition
- Modules: First 5 lines of documentation before the module declaration
- Comments are automatically cleaned of markers (
//,#,/*,*/, etc.) - Empty lines and extra whitespace are removed
You can extend the analyzer to support additional languages using a YAML or JSON configuration file.
custom_languages:
- extension: ".mylang"
rules:
class_pattern: "class\\s+(\\w+)(?:\\s+extends\\s+(\\w+))?"
function_pattern: "fn\\s+(\\w+)\\s*\\("
method_pattern: "(public|private)?\\s+method\\s+(\\w+)\\s*\\("
module_pattern: "module\\s+(\\w+)"
doc_comment_marker: "#"
doc_before_element: true{
"custom_languages": [
{
"extension": ".mylang",
"class_pattern": "class\\s+(\\w+)(?:\\s+extends\\s+(\\w+))?",
"function_pattern": "fn\\s+(\\w+)\\s*\\(",
"method_pattern": "(public|private)?\\s+method\\s+(\\w+)\\s*\\(",
"module_pattern": "module\\s+(\\w+)",
"doc_comment_marker": "#",
"doc_before_element": true
}
]
}code-analyzer --input ./src --config ./my-config.yamlcode-analyzer/
├── v.mod # V module configuration
├── README.md # This file
├── LICENSE # License file
├── src/
│ ├── main.v # Entry point and CLI parsing
│ ├── analyzer.v # Main analysis logic
│ ├── config.v # Configuration loading
│ ├── output.v # Output formatting
│ ├── progress.v # Progress tracking
│ └── parsers/
│ ├── base.v # Base parser interface
│ ├── python.v # Python parser
│ ├── js_ts.v # JavaScript/TypeScript parser
│ ├── java.v # Java parser
│ ├── rust.v # Rust parser
│ ├── cpp.v # C++ parser
│ ├── csharp.v # C# parser
│ ├── dart.v # Dart parser
│ ├── c.v # C parser
│ ├── d.v # D parser
│ ├── lua.v # Lua parser
│ ├── pascal.v # Pascal parser
│ ├── swift.v # Swift parser
│ ├── ruby.v # Ruby parser
│ ├── go.v # Go parser
│ ├── vlang.v # V (Vlang) parser
│ ├── kotlin.v # Kotlin parser
│ ├── scala.v # Scala parser
│ ├── php.v # PHP parser
│ └── zig.v # Zig parser
└── examples/
├── config.yaml # Example configuration
└── sample_output.txt # Sample output format
- Handles up to 10,000 files in ≤ 2 minutes on typical hardware
- Efficient regex-based parsing for fast analysis
- Lazy file reading to minimize memory usage
- Concurrent processing capabilities (future enhancement)
The analyzer is designed to be robust:
- Gracefully skips unreadable files
- Continues processing after encountering syntax errors
- Logs errors to stderr without crashing
- Reports summary of failed files with
--verboseflag
- Basic parsing using regex patterns (not full AST analysis)
- May miss complex nested structures
- Documentation extraction limited to comments before definitions
- Custom language support requires regex knowledge
- Does not analyze code semantics or relationships
v test .v -prod src/main.v -o code-analyzer- All code follows V language conventions
- English comments only
- Public functions are documented
- Error handling using V's
?and!operators
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Create a new file in
src/parsers/(e.g.,kotlin.v) - Implement the
Parserinterface - Add the parser to
analyzer.vinregister_parsers() - Add tests for the new parser
- Update the README with the new language
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with V (Vlang)
- Inspired by various code analysis tools
- Thanks to all contributors
For issues, questions, or contributions:
- Open an issue on GitHub
- Check existing documentation
- Review example configurations
- Added support for Kotlin (.kt, .kts)
- Added support for Scala (.scala)
- Added support for PHP (.php)
- Added support for Zig (.zig)
- Total support for 20 programming languages
- Initial release
- Support for 16 programming languages
- Basic documentation extraction
- Custom configuration support
- Verbose progress tracking
- Cross-platform compatibility