Skip to content

Commit

Permalink
refac: #1117 update docs
Browse files Browse the repository at this point in the history
- reworded the first sentences to make it clearer

- removed project structure as requested

- removed sentence about rust installation

- replaced `cargo run` with respective command
  • Loading branch information
miguelcsx committed Sep 26, 2024
1 parent c133f6a commit 6e2dfd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 46 deletions.
26 changes: 7 additions & 19 deletions rust-code-analysis-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,23 @@

- Analyze source code for different programming languages.
- Export results in different formats (CBOR, JSON, TOML, YAML).
- Perform various operations on source code (e.g., dumping abstract syntax tree to stdout, count nodes, computing code metrics).

## Project Structure

```sh
rust-code-analysis-cli
├── Cargo.toml # Project metadata and dependencies
└── src
├── formats.rs # Handles format-specific output (CBOR, JSON, TOML, YAML)
└── main.rs # Main logic for command-line operations and code analysis
```
- Perform various operations on source code (e.g., dumping abstract syntax tree to stdout, counting nodes, computing code metrics).

## Installation

To use this tool, you need to have Rust installed on your system.

Clone the repository and run the following command:
Clone the repository and build the project:

```sh
cd rust-code-analysis-cli/
cargo build --debug # or cargo build --release
cargo build
```

## Usage

Run the tool by specifying the input file and the desired operation:

```sh
cargo run -- [OPTIONS]
rust-code-analysis-cli [OPTIONS]
```

## Available Options
Expand All @@ -47,13 +35,13 @@ cargo run -- [OPTIONS]
- `-C, --count <NODE_TYPE>`: Count nodes of the given type.
- `-m, --metrics`: Compute code metrics.
- `--ops`: Retrieve all operands and operators in the code.
- `-i, --in-place`: Do actions in place.
- `-i, --in-place`: Perform actions in place.
- `-I, --include [<INCLUDE>...]`: Include files matching the given pattern.
- `-X, --exclude [<EXCLUDE>...]`: Exclude files matching the given pattern.
- `-j, --num-jobs <NUM_JOBS>`: Number of threads to use.
- `-l, --language-type <LANGUAGE>`: Language of the input files.
- `-O, --output-format <FORMAT>`: Output format for the results (CBOR, JSON, TOML, YAML).
- `--pr`: Dump a pretty json output file.
- `--pr`: Dump a pretty JSON output file.
- `-o, --output <OUTPUT>`: Output directory for the results.
- `--preproc <PREPROCESSOR>`: Get preprocessor directives for C/C++ files.
- `--ls <LINE_START>`: Start line for the analysis.
Expand All @@ -67,5 +55,5 @@ cargo run -- [OPTIONS]
To analyze the code in a file and export the metrics in JSON format:

```sh
cargo run -- --metrics --output-format json --output . --paths path/to/file.rs
rust-code-analysis-cli --metrics --output-format json --output . --paths path/to/file.rs
```
37 changes: 10 additions & 27 deletions rust-code-analysis-web/README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,30 @@
# rust-code-analysis-web

`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.
`rust-code-analysis-web` is a web server that provides source code analysis capabilities via a RESTful API. It enables developers to interact with the code analysis functionality from the rust-code-analysis suite through HTTP requests.

## Features

- **Comment Removal**: Removes comments from source code to produce a clean version.
- **Function Spans**: Retrieves the start and end lines of functions in the provided source code.
- **Metrics Calculation**: Computes various static analysis metrics for the source code.
- **Comment Removal**: Removes comments from source code to provide a cleaner version of the code.
- **Function Spans**: Retrieves the start and end lines of functions in the given source code.
- **Metrics Calculation**: Computes static analysis metrics for the source code.

## Project Structure

```sh
rust-code-analysis-web
├── Cargo.toml # Project metadata, dependencies, and build configuration
└── src
├── bin/
│ └── rust-code-analysis-web.rs # Entry point for running the web server with CLI options
├── web/
│ ├── comment.rs # Logic for handling requests related to removing comments from source code
│ ├── function.rs # Logic for extracting and returning function spans from the source code
│ ├── metrics.rs # Logic for computing and returning code metrics based on the source code
│ ├── mod.rs # Module declarations and routing between web modules
│ └── server.rs # Actix web server setup, route definitions, and main server handler logic
└── lib.rs # Main library file, sets up the module imports and starts the server
```
Refer to the REST API documentation for detailed information about the available endpoints and parameters.

## Installation

To use `rust-code-analysis-web`, you need to have Rust installed on your system.

Clone the repository and run the following command:
Clone the repository and build the project:

```sh
cd rust-code-analysis-web/
cargo build --debug # or cargo build --release
cargo build
```

## Usage

Run the server by specifying the host and port:

```sh
cargo run -- [OPTIONS]
rust-code-analysis-web [OPTIONS]
```

### Available Options
Expand All @@ -52,10 +35,10 @@ cargo run -- [OPTIONS]
- `-h, --help`: Show help information.
- `-v, --version`: Show version information.

# Examples
## Examples

To start the server on a specific host and port:

```sh
cargo run -- --host <HOST> --port <PORT> -j <NUM_JOBS>
rust-code-analysis-web --host <HOST> --port <PORT> -j <NUM_JOBS>
```

0 comments on commit 6e2dfd3

Please sign in to comment.