@g3nomaly/analyze 0.1.0 → 0.1.2

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 (97) hide show
  1. package/README.md +10 -5
  2. package/dist/api/bundle-builder.d.ts +29 -10
  3. package/dist/api/bundle-cache.d.ts +7 -4
  4. package/dist/api/bundle-loader.d.ts +10 -3
  5. package/dist/api/create-docs.d.ts +33 -14
  6. package/dist/api/embedding.d.ts +16 -7
  7. package/dist/api/errors.d.ts +13 -6
  8. package/dist/api/list.d.ts +20 -20
  9. package/dist/api/options.d.ts +18 -22
  10. package/dist/api/refs.d.ts +24 -21
  11. package/dist/api/scan.d.ts +24 -12
  12. package/dist/api/search.d.ts +27 -21
  13. package/dist/api/services.d.ts +9 -1
  14. package/dist/api/show.d.ts +15 -19
  15. package/dist/api/site-reader.d.ts +11 -3
  16. package/dist/api/site-writer.d.ts +30 -7
  17. package/dist/api/source.d.ts +23 -12
  18. package/dist/api/target.d.ts +2 -0
  19. package/dist/cli.js +670 -238
  20. package/dist/embeddings/index-builder.d.ts +3 -1
  21. package/dist/embeddings/model.d.ts +26 -13
  22. package/dist/embeddings/searcher.d.ts +24 -7
  23. package/dist/embeddings/vectors.d.ts +3 -1
  24. package/dist/embeddings/words.d.ts +7 -3
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +647 -229
  27. package/dist/model/index.d.ts +416 -188
  28. package/dist/model/registry.d.ts +204 -11
  29. package/dist/query/graph.d.ts +83 -26
  30. package/dist/query/name-search.d.ts +39 -21
  31. package/dist/query/semantic.d.ts +11 -3
  32. package/dist/retrieval/describe.d.ts +11 -4
  33. package/dist/retrieval/filter.d.ts +27 -8
  34. package/dist/retrieval/index.d.ts +1 -1
  35. package/dist/retrieval/markdown.d.ts +3 -2
  36. package/dist/retrieval/report.d.ts +147 -70
  37. package/dist/retrieval/resolve.d.ts +11 -7
  38. package/dist/retrieval/retriever.d.ts +34 -23
  39. package/dist/retrieval/summary.d.ts +6 -3
  40. package/dist/scanner/code/doc/clean.d.ts +31 -5
  41. package/dist/scanner/code/doc/index.d.ts +7 -1
  42. package/dist/scanner/code/doc/markdown.d.ts +6 -1
  43. package/dist/scanner/code/doc/python.d.ts +6 -1
  44. package/dist/scanner/code/doc/tagged.d.ts +13 -4
  45. package/dist/scanner/code/doc/types.d.ts +16 -5
  46. package/dist/scanner/code/doc/xml.d.ts +6 -1
  47. package/dist/scanner/code/example.d.ts +31 -10
  48. package/dist/scanner/code/extract.d.ts +56 -21
  49. package/dist/scanner/code/grammar.d.ts +20 -5
  50. package/dist/scanner/code/language.d.ts +100 -66
  51. package/dist/scanner/code/languages/index.d.ts +21 -7
  52. package/dist/scanner/code/languages/shared.d.ts +23 -4
  53. package/dist/scanner/code/planner.d.ts +50 -14
  54. package/dist/scanner/code/symbols.d.ts +86 -20
  55. package/dist/scanner/code/types.d.ts +48 -15
  56. package/dist/scanner/config.d.ts +42 -0
  57. package/dist/scanner/content.d.ts +49 -14
  58. package/dist/scanner/decisions/parse.d.ts +20 -11
  59. package/dist/scanner/decisions/planner.d.ts +20 -8
  60. package/dist/scanner/docs.d.ts +36 -19
  61. package/dist/scanner/files.d.ts +44 -19
  62. package/dist/scanner/glossary/parse.d.ts +17 -7
  63. package/dist/scanner/glossary/planner.d.ts +15 -8
  64. package/dist/scanner/glossary/terms.d.ts +57 -27
  65. package/dist/scanner/graph/builder.d.ts +80 -21
  66. package/dist/scanner/highlight.d.ts +32 -9
  67. package/dist/scanner/ignore.d.ts +25 -0
  68. package/dist/scanner/index.d.ts +5 -2
  69. package/dist/scanner/markdown/frontmatter.d.ts +18 -3
  70. package/dist/scanner/markdown/links.d.ts +19 -9
  71. package/dist/scanner/markdown/outline.d.ts +13 -5
  72. package/dist/scanner/markdown/renderer.d.ts +32 -13
  73. package/dist/scanner/openapi/planner.d.ts +20 -8
  74. package/dist/scanner/packages.d.ts +28 -0
  75. package/dist/scanner/reporter.d.ts +5 -2
  76. package/dist/scanner/scanner.d.ts +21 -7
  77. package/dist/scanner/schema/definitions.d.ts +18 -8
  78. package/dist/scanner/schema/describe.d.ts +44 -18
  79. package/dist/scanner/schema/planner.d.ts +6 -3
  80. package/dist/scanner/schema/registry.d.ts +23 -16
  81. package/dist/scanner/skills/classify.d.ts +2 -1
  82. package/dist/scanner/skills/layout.d.ts +27 -9
  83. package/dist/scanner/skills/planner.d.ts +19 -4
  84. package/dist/scanner/specs.d.ts +8 -2
  85. package/dist/scanner/sql/catalog.d.ts +21 -7
  86. package/dist/scanner/sql/cursor.d.ts +9 -4
  87. package/dist/scanner/sql/database.d.ts +6 -3
  88. package/dist/scanner/sql/parse.d.ts +62 -27
  89. package/dist/scanner/sql/planner.d.ts +6 -2
  90. package/dist/scanner/sql/query.d.ts +34 -21
  91. package/dist/scanner/sql/registry.d.ts +24 -10
  92. package/dist/scanner/sql/source.d.ts +1 -0
  93. package/dist/scanner/sql/statements.d.ts +9 -3
  94. package/dist/scanner/sql/tokens.d.ts +25 -12
  95. package/dist/scanner/tasks/layout.d.ts +22 -10
  96. package/dist/scanner/tasks/planner.d.ts +64 -9
  97. package/package.json +2 -2
@@ -8,62 +8,72 @@ import { type Resolution } from './resolve';
8
8
  export declare const SEARCH_MODES: readonly ['both', 'name', 'meaning'];
9
9
  /** How a search matches: `name` by the words of a name or a description, `meaning` by the embedding model, `both` by words first and then by meaning. */
10
10
  export type SearchMode = (typeof SEARCH_MODES)[number];
11
- /** How one search is run. */
11
+ /**
12
+ * @brief How one search is run.
13
+ *
14
+ * @property mode - How the search matches: `name`, `meaning` or `both`.
15
+ * @property limit - Most hits to return, both ways of matching together.
16
+ * @property filter - Narrows the nodes that count, such as to one kind.
17
+ */
12
18
  export interface SearchOptions {
13
19
  readonly mode: SearchMode;
14
- /** Most hits to return, both ways of matching together. */
15
20
  readonly limit: number;
16
21
  readonly filter: NodeFilter;
17
22
  }
18
- /** One result of a search. */
23
+ /**
24
+ * @brief One result of a search: a node summary with how it matched.
25
+ *
26
+ * @property match - `name`: every word of the query is in the name or the path of the node. `text`: at least one word is only in its description. `meaning`: the node is close to the query in the embedding model.
27
+ * @property score - From 0 to 1 for a match by meaning. `null` for a match by words.
28
+ */
19
29
  export interface SearchHit extends NodeSummary {
20
- /**
21
- * `name`: every word of the query is in the name or the path of the node.
22
- * `text`: at least one word is only in its description.
23
- * `meaning`: the node is close to the query in the embedding model.
24
- */
25
30
  readonly match: 'name' | 'text' | 'meaning';
26
- /** From 0 to 1 for a match by meaning. `null` for a match by words. */
27
31
  readonly score: number | null;
28
32
  }
29
33
  /**
30
- * Answers queries on one bundle: search, list, look up, describe.
34
+ * @brief Answers queries on one bundle: search, list, look up, describe.
31
35
  *
32
36
  * Holds the graph of the bundle and, after the first search by name, the
33
- * search index. `openRetriever` in `api/source.ts` creates one per request;
34
- * `listIn`, `searchIn`, `showIn` and `refsIn` in `api/` each call one method.
35
- * Every answer is plain data with ids, so a caller can print it, serialize it
36
- * or feed an id into the next call.
37
+ * search index. `openRetriever` in `api/source.ts` creates one per request from
38
+ * a `Graph`; `listIn`, `searchIn`, `showIn` and `refsIn` in `api/` each call one
39
+ * method. Create one with `new Retriever(new Graph(bundle))`. Every answer is
40
+ * plain data with ids, so a caller can print it, serialize it or feed an id into
41
+ * the next call.
37
42
  */
38
43
  export declare class Retriever {
39
44
  private readonly graph;
40
- /** Built on the first search by name. */
41
45
  private nameIndex;
42
- /** Creates a retriever for one bundle. */
46
+ /**
47
+ * @brief Creates a retriever for one bundle.
48
+ *
49
+ * @param graph - Graph of the bundle, from `new Graph(bundle)`.
50
+ */
43
51
  constructor(graph: Graph);
44
52
  /**
45
- * Names the embedding model that searches by meaning.
53
+ * @brief Names the embedding model that searches by meaning.
46
54
  *
47
55
  * @returns The name, or `null` when the bundle was built without embeddings.
48
56
  */
49
57
  get model(): string | null;
50
58
  /**
51
- * Finds pages and entries for a query. Matches by words come first, in the
59
+ * @brief Finds pages and entries for a query. Matches by words come first, in the
52
60
  * order the site lists them. Matches by meaning follow, best first.
53
61
  *
54
62
  * @param query - Words of a name, or a query in plain language.
63
+ * @param options - How the search runs: its mode, its limit and its filter.
55
64
  * @returns The hits, each once.
56
65
  */
57
66
  search(query: string, options: SearchOptions): SearchHit[];
58
67
  /**
59
- * Lists pages and entries in display order.
68
+ * @brief Lists pages and entries in display order.
60
69
  *
70
+ * @param filter - Narrows the nodes listed.
61
71
  * @param limit - Most rows to return. `null` returns all of them.
62
72
  * @returns One row per node.
63
73
  */
64
74
  list(filter: NodeFilter, limit: number | null): NodeSummary[];
65
75
  /**
66
- * Finds the node a caller means by an id, a file path or a name.
76
+ * @brief Finds the node a caller means by an id, a file path or a name.
67
77
  *
68
78
  * @param text - What the caller wrote.
69
79
  * @param filter - Narrows the nodes that count, to tell two nodes with one name apart.
@@ -71,23 +81,24 @@ export declare class Retriever {
71
81
  */
72
82
  resolve(text: string, filter: NodeFilter): Resolution;
73
83
  /**
74
- * Describes a node in one row.
84
+ * @brief Describes a node in one row.
75
85
  *
76
86
  * @param node - A page or an entry.
77
87
  * @returns Its id, kind, title, place on disk and summary.
78
88
  */
79
89
  summarize(node: NodeRef): NodeSummary;
80
90
  /**
81
- * Builds the full report of a node.
91
+ * @brief Builds the full report of a node.
82
92
  *
83
93
  * @param node - A page or an entry.
84
94
  * @returns Everything its page shows, with texts as markdown.
85
95
  */
86
96
  describe(node: NodeRef): NodeReport;
87
97
  /**
88
- * Lists the edges of a node.
98
+ * @brief Lists the edges of a node.
89
99
  *
90
100
  * @param node - A page or an entry.
101
+ * @param options - Which edges to keep, by direction and kind.
91
102
  * @returns What the node links to and what links to it.
92
103
  */
93
104
  references(node: NodeRef, options?: ReferenceOptions): References;
@@ -2,23 +2,26 @@ import { type NodeRef } from '../model';
2
2
  import { type Graph } from '../query';
3
3
  import type { NodeSummary } from './report';
4
4
  /**
5
- * Builds the id of a node: its route as the address of its page spells it,
5
+ * @brief Builds the id of a node: its route as the address of its page spells it,
6
6
  * without the leading `#/`.
7
7
  *
8
+ * @param graph - Graph the node belongs to.
8
9
  * @param node - The node. A parameter or a field has the id of its symbol.
9
10
  * @returns The id, such as `docs/glossary.md#term:lane`.
10
11
  */
11
12
  export declare function nodeId(graph: Graph, node: NodeRef): string;
12
13
  /**
13
- * Reduces an id, an address copied from the browser or an href of the site to an id.
14
+ * @brief Reduces an id, an address copied from the browser or an href of the site to an id.
14
15
  *
15
16
  * @param text - What the caller wrote, such as `#/code/src/app.ts#symbol:App.run` or `file:///site/docs.html#/code/src/app.ts`.
16
17
  * @returns The id without the file, `#/` or slashes around it, with percent escapes decoded.
17
18
  */
18
19
  export declare function normalizeId(text: string): string;
19
20
  /**
20
- * Describes a node in one row: what a search hit, a list row and a reference show.
21
+ * @brief Describes a node in one row: what a search hit, a list row and a reference show.
21
22
  *
23
+ * @param graph - Graph the node belongs to.
22
24
  * @param node - The node. A parameter or a field is not listed on its own, so pass its symbol.
25
+ * @returns The row of the node.
23
26
  */
24
27
  export declare function summarize(graph: Graph, node: NodeRef): NodeSummary;
@@ -1,10 +1,36 @@
1
- /** Strips comment markers from the text of consecutive comment nodes. */
1
+ /**
2
+ * @brief Strips comment markers from the text of consecutive comment nodes.
3
+ *
4
+ * @param comments - Raw text of each comment node, markers included.
5
+ * @returns The text of the comments, without the lines that configure tools such as `eslint-disable`.
6
+ */
2
7
  export declare function cleanComments(comments: readonly string[]): string;
3
- /** Content of a Python string literal used as a docstring, laid out like `inspect.cleandoc`. */
8
+ /**
9
+ * @brief Strips the quotes of a Python string literal and lays out its lines like `inspect.cleandoc`.
10
+ *
11
+ * @param literal - Source text of the string literal, quotes included.
12
+ * @returns The docstring text.
13
+ */
4
14
  export declare function cleanDocstring(literal: string): string;
5
- /** Text of the first fenced code block, or `null`. */
15
+ /**
16
+ * @brief Finds the text of the first fenced code block.
17
+ *
18
+ * @param markdown - Markdown to search.
19
+ * @returns The block without its fences, or `null` when there is none.
20
+ */
6
21
  export declare function firstFencedBlock(markdown: string): string | null;
7
- /** Applies `transform` to every line outside fenced code blocks. */
22
+ /**
23
+ * @brief Applies `transform` to every line outside fenced code blocks.
24
+ *
25
+ * @param markdown - Markdown to rewrite.
26
+ * @param transform - Maps one prose line to its new text.
27
+ * @returns The markdown with the prose lines transformed. Fenced lines stay as they are.
28
+ */
8
29
  export declare function mapProseLines(markdown: string, transform: (line: string) => string): string;
9
- /** Turns markdown headings into bold lines, so a description never outranks its symbol title. */
30
+ /**
31
+ * @brief Turns markdown headings into bold lines, so a description never outranks its symbol title.
32
+ *
33
+ * @param markdown - Markdown of a description.
34
+ * @returns The markdown with bold lines in place of its headings.
35
+ */
10
36
  export declare function demoteHeadings(markdown: string): string;
@@ -2,5 +2,11 @@ import type { DocStyle } from '../language';
2
2
  import { type ParsedDoc } from './types';
3
3
  export { cleanComments, cleanDocstring } from './clean';
4
4
  export type { ParsedDoc, ParsedTag, ParsedTagKind } from './types';
5
- /** Parses cleaned doc comment text in the given dialect. */
5
+ /**
6
+ * @brief Parses cleaned doc comment text in the given dialect.
7
+ *
8
+ * @param style - Dialect the comment is written in.
9
+ * @param text - Comment text without its markers, or `null` when the symbol has no comment.
10
+ * @returns The parsed doc, with its headings demoted. `EMPTY_DOC` for an empty or missing comment.
11
+ */
6
12
  export declare function parseDoc(style: DocStyle, text: string | null): ParsedDoc;
@@ -1,3 +1,8 @@
1
1
  import type { ParsedDoc } from './types';
2
- /** Parses a markdown doc comment (rustdoc, godoc). An "Examples" section becomes the example. */
2
+ /**
3
+ * @brief Parses a markdown doc comment (rustdoc, godoc). An "Examples" section becomes the example.
4
+ *
5
+ * @param text - Markdown doc comment text, cleaned of its markers.
6
+ * @returns The parsed doc.
7
+ */
3
8
  export declare function parseMarkdownDoc(text: string): ParsedDoc;
@@ -1,3 +1,8 @@
1
1
  import type { ParsedDoc } from './types';
2
- /** Parses a docstring in Google, NumPy or reST layout. */
2
+ /**
3
+ * @brief Parses a docstring in Google, NumPy or reST layout.
4
+ *
5
+ * @param text - Docstring content, cleaned of its quotes.
6
+ * @returns The description, the tags and the example.
7
+ */
3
8
  export declare function parsePythonDoc(text: string): ParsedDoc;
@@ -1,10 +1,19 @@
1
1
  import type { ParsedDoc } from './types';
2
- /** Dialect switches for `parseTagged`. */
2
+ /**
3
+ * @brief Dialect switches for `parseTagged`.
4
+ *
5
+ * @property titledExamples - YARD puts an example title on the `@example` line.
6
+ * @property braceLinks - YARD links to code with braces, as in `{Label.parse}` and `{#render}`.
7
+ */
3
8
  export interface TaggedOptions {
4
- /** YARD puts an example title on the `@example` line. */
5
9
  readonly titledExamples?: boolean;
6
- /** YARD links to code with braces, as in `{Label.parse}` and `{#render}`. */
7
10
  readonly braceLinks?: boolean;
8
11
  }
9
- /** Parses a doc comment written with `@tag` lines. */
12
+ /**
13
+ * @brief Parses a doc comment written with `@tag` lines.
14
+ *
15
+ * @param text - Doc comment text, cleaned of its markers.
16
+ * @param options - Dialect switches. Empty for the tagged dialect, `{ titledExamples, braceLinks }` for YARD.
17
+ * @returns The description, the tags and the example.
18
+ */
10
19
  export declare function parseTagged(text: string, options?: TaggedOptions): ParsedDoc;
@@ -1,21 +1,32 @@
1
1
  import type { DocTagKind } from '../../../model';
2
2
  /** Tag kinds a parser emits. The planner folds the first three into parameters, return value and fields. */
3
3
  export type ParsedTagKind = 'param' | 'returns' | 'field' | DocTagKind;
4
- /** One tag of a parsed doc comment, such as a parameter or a return value. */
4
+ /**
5
+ * @brief One tag of a parsed doc comment, such as a parameter or a return value.
6
+ *
7
+ * @property kind - Kind of the tag.
8
+ * @property label - Label of an `other` tag, as the comment writes it.
9
+ * @property name - Name of the parameter, field or exception the tag is about.
10
+ * @property type - Type as the comment writes it, when it writes one.
11
+ * @property text - Markdown.
12
+ */
5
13
  export interface ParsedTag {
6
14
  readonly kind: ParsedTagKind;
7
15
  readonly label?: string;
8
16
  readonly name?: string;
9
17
  readonly type?: string;
10
- /** Markdown. */
11
18
  readonly text: string;
12
19
  }
13
- /** A doc comment parsed into description, tags and example, the same for every dialect. */
20
+ /**
21
+ * @brief A doc comment parsed into description, tags and example, the same for every dialect.
22
+ *
23
+ * @property description - Markdown.
24
+ * @property tags - Tags in the order the comment writes them.
25
+ * @property example - Example source code, when the comment documents one.
26
+ */
14
27
  export interface ParsedDoc {
15
- /** Markdown. */
16
28
  readonly description: string;
17
29
  readonly tags: readonly ParsedTag[];
18
- /** Example source code, when the comment documents one. */
19
30
  readonly example: string | null;
20
31
  }
21
32
  /** Result for a symbol with no doc comment. */
@@ -1,3 +1,8 @@
1
1
  import type { ParsedDoc } from './types';
2
- /** Parses C# XML documentation comments. Text without XML elements is the description. */
2
+ /**
3
+ * @brief Parses C# XML documentation comments. Text without XML elements is the description.
4
+ *
5
+ * @param text - Doc comment text, with its XML elements.
6
+ * @returns The description, the tags and the example.
7
+ */
3
8
  export declare function parseXmlDoc(text: string): ParsedDoc;
@@ -1,36 +1,57 @@
1
1
  import { type SymbolKind } from '../../model';
2
2
  import type { CallStyle, ImportContext } from './language';
3
- /** What a generated example needs to know about the type a method belongs to. */
3
+ /**
4
+ * What a generated example needs to know about the type a method belongs to.
5
+ *
6
+ * @property kind - Kind of the owning type, such as `class` or `struct`.
7
+ * @property name - Name of the owning type.
8
+ * @property args - Constructor argument expressions of the type, receivers excluded.
9
+ * @property hasConstructor - True when the scanner found a constructor for the type.
10
+ * @property instantiable - False when the type is abstract or a singleton.
11
+ */
4
12
  export interface ParentTarget {
5
13
  readonly kind: SymbolKind;
6
14
  readonly name: string;
7
- /** Constructor arguments of the type. */
8
15
  readonly args: readonly string[];
9
16
  readonly hasConstructor: boolean;
10
17
  readonly instantiable: boolean;
11
18
  }
12
- /** The symbol a generated example calls or constructs, with what decides how. */
19
+ /**
20
+ * The symbol a generated example calls or constructs, with what decides how.
21
+ *
22
+ * @property kind - Kind of the symbol, such as `function`, `method`, `class` or `struct`.
23
+ * @property name - Name of the symbol.
24
+ * @property args - Argument expressions, receivers excluded.
25
+ * @property parent - Type or namespace the symbol belongs to, or `null` for a top-level symbol.
26
+ * @property isStatic - True when the symbol is called on its type rather than on an instance.
27
+ * @property isAsync - True when the call must be awaited.
28
+ * @property instantiable - For types: false when abstract or a singleton.
29
+ * @property isConstructor - True when the symbol is a constructor of `parent`.
30
+ * @property hasConstructor - For types: whether a constructor was found.
31
+ * @property returnsValue - True when the call yields a value that the example binds to a variable.
32
+ * @property returnType - Declared return type, or `null` when none is declared.
33
+ * @property importContext - What to import, or `null` when the symbol needs no import or none can be derived.
34
+ */
13
35
  export interface CallTarget {
14
36
  readonly kind: SymbolKind;
15
37
  readonly name: string;
16
- /** Argument expressions, receivers excluded. */
17
38
  readonly args: readonly string[];
18
39
  readonly parent: ParentTarget | null;
19
40
  readonly isStatic: boolean;
20
41
  readonly isAsync: boolean;
21
- /** For types: false when abstract or a singleton. */
22
42
  readonly instantiable: boolean;
23
43
  readonly isConstructor: boolean;
24
- /** For types: whether a constructor was found. */
25
44
  readonly hasConstructor: boolean;
26
45
  readonly returnsValue: boolean;
27
46
  readonly returnType: string | null;
28
- /** What to import, or `null` when the symbol needs no import or none can be derived. */
29
47
  readonly importContext: ImportContext | null;
30
48
  }
31
49
  /**
32
- * Builds a usage example from a signature: an import where the language
33
- * allows one, the instance a method needs, then the call.
34
- * Returns `null` for symbols that are not called.
50
+ * @brief Builds a usage example from a signature: an import where the language allows one,
51
+ * the instance a method needs, then the call.
52
+ *
53
+ * @param style - Call syntax of the target's language.
54
+ * @param target - Symbol the example uses.
55
+ * @returns Example source, or `null` for symbols that are not called.
35
56
  */
36
57
  export declare function buildExample(style: CallStyle, target: CallTarget): string | null;
@@ -1,78 +1,113 @@
1
1
  import { type SymbolKind } from '../../model';
2
2
  import type { Node, Query } from 'web-tree-sitter';
3
3
  import type { LanguageSpec } from './language';
4
- /** One parameter as declared. */
4
+ /**
5
+ * One parameter as declared.
6
+ *
7
+ * @property name - Name with its variadic marker, such as `...rest` or `*args`.
8
+ * @property type - Declared type text, or `null` when the language or declaration has none.
9
+ * @property defaultValue - Default value text, truncated, or `null` when there is none.
10
+ * @property optional - True when the parameter may be left out of a call.
11
+ * @property argument - Expression a generated call passes for this parameter.
12
+ */
5
13
  export interface RawParameter {
6
- /** Name with its variadic marker, such as `...rest` or `*args`. */
7
14
  readonly name: string;
8
15
  readonly type: string | null;
9
16
  defaultValue: string | null;
10
17
  optional: boolean;
11
- /** Expression a generated call passes for this parameter. */
12
18
  readonly argument: string;
13
19
  }
14
- /** A field, property or enum member as declared. */
20
+ /**
21
+ * A field, property or enum member as declared.
22
+ *
23
+ * @property name - Name of the field.
24
+ * @property type - Declared type text, or `null` when none is declared.
25
+ * @property defaultValue - Initial value text, truncated, or `null` when there is none.
26
+ * @property optional - True when the field is nullable or optional.
27
+ * @property annotations - Decorator, attribute and annotation texts on the field.
28
+ * @property comment - Cleaned doc comment text, or `null`.
29
+ */
15
30
  export interface RawField {
16
31
  readonly name: string;
17
32
  readonly type: string | null;
18
33
  readonly defaultValue: string | null;
19
34
  readonly optional: boolean;
20
35
  readonly annotations: readonly string[];
21
- /** Cleaned doc comment text, or `null`. */
22
36
  readonly comment: string | null;
23
37
  }
24
- /** One definition as found in the syntax tree, before rendering. */
38
+ /**
39
+ * @brief One definition as found in the syntax tree, before rendering.
40
+ *
41
+ * @property kind - Kind of the symbol, such as `function`, `method`, `class` or `enum`.
42
+ * @property signature - Declaration head. Empty when `inferred`.
43
+ * @property modifiers - Keywords in front of the name, such as `export` or `static`.
44
+ * @property comment - Cleaned doc comment text, or `null`.
45
+ * @property parameters - Parameters as declared, with the receiver left out.
46
+ * @property fields - Fields, properties and enum members declared on this type.
47
+ * @property returnType - Declared return type text, or `null`.
48
+ * @property typeParameters - Names the declaration introduces as type parameters, such as `T`. They never name a real type.
49
+ * @property heritage - For a type: the text after its name that lists what it extends or is composed of. `''` otherwise.
50
+ * @property instantiable - False for abstract classes and singletons.
51
+ * @property isStatic - True for a method called on its type rather than on an instance.
52
+ * @property returnsValue - True when a call to the symbol yields a value.
53
+ * @property inferred - True for an owner type that is not declared in this file.
54
+ * @property children - Members nested under this symbol.
55
+ */
25
56
  export interface RawSymbol {
26
57
  kind: SymbolKind;
27
58
  readonly name: string;
28
59
  readonly line: number;
29
- /** Declaration head. Empty when `inferred`. */
30
60
  readonly signature: string;
31
- /** Keywords in front of the name, such as `export` or `static`. */
32
61
  readonly modifiers: readonly string[];
33
62
  readonly annotations: readonly string[];
34
- /** Cleaned doc comment text, or `null`. */
35
63
  readonly comment: string | null;
36
- /** Receivers excluded. */
37
64
  readonly parameters: readonly RawParameter[];
38
65
  readonly fields: RawField[];
39
66
  readonly returnType: string | null;
40
- /** Names the declaration introduces as type parameters, such as `T`. They never name a real type. */
41
67
  readonly typeParameters: readonly string[];
42
- /** For a type: the text after its name that lists what it extends or is composed of. `''` otherwise. */
43
68
  readonly heritage: string;
44
69
  readonly isAsync: boolean;
45
- /** False for abstract classes and singletons. */
46
70
  readonly instantiable: boolean;
47
71
  isStatic: boolean;
48
72
  returnsValue: boolean;
49
- /** True for an owner type that is not declared in this file. */
50
73
  readonly inferred: boolean;
51
74
  readonly children: RawSymbol[];
52
75
  }
53
- /** Symbols and package name extracted from one source file. */
76
+ /**
77
+ * Symbols and package name extracted from one source file.
78
+ *
79
+ * @property symbols - Top-level symbols of the file, each with its members nested under it.
80
+ * @property packageName - Package or namespace the file declares, or `null` when the language has none.
81
+ */
54
82
  export interface ExtractedFile {
55
83
  readonly symbols: RawSymbol[];
56
- /** Package or namespace the file declares, when the language has one. */
57
84
  readonly packageName: string | null;
58
85
  }
59
86
  /**
60
- * Turns a parsed file into a tree of {@link RawSymbol}s, driven by a {@link LanguageSpec}.
87
+ * @brief Turns a parsed file into a tree of {@link RawSymbol}s, driven by a {@link LanguageSpec}.
61
88
  *
62
- * Holds no state, so one instance serves every file. Created by `RepositoryScanner`
63
- * in `scanner/scanner.ts` and passed to `CodePlanner` in `planner.ts`, which calls
64
- * {@link SymbolExtractor.extract} once per parsed file.
89
+ * Holds no state, so one instance serves every file. Created with `new SymbolExtractor()` by
90
+ * `RepositoryScanner` in `scanner/scanner.ts` and passed to `CodePlanner` in `planner.ts`, which
91
+ * calls {@link SymbolExtractor.extract} once per parsed file.
65
92
  */
66
93
  export declare class SymbolExtractor {
67
94
  /**
68
95
  * Runs the language's tags query over the tree and builds the symbol tree from its matches.
69
96
  *
97
+ * @param root - Root node of the parsed tree.
98
+ * @param query - Compiled tags query of the language.
99
+ * @param spec - Language spec that drives the extraction.
70
100
  * @param source - Full text of the file the tree was parsed from; node offsets index into it.
101
+ * @returns Symbols of the file and its declared package name.
71
102
  */
72
103
  extract(root: Node, query: Query, spec: LanguageSpec, source: string): ExtractedFile;
73
104
  /**
74
- * Merges the query matches into one definition per node (per name for fields), sorted by
105
+ * @brief Merges the query matches into one definition per node (per name for fields), sorted by
75
106
  * position with outer nodes first, and picks up the declared package name.
107
+ *
108
+ * @param root - Root node of the parsed tree.
109
+ * @param query - Compiled tags query of the language.
110
+ * @returns Merged definitions, and the package name or `null` when none is declared.
76
111
  */
77
112
  private collect;
78
113
  }
@@ -1,6 +1,11 @@
1
1
  import { Parser, Query } from 'web-tree-sitter';
2
2
  import type { LanguageSpec } from './language';
3
- /** Parser and compiled tags query for one language. */
3
+ /**
4
+ * Parser and compiled tags query for one language.
5
+ *
6
+ * @property parser - Tree-sitter parser set to the language.
7
+ * @property query - Tags query compiled against the language.
8
+ */
4
9
  export interface LoadedGrammar {
5
10
  readonly parser: Parser;
6
11
  readonly query: Query;
@@ -9,8 +14,8 @@ export interface LoadedGrammar {
9
14
  * Loads tree-sitter grammars on first use and keeps one parser and compiled query per language.
10
15
  *
11
16
  * Holds the tree-sitter runtime init promise and one pending {@link LoadedGrammar} per
12
- * language id. Created by `RepositoryScanner` in `scanner/scanner.ts`; `CodePlanner` in
13
- * `planner.ts` loads a grammar for each file it parses.
17
+ * language id. Created with `new GrammarLoader(baseDir)` by `RepositoryScanner` in
18
+ * `scanner/scanner.ts`; `CodePlanner` in `planner.ts` calls `load` for each file it parses.
14
19
  */
15
20
  export declare class GrammarLoader {
16
21
  private readonly baseDir;
@@ -22,8 +27,18 @@ export declare class GrammarLoader {
22
27
  * @param baseDir - Absolute directory that relative grammar paths resolve against.
23
28
  */
24
29
  constructor(baseDir: string);
25
- /** Returns the cached grammar of the spec's language, loading it on the first call. */
30
+ /**
31
+ * Returns the cached grammar of the spec's language, loading it on the first call.
32
+ *
33
+ * @param spec - Language whose grammar is needed.
34
+ * @returns Parser and query for the language, resolved once the grammar is loaded.
35
+ */
26
36
  load(spec: LanguageSpec): Promise<LoadedGrammar>;
27
- /** Initialises the tree-sitter runtime once, then loads the grammar `.wasm` and compiles the query. */
37
+ /**
38
+ * Initialises the tree-sitter runtime once, then loads the grammar `.wasm` and compiles the query.
39
+ *
40
+ * @param spec - Language to load.
41
+ * @returns Parser and query for the language.
42
+ */
28
43
  private create;
29
44
  }