Skip to content

Commit 6dbfe6f

Browse files
committed
docs: #377 create documentation
- added documentation per package module - included information about the code, how to build and run it - give information about the flags that can be used
1 parent f43652b commit 6dbfe6f

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

rust-code-analysis-cli/README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# rust-code-analysis-cli
2+
3+
`rust-code-analysis-cli` is a tool designed to compute and export code metrics, analyze source code, and perform various operations such as removing comments, counting nodes, retrieving functions, and computing code metrics in different formats.
4+
5+
## Features
6+
7+
- Analyze source code for different programming languages.
8+
- Export results in different formats (CBOR, JSON, TOML, YAML).
9+
- Perform various operations on source code (e.g., dumping abstract syntax tree to stdout, count nodes, computing code metrics).
10+
11+
## Project Structure
12+
13+
```sh
14+
rust-code-analysis-cli
15+
├── Cargo.toml # Project metadata and dependencies
16+
└── src
17+
├── formats.rs # Handles format-specific output (CBOR, JSON, TOML, YAML)
18+
└── main.rs # Main logic for command-line operations and code analysis
19+
```
20+
21+
## Installation
22+
23+
To use this tool, you need to have Rust installed on your system.
24+
25+
Clone the repository and run the following command:
26+
27+
```sh
28+
cd rust-code-analysis-cli/
29+
cargo build --debug # or cargo build --release
30+
```
31+
32+
## Usage
33+
34+
Run the tool by specifying the input file and the desired operation:
35+
36+
```sh
37+
cargo run -- [OPTIONS]
38+
```
39+
40+
## Available Options
41+
42+
- `-p, --paths <FILE>...`: Input files to analyze.
43+
- `-d, --dump`: Dump the abstract syntax tree to stdout.
44+
- `-c, --comments`: Remove comments from specified files.
45+
- `-f, --find <NODE_TYPE>`: Find nodes of the given type.
46+
- `-F, --function`: Get functions and their spans.
47+
- `-C, --count <NODE_TYPE>`: Count nodes of the given type.
48+
- `-m, --metrics`: Compute code metrics.
49+
- `--ops`: Retrieve all operands and operators in the code.
50+
- `-i, --in-place`: Do actions in place.
51+
- `-I, --include [<INCLUDE>...]`: Include files matching the given pattern.
52+
- `-X, --exclude [<EXCLUDE>...]`: Exclude files matching the given pattern.
53+
- `-j, --num-jobs <NUM_JOBS>`: Number of threads to use.
54+
- `-l, --language-type <LANGUAGE>`: Language of the input files.
55+
- `-O, --output-format <FORMAT>`: Output format for the results (CBOR, JSON, TOML, YAML).
56+
- `--pr`: Dump a pretty json output file.
57+
- `-o, --output <OUTPUT>`: Output directory for the results.
58+
- `--preproc <PREPROCESSOR>`: Get preprocessor directives for C/C++ files.
59+
- `--ls <LINE_START>`: Start line for the analysis.
60+
- `--le <LINE_END>`: End line for the analysis.
61+
- `-w, --warning`: Show warnings.
62+
- `-v, --version`: Show version information.
63+
- `-h, --help`: Show help information.
64+
65+
## Examples
66+
67+
To analyze the code in a file and export the metrics in JSON format:
68+
69+
```sh
70+
cargo run -- --metrics --output-format json --output . --paths path/to/file.rs
71+
```

rust-code-analysis-web/README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# rust-code-analysis-web
2+
3+
`rust-code-analysis-web` is a web server that facilitates the analysis of source code through a RESTful API. It is part of the rust-code-analysis suite and allows developers to remotely interact with the code analysis features provided by the library.
4+
5+
## Features
6+
7+
- **Comment Removal**: Removes comments from source code to produce a clean version.
8+
- **Function Spans**: Retrieves the start and end lines of functions in the provided source code.
9+
- **Metrics Calculation**: Computes various static analysis metrics for the source code.
10+
11+
## Project Structure
12+
13+
```sh
14+
rust-code-analysis-web
15+
├── Cargo.toml # Project metadata, dependencies, and build configuration
16+
└── src
17+
├── bin/
18+
│ └── rust-code-analysis-web.rs # Entry point for running the web server with CLI options
19+
├── web/
20+
│ ├── comment.rs # Logic for handling requests related to removing comments from source code
21+
│ ├── function.rs # Logic for extracting and returning function spans from the source code
22+
│ ├── metrics.rs # Logic for computing and returning code metrics based on the source code
23+
│ ├── mod.rs # Module declarations and routing between web modules
24+
│ └── server.rs # Actix web server setup, route definitions, and main server handler logic
25+
└── lib.rs # Main library file, sets up the module imports and starts the server
26+
```
27+
28+
## Installation
29+
30+
To use `rust-code-analysis-web`, you need to have Rust installed on your system.
31+
32+
Clone the repository and run the following command:
33+
34+
```sh
35+
cd rust-code-analysis-web/
36+
cargo build --debug # or cargo build --release
37+
```
38+
39+
## Usage
40+
41+
Run the server by specifying the host and port:
42+
43+
```sh
44+
cargo run -- [OPTIONS]
45+
```
46+
47+
### Available Options
48+
49+
- `-j, --num-jobs <NUM_JOBS>`: Number of parallel jobs to run (optional).
50+
- `--host <HOST>`: IP address where the server should run (default is 127.0.0.1).
51+
- `--port <PORT>`: Port to be used by the server (default is 8080).
52+
- `-h, --help`: Show help information.
53+
- `-v, --version`: Show version information.
54+
55+
# Examples
56+
57+
To start the server on a specific host and port:
58+
59+
```sh
60+
cargo run -- --host <HOST> --port <PORT> -j <NUM_JOBS>
61+
```

0 commit comments

Comments
 (0)