solidity-comments
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "solidity-comments", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": "github:frangio/solidity-comments", | ||
@@ -55,13 +55,13 @@ "main": "index.js", | ||
"optionalDependencies": { | ||
"solidity-comments-darwin-arm64": "0.0.1", | ||
"solidity-comments-win32-arm64-msvc": "0.0.1", | ||
"solidity-comments-linux-arm64-gnu": "0.0.1", | ||
"solidity-comments-linux-arm64-musl": "0.0.1", | ||
"solidity-comments-win32-ia32-msvc": "0.0.1", | ||
"solidity-comments-darwin-x64": "0.0.1", | ||
"solidity-comments-win32-x64-msvc": "0.0.1", | ||
"solidity-comments-linux-x64-gnu": "0.0.1", | ||
"solidity-comments-linux-x64-musl": "0.0.1", | ||
"solidity-comments-freebsd-x64": "0.0.1" | ||
"solidity-comments-darwin-arm64": "0.0.2", | ||
"solidity-comments-win32-arm64-msvc": "0.0.2", | ||
"solidity-comments-linux-arm64-gnu": "0.0.2", | ||
"solidity-comments-linux-arm64-musl": "0.0.2", | ||
"solidity-comments-win32-ia32-msvc": "0.0.2", | ||
"solidity-comments-darwin-x64": "0.0.2", | ||
"solidity-comments-win32-x64-msvc": "0.0.2", | ||
"solidity-comments-linux-x64-gnu": "0.0.2", | ||
"solidity-comments-linux-x64-musl": "0.0.2", | ||
"solidity-comments-freebsd-x64": "0.0.2" | ||
} | ||
} |
# `solidity-comments` | ||
`solidity-comments` is an N-API library built in Rust, which exposes a single function, which takes the contents of a Solidity source file and returns its imports and version pragmas. | ||
`solidity-comments` is an N-API library built in Rust, which exposes a single function, which takes the contents of a Solidity source file and returns its comments. | ||
@@ -15,30 +15,14 @@ ## Installation | ||
export interface AnalysisResult { | ||
versionPragmas: Array<string>; | ||
imports: Array<string>; | ||
comments: Array<Comment>; | ||
} | ||
export interface Comment { | ||
start: number | ||
end: number | ||
text: string | ||
} | ||
export function analyze(input: string): AnalysisResult; | ||
``` | ||
## Example | ||
```ts | ||
analyze(` | ||
pragma solidity ^0.8.0; | ||
import "./file.sol"; | ||
`); | ||
// { versionPragmas: [ '^0.8.0' ], imports: [ './file.sol' ] } | ||
``` | ||
## Goals | ||
This library has two different goals: | ||
1. Being fast | ||
2. Being error-tolerant | ||
Both are achieved by not parsing the Solidity source but just tokenizing it instead. This allows us to create a simple state machine that only recognizes imports and pragmas, ignoring everything else, and recovering from malformed tokens or expressions. | ||
## Browser support | ||
@@ -48,8 +32,2 @@ | ||
## Testing | ||
This project has some JavaScript unit tests in `__test__`, and it's also tested using the entire [`smart-contract-sanctuary`](https://github.com/tintinweb/smart-contract-sanctuary). | ||
You can find the scripts to test with the sanctuary in `test-with-sanctuary/`. | ||
## Regenerating `index.js` and `index.d.ts` | ||
@@ -56,0 +34,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11467
36