legacyver 3.1.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/bin/legacyver.js +1 -1
  2. package/legacyver-docs/auth.md +71 -0
  3. package/legacyver-docs/hash.md +37 -0
  4. package/package.json +3 -2
  5. package/src/api/auth.js +32 -45
  6. package/src/cli/commands/analyze.js +20 -1
  7. package/src/cli/commands/init.js +34 -4
  8. package/src/cli/commands/login.js +1 -1
  9. package/src/cli/commands/providers.js +20 -23
  10. package/src/cli/ui.js +19 -9
  11. package/src/db/config.js +39 -14
  12. package/src/db/index.js +69 -88
  13. package/src/llm/providers/groq.js +4 -2
  14. package/src/llm/validator.js +2 -2
  15. package/src/utils/config.js +1 -1
  16. package/legacyver-docs/bin/legacyver.md +0 -107
  17. package/legacyver-docs/src/api/auth.md +0 -47
  18. package/legacyver-docs/src/cache/hash.md +0 -24
  19. package/legacyver-docs/src/cache/index.md +0 -112
  20. package/legacyver-docs/src/cli/commands/analyze.md +0 -58
  21. package/legacyver-docs/src/cli/commands/cache.md +0 -21
  22. package/legacyver-docs/src/cli/commands/init.md +0 -42
  23. package/legacyver-docs/src/cli/commands/login.md +0 -70
  24. package/legacyver-docs/src/cli/commands/logout.md +0 -26
  25. package/legacyver-docs/src/cli/commands/providers.md +0 -23
  26. package/legacyver-docs/src/cli/commands/push.md +0 -48
  27. package/legacyver-docs/src/cli/commands/version.md +0 -26
  28. package/legacyver-docs/src/cli/ui.md +0 -112
  29. package/legacyver-docs/src/crawler/filters.md +0 -54
  30. package/legacyver-docs/src/crawler/index.md +0 -54
  31. package/legacyver-docs/src/crawler/manifest.md +0 -22
  32. package/legacyver-docs/src/crawler/walk.md +0 -29
  33. package/legacyver-docs/src/db/config.md +0 -13
  34. package/legacyver-docs/src/db/index.md +0 -86
  35. package/legacyver-docs/src/llm/chunker.md +0 -28
  36. package/legacyver-docs/src/llm/cost-estimator.md +0 -62
  37. package/legacyver-docs/src/llm/free-model.md +0 -40
  38. package/legacyver-docs/src/llm/index.md +0 -29
  39. package/legacyver-docs/src/llm/prompts.md +0 -150
  40. package/legacyver-docs/src/llm/providers/gemini.md +0 -51
  41. package/legacyver-docs/src/llm/providers/groq.md +0 -76
  42. package/legacyver-docs/src/llm/providers/kimi.md +0 -48
  43. package/legacyver-docs/src/llm/providers/ollama.md +0 -50
  44. package/legacyver-docs/src/llm/providers/openrouter.md +0 -55
  45. package/legacyver-docs/src/llm/queue.md +0 -41
  46. package/legacyver-docs/src/llm/re-prompter.md +0 -33
  47. package/legacyver-docs/src/llm/validator.md +0 -34
  48. package/legacyver-docs/src/parser/ast/generic.md +0 -34
  49. package/legacyver-docs/src/parser/ast/go.md +0 -59
  50. package/legacyver-docs/src/parser/ast/java.md +0 -58
  51. package/legacyver-docs/src/parser/ast/javascript.md +0 -71
  52. package/legacyver-docs/src/parser/ast/laravel/blade.md +0 -45
  53. package/legacyver-docs/src/parser/ast/laravel/classifier.md +0 -29
  54. package/legacyver-docs/src/parser/ast/laravel/controller.md +0 -57
  55. package/legacyver-docs/src/parser/ast/laravel/index.md +0 -27
  56. package/legacyver-docs/src/parser/ast/laravel/model.md +0 -34
  57. package/legacyver-docs/src/parser/ast/laravel/provider.md +0 -31
  58. package/legacyver-docs/src/parser/ast/laravel/routes.md +0 -31
  59. package/legacyver-docs/src/parser/ast/php.md +0 -127
  60. package/legacyver-docs/src/parser/ast/python.md +0 -62
  61. package/legacyver-docs/src/parser/ast/typescript.md +0 -22
  62. package/legacyver-docs/src/parser/body-extractor.md +0 -34
  63. package/legacyver-docs/src/parser/call-graph.md +0 -45
  64. package/legacyver-docs/src/parser/complexity-scorer.md +0 -25
  65. package/legacyver-docs/src/parser/index.md +0 -59
  66. package/legacyver-docs/src/parser/pattern-detector.md +0 -28
  67. package/legacyver-docs/src/parser/pkg-builder.md +0 -34
  68. package/legacyver-docs/src/renderer/html.md +0 -36
  69. package/legacyver-docs/src/renderer/index.md +0 -26
  70. package/legacyver-docs/src/renderer/json.md +0 -25
  71. package/legacyver-docs/src/renderer/markdown.md +0 -77
  72. package/legacyver-docs/src/utils/config.md +0 -62
  73. package/legacyver-docs/src/utils/errors.md +0 -53
  74. package/legacyver-docs/src/utils/logger.md +0 -48
@@ -1,59 +0,0 @@
1
- ## Overview
2
- The `parse` function is a parser for Go source code, responsible for extracting and analyzing the structure of the code.
3
-
4
- ## Functions
5
- ### parse
6
- #### Description
7
- Parses Go source code and extracts functions, classes, imports, and exports.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | `sourceText` | string | The source code to parse. |
13
- | `relativePath` | string | The relative path of the source code. |
14
-
15
- #### Return Value
16
- An object containing the parsed data, including functions, classes, imports, exports, and other metadata.
17
-
18
- ### findBlockEnd
19
- #### Description
20
- Finds the end of a block in the source code, starting from a given index.
21
-
22
- #### Parameters
23
- | Name | Type | Description |
24
- | --- | --- | --- |
25
- | `lines` | array | The source code split into lines. |
26
- | `startIdx` | number | The starting index to search from. |
27
-
28
- #### Return Value
29
- The index of the end of the block, or the length of the `lines` array if no block is found.
30
-
31
- ### extractCalls
32
- #### Description
33
- Extracts function calls from a given source code snippet.
34
-
35
- #### Parameters
36
- | Name | Type | Description |
37
- | --- | --- | --- |
38
- | `body` | string | The source code snippet to extract calls from. |
39
-
40
- #### Return Value
41
- An array of function call names.
42
-
43
- ## Dependencies
44
- * `../complexity-scorer: scoreComplexity`
45
- * `../body-extractor: extractBodySnippet`
46
-
47
- ## Usage Example
48
- ```javascript
49
- const sourceText = `
50
- func main() {
51
- fmt.Println("Hello, World!")
52
- }
53
- `;
54
-
55
- const relativePath = './main.go';
56
- const parsedData = parse(sourceText, relativePath);
57
- console.log(parsedData);
58
- ```
59
- Note: This example is not directly visible in the code, but it can be inferred from the `parse` function's usage.
@@ -1,58 +0,0 @@
1
- ## Overview
2
- The `parse` function is a parser for Java source code, responsible for extracting and analyzing the structure of a Java file. It takes two parameters: `sourceText` and `relativePath`, and returns an object containing information about the file's structure, including functions, classes, imports, and exports.
3
-
4
- ## Functions
5
- ### parse
6
- | Parameter | Type | Description |
7
- | --- | --- | --- |
8
- | sourceText | string | The source code of the Java file to parse |
9
- | relativePath | string | The relative path of the Java file |
10
-
11
- | Return Value | Type | Description |
12
- | --- | --- | --- |
13
- | object | | An object containing information about the file's structure |
14
-
15
- The `parse` function iterates over each line of the source code, using regular expressions to identify imports, classes, and methods. It extracts information about each method, including its name, parameters, return type, and body.
16
-
17
- ### findBlockEnd
18
- | Parameter | Type | Description |
19
- | --- | --- | --- |
20
- | lines | array | The array of lines to search for the block end |
21
- | startIdx | number | The starting index to search from |
22
-
23
- | Return Value | Type | Description |
24
- | --- | --- | --- |
25
- | number | | The index of the line where the block ends |
26
-
27
- The `findBlockEnd` function finds the index of the line where a block ends by counting the number of opening and closing curly brackets.
28
-
29
- ### extractCalls
30
- | Parameter | Type | Description |
31
- | --- | --- | --- |
32
- | body | string | The body of a method or function |
33
-
34
- | Return Value | Type | Description |
35
- | --- | --- | --- |
36
- | array | | An array of function or method names called in the body |
37
-
38
- The `extractCalls` function uses a regular expression to find all function or method calls in the body of a method or function, and returns an array of the names of these calls.
39
-
40
- ## Dependencies
41
- * `../complexity-scorer: scoreComplexity`
42
- * `../body-extractor: extractBodySnippet`
43
-
44
- ## Usage Example
45
- ```javascript
46
- const sourceText = `
47
- public class MyClass {
48
- public void myMethod() {
49
- System.out.println("Hello, World!");
50
- }
51
- }
52
- `;
53
-
54
- const relativePath = 'path/to/MyClass.java';
55
- const result = parse(sourceText, relativePath);
56
- console.log(result);
57
- ```
58
- This example shows how to use the `parse` function to parse a Java file and extract its structure. The `relativePath` parameter is used to specify the relative path of the file, and the `sourceText` parameter is the source code of the file. The `result` object contains information about the file's structure, including the functions, classes, imports, and exports.
@@ -1,71 +0,0 @@
1
- ## Overview
2
- This is a JavaScript AST parser that uses regex and heuristics to parse JavaScript code. It is designed to be a robust implementation, as it is not using the web-tree-sitter WASM parser.
3
-
4
- ## Functions
5
-
6
- ### parse
7
- #### Description
8
- Parses a JavaScript source code string and extracts information about functions, classes, imports, and exports.
9
-
10
- #### Parameters
11
- | Name | Type | Description |
12
- | --- | --- | --- |
13
- | sourceText | string | The source code to parse. |
14
- | relativePath | string | The relative path of the source code. |
15
-
16
- #### Return Value
17
- An object containing the parsed information.
18
-
19
- ### parseParams
20
- #### Description
21
- Parses a string of comma-separated parameter names and returns an array of objects with the parameter name and type.
22
-
23
- #### Parameters
24
- | Name | Type | Description |
25
- | --- | --- | --- |
26
- | paramsStr | string | The string of comma-separated parameter names. |
27
-
28
- #### Return Value
29
- An array of objects with the parameter name and type.
30
-
31
- ### findBlockEnd
32
- #### Description
33
- Finds the end of a block in a given array of lines.
34
-
35
- #### Parameters
36
- | Name | Type | Description |
37
- | --- | --- | --- |
38
- | lines | array | The array of lines to search. |
39
- | startIdx | number | The starting index to search from. |
40
-
41
- #### Return Value
42
- The index of the end of the block.
43
-
44
- ### extractCalls
45
- #### Description
46
- Extracts a list of function calls from a given string.
47
-
48
- #### Parameters
49
- | Name | Type | Description |
50
- | --- | --- | --- |
51
- | body | string | The string to extract calls from. |
52
-
53
- #### Return Value
54
- An array of function calls.
55
-
56
- ## Dependencies
57
- * `../complexity-scorer: scoreComplexity`
58
- * `../body-extractor: extractBodySnippet`
59
- * `y: x`
60
-
61
- ## Usage Example
62
- ```javascript
63
- const sourceText = `
64
- function foo() {
65
- console.log('Hello World!');
66
- }
67
- `;
68
- const relativePath = './path/to/file.js';
69
- const parsed = parse(sourceText, relativePath);
70
- console.log(parsed);
71
- ```
@@ -1,45 +0,0 @@
1
- ## Overview
2
- The `extract` function is used to extract Blade template facts from a given source text.
3
-
4
- ## Functions
5
- ### extract
6
- #### Description
7
- Extracts Blade template facts from a source text.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | sourceText | string | The source text to extract facts from. |
13
- | relativePath | string | The relative path of the source text. |
14
-
15
- #### Return Value
16
- An object containing various metadata about the source text, including:
17
- * `relativePath`: The relative path of the source text.
18
- * `language`: The language of the source text, which is always 'php'.
19
- * `fileType`: The file type of the source text, which is always 'blade'.
20
- * `linesOfCode`: The number of lines of code in the source text.
21
- * `functions`: An empty array, as this function does not extract function information.
22
- * `classes`: An empty array, as this function does not extract class information.
23
- * `imports`: An empty array, as this function does not extract import information.
24
- * `exports`: An array containing the `extract` function itself.
25
- * `callsTo`: An empty array, as this function does not call any other functions.
26
- * `calledBy`: An empty array, as this function is not called by any other functions.
27
- * `hash`: Null, as this function does not generate a hash.
28
- * `parserType`: The type of parser used, which is always 'blade'.
29
- * `laravelContext`: An object containing various metadata about the source text in the context of Laravel, including:
30
- + `type`: The type of the source text, which is always 'blade'.
31
- + `directives`: An array of directives found in the source text.
32
- + `includedViews`: An array of included views found in the source text.
33
- + `outputExpressions`: An array of output expressions found in the source text.
34
-
35
- ## Dependencies
36
- * `module.exports`
37
-
38
- ## Usage Example
39
- The `extract` function can be used as follows:
40
- ```javascript
41
- const sourceText = '... Blade template code ...';
42
- const relativePath = 'path/to/template.blade.php';
43
- const extractedFacts = extract(sourceText, relativePath);
44
- console.log(extractedFacts);
45
- ```
@@ -1,29 +0,0 @@
1
- ## Overview
2
- This module exports a function `classify` that takes a relative file path and the source text of a Laravel PHP file, and returns its role in the application.
3
-
4
- ## Functions
5
- ### classify
6
- Classify a Laravel PHP file into its role.
7
-
8
- | Parameter | Type | Description |
9
- | --- | --- | --- |
10
- | relativePath | string | The relative path to the file. |
11
- | sourceText | string | The source text of the file. |
12
-
13
- Returns:
14
- | Type | Description |
15
- | --- | --- |
16
- | string | The role of the file, one of: 'controller', 'model', 'middleware', 'provider', 'route_file', 'blade', 'request', or 'other'. |
17
-
18
- ## Dependencies
19
- * `path`: The Node.js `path` module.
20
-
21
- ## Usage Example
22
- The following example demonstrates how to use the `classify` function:
23
- ```javascript
24
- const classifier = require('./classifier');
25
- const relativePath = 'app/Http/Controllers/UserController.php';
26
- const sourceText = '...'; // source text of the file
27
- const role = classifier.classify(relativePath, sourceText);
28
- console.log(role); // Output: 'controller'
29
- ```
@@ -1,57 +0,0 @@
1
- ## Overview
2
- The `extract` function is used to extract Laravel Controller specifics from a given `sourceText` and `fileFacts`. It returns an object containing information about the controller's type, route actions, injected services, and form requests.
3
-
4
- ## Functions
5
- ### extract
6
- | Parameter | Type | Description |
7
- | --- | --- | --- |
8
- | sourceText | string | The source code of the file to extract information from. |
9
- | fileFacts | object | An object containing information about the file, including its functions. |
10
-
11
- | Return Value | Type | Description |
12
- | --- | --- | --- |
13
- | laravelContext | object | An object containing information about the Laravel Controller, including its type, route actions, injected services, and form requests. |
14
-
15
- ## Dependencies
16
- * `match`
17
- * `split`
18
- * `trim`
19
- * `push`
20
- * `methods`
21
- * `test`
22
-
23
- ## Usage Example
24
- The function can be used to extract information from a Laravel Controller file, for example:
25
- ```javascript
26
- const sourceText = `
27
- public function __construct($service1, $service2) {}
28
- public function index(Request $request) {}
29
- public function store(Request $request) {}
30
- `;
31
-
32
- const fileFacts = {
33
- functions: [
34
- {
35
- name: 'index',
36
- params: [{ type: 'Request' }],
37
- isExported: true
38
- },
39
- {
40
- name: 'store',
41
- params: [{ type: 'Request' }],
42
- isExported: true
43
- }
44
- ]
45
- };
46
-
47
- const laravelContext = extract(sourceText, fileFacts);
48
- console.log(laravelContext);
49
- // Output:
50
- // {
51
- // type: 'controller',
52
- // routeActions: ['index', 'store'],
53
- // injectedServices: [{ type: 'service1', name: '$service1' }, { type: 'service2', name: '$service2' }],
54
- // formRequests: [{ method: 'index', requestClass: 'Request' }, { method: 'store', requestClass: 'Request' }]
55
- // }
56
- ```
57
- Note: The usage example is based on the patterns detected in the code and may not cover all possible scenarios.
@@ -1,27 +0,0 @@
1
- ## Overview
2
- The `enrich` function enriches a FileFacts object with Laravel-specific context.
3
-
4
- ## Functions
5
- ### enrich
6
- #### Description
7
- Enrich a FileFacts object with Laravel-specific context.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | sourceText | string | The source code of the file. |
13
- | fileFacts | Object | The base FileFacts object from the PHP parser. |
14
-
15
- #### Return Value
16
- An enriched FileFacts object with Laravel-specific context.
17
-
18
- ## Dependencies
19
- * `./classifier: classify`
20
- * `./controller: extract: extractController`
21
- * `./model: extract: extractModel`
22
- * `./routes: extract: extractRoutes`
23
- * `./blade: extract: extractBlade`
24
- * `./provider: extract: extractProvider`
25
-
26
- ## Usage Example
27
- No clear pattern is visible in the code.
@@ -1,34 +0,0 @@
1
- ## Overview
2
- The `extract` function is used to extract Laravel Model specifics from a given source text and FileFacts.
3
-
4
- ## Functions
5
- ### extract
6
- #### Description
7
- Extracts Laravel Model specifics from a given source text and FileFacts.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | sourceText | string | The source text to extract from. |
13
- | fileFacts | object | An object containing information about the file, including its functions. |
14
-
15
- #### Return Value
16
- An object containing the extracted Laravel Model specifics, including the table name, fillable fields, guarded fields, and relationships.
17
-
18
- ## Dependencies
19
- * `match`
20
- * `split`
21
- * `map`
22
- * `trim`
23
- * `replace`
24
- * `filter`
25
- * `RegExp`
26
- * `join`
27
- * `slice`
28
- * `max`
29
- * `exec`
30
- * `pop`
31
- * `push`
32
-
33
- ## Usage Example
34
- Based on the code, it appears that the `extract` function is designed to be used in a loop, where it iterates over the functions in the `fileFacts` object and extracts the relevant information from the `sourceText`. However, without a clear pattern or example usage, it's difficult to provide a concrete usage example.
@@ -1,31 +0,0 @@
1
- ## Overview
2
- The `extract` function is used to extract Service Provider specifics from a given source text and file facts.
3
-
4
- ## Functions
5
- ### extract
6
- #### Description
7
- Extracts Service Provider specifics from a given source text and file facts.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | sourceText | string | The source text to extract from. |
13
- | fileFacts | object | An object containing file facts. |
14
-
15
- #### Return Value
16
- An object containing the extracted Service Provider specifics.
17
-
18
- #### Body Logic
19
- The function iterates through the `register()` and `boot()` method bodies in the file facts to extract relevant information. For the `register()` method, it uses a regular expression to find bindings and adds them to the `registerBindings` array. For the `boot()` method, it simply adds a string indicating the presence of the `boot()` method to the `bootActions` array.
20
-
21
- ## Dependencies
22
- * `find` function from `fileFacts.functions`
23
- * `exec` function from regular expression
24
- * `push` function from `laravelContext.registerBindings` and `laravelContext.bootActions`
25
-
26
- ## Usage Example
27
- The code does not provide a clear usage example, but the function can be used as follows:
28
- ```javascript
29
- const laravelContext = extract(sourceText, fileFacts);
30
- console.log(laravelContext);
31
- ```
@@ -1,31 +0,0 @@
1
- ## Overview
2
- This module exports a function `extract` that parses Laravel route files and extracts route definitions.
3
-
4
- ## Functions
5
- ### extract
6
- Extracts route definitions from a given source text.
7
-
8
- | Parameter | Type | Description |
9
- | --- | --- | --- |
10
- | sourceText | string | The source text to extract route definitions from |
11
-
12
- | Return Value | Type | Description |
13
- | --- | --- | --- |
14
- | object | { type: 'route_file', routes } | An object containing the extracted route definitions |
15
-
16
- ## Dependencies
17
- * `module.exports`
18
-
19
- ## Usage Example
20
- ```javascript
21
- const routes = extract('Route::get('users', [UserController::class, 'index'])->middleware('auth')->name('users.index');');
22
- console.log(routes);
23
- ```
24
- This example extracts a single route definition from the given source text and logs the result to the console. The extracted route definition is an object with the following properties:
25
-
26
- * `method`: The HTTP method of the route (e.g. "get")
27
- * `uri`: The URI of the route (e.g. "users")
28
- * `controller`: The controller class of the route (e.g. "UserController")
29
- * `action`: The action method of the route (e.g. "index")
30
- * `middleware`: The middleware applied to the route (e.g. "auth")
31
- * `name`: The name of the route (e.g. "users.index")
@@ -1,127 +0,0 @@
1
- ## Overview
2
- This is a PHP Abstract Syntax Tree (AST) parser that takes source code as input and returns an object containing the parsed data.
3
-
4
- ## Functions
5
- ### parse
6
- #### Description
7
- Parses the source code and returns an object containing the parsed data.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | sourceText | string | The source code to parse. |
13
- | relativePath | string | The relative path of the source code. |
14
-
15
- #### Return Value
16
- An object containing the parsed data.
17
-
18
- #### Calls
19
- | Function | Description |
20
- | --- | --- |
21
- | parsePhpParams | Parses PHP function parameters. |
22
- | findBlockEnd | Finds the end of a block in the source code. |
23
- | extractCalls | Extracts function calls from the source code. |
24
- | scoreComplexity | Scores the complexity of the source code. |
25
- | extractBodySnippet | Extracts a snippet of the source code. |
26
-
27
- ### publicFns
28
- #### Description
29
- Returns an array of public function names.
30
-
31
- #### Parameters
32
- | Name | Type | Description |
33
- | --- | --- | --- |
34
- | functions | array | The array of functions to filter. |
35
-
36
- #### Return Value
37
- An array of public function names.
38
-
39
- #### Calls
40
- | Function | Description |
41
- | --- | --- |
42
- | filter | Filters the array of functions. |
43
- | map | Maps the array of functions to an array of function names. |
44
-
45
- ### parsePhpParams
46
- #### Description
47
- Parses PHP function parameters.
48
-
49
- #### Parameters
50
- | Name | Type | Description |
51
- | --- | --- | --- |
52
- | paramsStr | string | The string of parameters to parse. |
53
-
54
- #### Return Value
55
- An array of parsed parameters.
56
-
57
- #### Calls
58
- | Function | Description |
59
- | --- | --- |
60
- | trim | Trims the string of parameters. |
61
- | split | Splits the string of parameters into an array. |
62
- | map | Maps the array of parameters to an array of parsed parameters. |
63
- | match | Matches the string of parameters against a regular expression. |
64
- | filter | Filters the array of parsed parameters. |
65
-
66
- ### findBlockEnd
67
- #### Description
68
- Finds the end of a block in the source code.
69
-
70
- #### Parameters
71
- | Name | Type | Description |
72
- | --- | --- | --- |
73
- | lines | array | The array of lines in the source code. |
74
- | startIdx | number | The index of the start of the block. |
75
-
76
- #### Return Value
77
- The index of the end of the block.
78
-
79
- #### Calls
80
- | Function | Description |
81
- | --- | --- |
82
- | findBlockEnd | Recursively finds the end of the block. |
83
-
84
- ### extractCalls
85
- #### Description
86
- Extracts function calls from the source code.
87
-
88
- #### Parameters
89
- | Name | Type | Description |
90
- | --- | --- | --- |
91
- | body | string | The body of the function to extract calls from. |
92
-
93
- #### Return Value
94
- An array of extracted function calls.
95
-
96
- #### Calls
97
- | Function | Description |
98
- | --- | --- |
99
- | matchAll | Matches the body of the function against a regular expression. |
100
- | Set | Creates a set of unique function calls. |
101
- | has | Checks if a function call is in the set. |
102
- | add | Adds a function call to the set. |
103
- | filter | Filters the array of function calls. |
104
-
105
- ## Dependencies
106
- * `../complexity-scorer: scoreComplexity`
107
- * `../body-extractor: extractBodySnippet`
108
-
109
- ## Usage Example
110
- ```javascript
111
- const sourceCode = `
112
- namespace App\\Http\\Controllers;
113
-
114
- use Illuminate\\Support\\Facades\\Auth;
115
-
116
- class UserController extends Controller
117
- {
118
- public function index()
119
- {
120
- // ...
121
- }
122
- }
123
- `;
124
-
125
- const parsedData = parse(sourceCode, 'path/to/source/code');
126
- console.log(parsedData);
127
- ```
@@ -1,62 +0,0 @@
1
- ## Overview
2
- The `parse` function is a parser for Python source code, responsible for extracting and analyzing the structure of a Python file. It takes two parameters: `sourceText` and `relativePath`, and returns an object containing information about the file's structure, including functions, classes, imports, and exports.
3
-
4
- ## Functions
5
-
6
- ### parse
7
- #### Description
8
- Parses a Python source code file and extracts its structure.
9
-
10
- #### Parameters
11
- | Name | Type | Description |
12
- | --- | --- | --- |
13
- | sourceText | string | The source code of the Python file. |
14
- | relativePath | string | The relative path of the Python file. |
15
-
16
- #### Return Value
17
- An object containing information about the file's structure, including functions, classes, imports, and exports.
18
-
19
- ### findBlockEnd
20
- #### Description
21
- Finds the end of a block in a list of lines.
22
-
23
- #### Parameters
24
- | Name | Type | Description |
25
- | --- | --- | --- |
26
- | lines | array | The list of lines to search. |
27
- | startIdx | number | The index to start searching from. |
28
-
29
- #### Return Value
30
- The index of the end of the block.
31
-
32
- ### extractCalls
33
- #### Description
34
- Extracts function calls from a string.
35
-
36
- #### Parameters
37
- | Name | Type | Description |
38
- | --- | --- | --- |
39
- | body | string | The string to extract calls from. |
40
-
41
- #### Return Value
42
- An array of function calls.
43
-
44
- ## Dependencies
45
- * `../complexity-scorer: scoreComplexity`
46
- * `../body-extractor: extractBodySnippet`
47
-
48
- ## Usage Example
49
- ```javascript
50
- const sourceText = `
51
- def add(a, b):
52
- return a + b
53
-
54
- def multiply(a, b):
55
- return a * b
56
- `;
57
-
58
- const relativePath = 'example.py';
59
- const result = parse(sourceText, relativePath);
60
- console.log(result);
61
- ```
62
- Note: The usage example is not directly visible in the code, but it can be inferred from the function signature and the structure of the `parse` function.
@@ -1,22 +0,0 @@
1
- ## Overview
2
- This module provides a TypeScript parser that extends the JavaScript parser, handling type annotations.
3
-
4
- ## Functions
5
- ### parse
6
- #### Description
7
- Parses a TypeScript source text and returns the parsed result with the language set to 'typescript'.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | sourceText | string | The source text to parse. |
13
- | relativePath | string | The relative path of the source file. |
14
-
15
- #### Return Value
16
- The parsed result with the language set to 'typescript'.
17
-
18
- ## Dependencies
19
- * `./javascript: parse: parseJS` - The JavaScript parser function.
20
-
21
- ## Usage Example
22
- None. The code does not provide a clear usage example.