@g3nomaly/analyze 0.1.0 → 0.1.1

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
@@ -1,47 +1,64 @@
1
1
  import type { NodeRef } from '../../model';
2
2
  import type { GraphBuilder } from '../graph/builder';
3
- /** A glossary term found in a run of prose. */
3
+ /**
4
+ * @brief A glossary term found in a run of prose.
5
+ *
6
+ * @property start - Offset where the term starts in the text.
7
+ * @property end - Offset where the term ends in the text.
8
+ * @property href - In-site href of the term's entry.
9
+ * @property title - The definition as plain text, for a tooltip.
10
+ */
4
11
  export interface TermMatch {
5
- /** Offsets of the term in the text. */
6
12
  readonly start: number;
7
13
  readonly end: number;
8
- /** In-site href of the term's entry. */
9
14
  readonly href: string;
10
- /** The definition as plain text, for a tooltip. */
11
15
  readonly title: string;
12
16
  }
13
- /** Finds the glossary terms of one piece of prose. */
17
+ /**
18
+ * @brief Finds the glossary terms of one piece of prose.
19
+ *
20
+ * @param text - Plain prose to search.
21
+ * @returns The matches in text order.
22
+ */
14
23
  export type TermFinder = (text: string) => TermMatch[];
15
- /** One definition of a term in the index. */
24
+ /**
25
+ * @brief One definition of a term in the index.
26
+ *
27
+ * @property ref - Node of the term's entry.
28
+ * @property path - Path of the glossary file that defines the term.
29
+ * @property summary - The definition as plain text.
30
+ */
16
31
  interface TermEntry {
17
32
  readonly ref: NodeRef;
18
- /** Path of the glossary file that defines the term. */
19
33
  readonly path: string;
20
34
  readonly summary: string;
21
35
  }
22
36
  /**
23
- * Every term of every glossary of the scan, by name, and finds uses of them
24
- * in text.
37
+ * @brief Every term of every glossary of the scan, by name, and finds uses of them in text.
38
+ *
39
+ * Holds the definitions of each term, keyed by its lowercased name, and one regex that matches any
40
+ * term. Created once per scan by `RepositoryScanner`, filled by `GlossaryPlanner` and read by
41
+ * `TermLinker`. Created with `new TermIndex()`.
25
42
  *
26
- * Holds the definitions of each term, keyed by its lowercased name, and one
27
- * regex that matches any term. Created once per scan by `RepositoryScanner`,
28
- * filled by `GlossaryPlanner` and read by `TermLinker`.
43
+ * @property byName - Definitions of each term, keyed by its normalized name.
44
+ * @property pattern - Matches any term. `null` until built, and reset when a term is added.
29
45
  */
30
46
  export declare class TermIndex {
31
47
  private readonly byName;
32
- /** Matches any term. Rebuilt after a term is added. */
33
48
  private pattern;
34
49
  /**
35
- * Adds a term.
50
+ * @brief Adds a term.
36
51
  *
37
52
  * @param name - The term as the glossary writes it.
53
+ * @param ref - Node of the term's entry.
38
54
  * @param path - Path of the glossary file, as the site shows it.
39
55
  * @param summary - The definition as plain text.
40
56
  */
41
57
  register(name: string, ref: NodeRef, path: string, summary: string): void;
42
58
  /**
43
- * Finds every use of a term in a text. Case is ignored and a plural ending
44
- * is allowed. Where two terms overlap, the longer one wins.
59
+ * @brief Finds every use of a term in a text.
60
+ *
61
+ * Case is ignored and a plural ending is allowed. Where two terms overlap, the longer one wins.
45
62
  *
46
63
  * @param text - Plain prose.
47
64
  * @param path - Path of the file the prose is in, or `null`. Chooses between glossaries that define the same term.
@@ -52,30 +69,43 @@ export declare class TermIndex {
52
69
  end: number;
53
70
  term: TermEntry;
54
71
  }[];
55
- /** Builds one regex that matches any term, longest first, with an optional plural ending. */
72
+ /**
73
+ * @brief Builds one regex that matches any term, longest first, with an optional plural ending.
74
+ *
75
+ * @returns The regex.
76
+ */
56
77
  private buildPattern;
57
78
  /**
58
- * Finds the definition a written term names. The glossary closest to the
59
- * file wins when several define the term.
79
+ * @brief Finds the definition a written term names. The glossary closest to the file wins when
80
+ * several define the term.
81
+ *
82
+ * @param written - The term as the prose writes it.
83
+ * @param path - Path of the file the prose is in, or `null`.
84
+ * @returns The definition, or `null` when none matches.
60
85
  */
61
86
  private resolve;
62
87
  }
63
88
  /**
64
- * Turns the glossary terms in prose into links to their entries, and records each use as an edge.
89
+ * @brief Turns the glossary terms in prose into links to their entries, and records each use as an edge.
65
90
  *
66
- * Holds the `TermIndex` and the graph. Created once per scan by
67
- * `RepositoryScanner` and handed to `ProseResolvers`, which asks it for a
68
- * finder per piece of prose.
91
+ * Holds the `TermIndex` and the graph. Created once per scan by `RepositoryScanner` and handed to
92
+ * `ProseResolvers`, which asks it for a finder per piece of prose.
69
93
  */
70
94
  export declare class TermLinker {
71
95
  private readonly index;
72
96
  private readonly graph;
73
- /** Creates a linker that reads `index` and records edges in `graph`. */
97
+ /**
98
+ * Creates a linker that reads `index` and records edges in `graph`.
99
+ *
100
+ * @param index - The terms the prose is searched for.
101
+ * @param graph - Graph the `uses` edges are added to.
102
+ */
74
103
  constructor(index: TermIndex, graph: GraphBuilder);
75
104
  /**
76
- * Creates the finder for one piece of prose, such as a page or a
77
- * description. The finder links each term once, at its first use, and
78
- * records a `uses` edge from the owner to the term.
105
+ * @brief Creates the finder for one piece of prose, such as a page or a description.
106
+ *
107
+ * The finder links each term once, at its first use, and records a `uses` edge from the owner to
108
+ * the term.
79
109
  *
80
110
  * @param from - Node that owns the prose.
81
111
  * @param path - Path of the file the prose is in, or `null` when it has none.
@@ -1,49 +1,108 @@
1
- import { type Edge, type EdgeKind, type GraphNode, type NodeKind, type NodeRef } from '../../model';
1
+ import { type Edge, type EdgeKind, type GraphNode, type NodeType, type NodeRef } from '../../model';
2
+ import type { PackageInfo } from '../packages';
2
3
  /** The fields of a node that fix its place in the tree and its route. Known when the node is added. */
3
4
  type IdentityKey = 'kind' | 'name' | 'parent' | 'slug' | 'anchor';
4
5
  /** The node types whose `kind` can be `K`. */
5
- type NodeOf<K extends NodeKind, N = GraphNode> = N extends GraphNode ? (K extends N['kind'] ? N : never) : never;
6
+ type NodeOf<K extends NodeType, N = GraphNode> = N extends GraphNode ? (K extends N['kind'] ? N : never) : never;
6
7
  /** The identity fields of a node of kind `K`, as `add` takes them. */
7
- export type IdentityOf<K extends NodeKind> = Omit<Pick<NodeOf<K>, Extract<keyof NodeOf<K>, IdentityKey>>, 'kind'>;
8
+ export type IdentityOf<K extends NodeType> = Omit<Pick<NodeOf<K>, Extract<keyof NodeOf<K>, IdentityKey>>, 'kind'>;
8
9
  /** The fields of a node of kind `K` that its `ContentSource` produces. */
9
- export type ContentOf<K extends NodeKind> = Omit<NodeOf<K>, IdentityKey>;
10
- /** Produces the rest of a node. Runs in `build`, when every node has its place, so it can link to any of them. */
11
- export type ContentSource<K extends NodeKind> = (self: NodeRef) => ContentOf<K> | Promise<ContentOf<K>>;
10
+ export type ContentOf<K extends NodeType> = Omit<NodeOf<K>, IdentityKey>;
12
11
  /**
13
- * Builds the graph in two passes.
12
+ * @brief Produces the rest of a node. Runs in `build`, when every node has its place, so it can link to any of them.
13
+ *
14
+ * @param self - Ref of the node being built, which the source may link from.
15
+ * @returns The fields of the node that its identity does not hold.
16
+ */
17
+ export type ContentSource<K extends NodeType> = (self: NodeRef) => ContentOf<K> | Promise<ContentOf<K>>;
18
+ /**
19
+ * @brief Builds the graph in two passes.
14
20
  *
15
21
  * 1. The scanners `add` every node: its kind, name and parent. That fixes the
16
22
  * tree, the routes and the refs.
17
23
  * 2. `build` requests the content of every node. By then a link from any node to
18
24
  * any other can be resolved.
19
25
  *
20
- * Holds the identity and content source of every node, the edges, the folder
21
- * nodes by path and the file nodes by path. A node's `NodeRef` is its index.
22
- * Created once per scan by `RepositoryScanner`, which calls `build` at the end;
23
- * every planner (`code/`, `sql/`, `docs`, `skills/`, `tasks/`, `glossary/`,
24
- * `decisions/`, `schema/`, `openapi/`) and `ProseResolvers` add nodes and edges to it.
26
+ * A node's `NodeRef` is its index. Created once per scan by `RepositoryScanner`,
27
+ * which calls `build` at the end; every planner (`code/`, `sql/`, `docs`,
28
+ * `skills/`, `tasks/`, `glossary/`, `decisions/`, `schema/`, `openapi/`) and
29
+ * `ProseResolvers` add nodes and edges to it.
30
+ *
31
+ * @property identities - Routable identity of each node, by `NodeRef`. Together with `contents` it makes the node.
32
+ * @property contents - Content source of each node by `NodeRef`, or `null` for a node that has none.
33
+ * @property edges - Edges by `from:kind:to`, so an edge recorded twice is kept once.
34
+ * @property folders - Folder nodes by `parent/name`.
35
+ * @property files - File nodes by normalized path.
36
+ * @property packages - Packages by display path of their directory, set by `markPackages`.
37
+ * @property packageSections - Sections whose folders become `package` nodes where a package sits.
38
+ * @example
39
+ * const graph = new GraphBuilder();
25
40
  */
26
41
  export declare class GraphBuilder {
27
- /** `identities[ref]` and `contents[ref]` together make the node at `ref`. */
28
42
  private readonly identities;
29
43
  private readonly contents;
30
44
  private readonly edges;
31
45
  private readonly folders;
32
46
  private readonly files;
33
- /** Adds a node. Kinds without content of their own, such as folders, take no `content`. */
34
- add<K extends NodeKind>(kind: K, identity: IdentityOf<K>, ...content: Record<never, never> extends ContentOf<K> ? [] : [ContentSource<K>]): NodeRef;
35
- /** The folder at `directory` below `parent`, created with its ancestors on first use. `''` is `parent` itself. */
47
+ private packages;
48
+ private readonly packageSections;
49
+ /**
50
+ * @brief Adds a node. Kinds without content of their own, such as folders, take no `content`.
51
+ *
52
+ * @param identity - Fields that place the node: its name and parent, plus the slug or anchor of kinds that have them.
53
+ * @param content - Source of the rest of the node. Omitted for a kind without content.
54
+ * @returns Ref of the new node.
55
+ */
56
+ add<K extends NodeType>(kind: K, identity: IdentityOf<K>, ...content: Record<never, never> extends ContentOf<K> ? [] : [ContentSource<K>]): NodeRef;
57
+ /**
58
+ * @brief Makes `folder` create a `package` node instead of a folder for every package directory below the given sections.
59
+ *
60
+ * @param sections - Sections whose `folder` paths are display paths of the repository, such as the code and docs sections.
61
+ * @param packages - Packages by display path of their directory, as `detectPackages` returns them.
62
+ */
63
+ markPackages(sections: readonly NodeRef[], packages: ReadonlyMap<string, PackageInfo>): void;
64
+ /**
65
+ * @brief Finds the folder at `directory` below `parent`, creating it and its ancestors on first use.
66
+ *
67
+ * Below a section passed to `markPackages`, a directory that holds a package becomes a `package` node.
68
+ *
69
+ * @param parent - Node the directory is below.
70
+ * @param directory - Slash-separated path, such as `docs/guides`. `''` names `parent` itself.
71
+ * @returns Ref of the folder at the end of the path.
72
+ */
36
73
  folder(parent: NodeRef, directory: string): NodeRef;
37
- /** Records which node shows the file at `path`, so links to that file can find it. */
74
+ /**
75
+ * @brief Records which node shows the file at `path`, so links to that file can find it.
76
+ *
77
+ * @param path - Display path of the file, as `DocFile.displayPath` gives it. Normalized before storing.
78
+ * @param ref - Node that shows the file.
79
+ */
38
80
  registerFile(path: string, ref: NodeRef): void;
39
- /** Finds the node registered for the file at `path`, or `undefined`. */
81
+ /**
82
+ * @brief Finds the node registered for the file at `path`.
83
+ *
84
+ * @param path - Display path of the file, as passed to `registerFile`.
85
+ * @returns The node, or `undefined` when no file is registered at that path.
86
+ */
40
87
  fileAt(path: string): NodeRef | undefined;
41
- /** In-site href of a node. `fragment` replaces the node's own anchor, for a heading on a page. */
88
+ /**
89
+ * @brief Builds the in-site href of a node.
90
+ *
91
+ * @param ref - Node to link to.
92
+ * @param fragment - Replaces the node's own anchor, for a heading on a page.
93
+ * @returns The href, relative to the site root.
94
+ */
42
95
  href(ref: NodeRef, fragment?: string): string;
43
- /** Records an edge. The same edge recorded twice is kept once. */
96
+ /**
97
+ * @brief Records an edge. The same edge recorded twice is kept once.
98
+ *
99
+ * @param from - Node the edge starts at.
100
+ * @param kind - Relation the edge expresses.
101
+ * @param to - Node the edge ends at.
102
+ */
44
103
  link(from: NodeRef, kind: EdgeKind, to: NodeRef): void;
45
104
  /**
46
- * Runs the content source of every node and returns the finished graph.
105
+ * @brief Runs the content source of every node and returns the finished graph.
47
106
  *
48
107
  * @returns Nodes in `NodeRef` order, and edges sorted by source, kind (in `EDGE_KINDS` order) and target.
49
108
  */
@@ -1,15 +1,25 @@
1
1
  import type { Element } from 'hast';
2
- /** Highlights code of a language into HTML or into a HAST `<pre>` element. */
2
+ /**
3
+ * @brief Highlights code of a language into HTML or into a HAST `<pre>` element.
4
+ *
5
+ * @property toHtml - Highlights code into an HTML string.
6
+ * @property toHast - Highlights code into the HAST `<pre>` element shiki produces.
7
+ */
3
8
  export interface CodeHighlighter {
4
9
  toHtml(code: string, language: string): Promise<string>;
5
10
  toHast(code: string, language: string): Promise<Element>;
6
11
  }
7
12
  /**
8
- * Highlights with shiki. Colors are emitted as `var(--syntax-*)` references,
9
- * so the page stylesheet owns the palette in light and dark mode. Holds one
10
- * shiki highlighter, created on first use, and loads each language once; an
11
- * unknown language falls back to plain text. Created in `api/services.ts` and
12
- * passed to `RepositoryScanner`, which hands it to the renderers and planners.
13
+ * @brief Highlights with shiki. Colors are emitted as `var(--syntax-*)` references,
14
+ * so the page stylesheet owns the palette in light and dark mode. Loads each
15
+ * language once; an unknown language falls back to plain text. Created in
16
+ * `api/services.ts` and passed to `RepositoryScanner`, which hands it to the
17
+ * renderers and planners.
18
+ *
19
+ * @property highlighter - The shiki highlighter, created on first use. `null` until then.
20
+ * @property loading - Pending load of each language by name, shared between callers.
21
+ * @example
22
+ * const highlighter = new ShikiHighlighter();
13
23
  */
14
24
  export declare class ShikiHighlighter implements CodeHighlighter {
15
25
  private highlighter;
@@ -19,13 +29,26 @@ export declare class ShikiHighlighter implements CodeHighlighter {
19
29
  /** Highlights code into the HAST `<pre>` element shiki produces. */
20
30
  toHast(code: string, language: string): Promise<Element>;
21
31
  /**
22
- * Creates the shiki highlighter on first use and loads a language.
32
+ * @brief Creates the shiki highlighter on first use and loads a language.
23
33
  *
34
+ * @param language - Language name as the code block gives it, in any case.
24
35
  * @returns The highlighter and the language name to pass to it: the lowercased `language`, or `text` when shiki lacks it.
25
36
  */
26
37
  private prepare;
27
- /** Loads a language once, sharing the pending load between callers. */
38
+ /**
39
+ * @brief Loads a language once, sharing the pending load between callers.
40
+ *
41
+ * @param highlighter - The shiki highlighter the language is loaded into.
42
+ * @param language - Lowercased language name.
43
+ * @returns The name to highlight with: `language`, or `text` when it cannot be loaded.
44
+ */
28
45
  private resolveLanguage;
29
- /** Loads a bundled language into shiki, or returns `text` when it is not bundled or fails to load. */
46
+ /**
47
+ * @brief Loads a bundled language into shiki, or returns `text` when it is not bundled or fails to load.
48
+ *
49
+ * @param highlighter - The shiki highlighter the language is loaded into.
50
+ * @param language - Lowercased language name.
51
+ * @returns The language name, or `text`.
52
+ */
30
53
  private load;
31
54
  }
@@ -0,0 +1,25 @@
1
+ /** Name of the file at the root of a repository that lists what analyze skips. */
2
+ export declare const IGNORE_FILE = ".analyzeignore";
3
+ /** Lines of the `.analyzeignore` that analyze writes when a repository has none. */
4
+ export declare const DEFAULT_IGNORE_LINES: readonly string[];
5
+ /**
6
+ * @brief Turns the lines of an ignore file into globs that `Bun.Glob` matches against root-relative paths.
7
+ *
8
+ * A pattern without a slash matches at any depth, a leading `/` anchors it to the root, and a
9
+ * trailing `/` matches a directory. A pattern without a trailing `/` matches a file or a directory.
10
+ * Blank lines and `#` comments are skipped. Negation with `!` is not supported, so such a line is skipped too.
11
+ *
12
+ * @param text - Contents of the ignore file.
13
+ * @returns Globs, two per pattern that may name a file or a directory. `dist/` gives one: any `dist` directory and all below it.
14
+ */
15
+ export declare function ignoreGlobs(text: string): string[];
16
+ /**
17
+ * @brief Reads the `.analyzeignore` of a repository, and writes one with {@link DEFAULT_IGNORE_LINES} when it has none.
18
+ *
19
+ * @param repo - Absolute path of the repository.
20
+ * @returns The globs of the file, and whether this call created the file.
21
+ */
22
+ export declare function loadIgnoreFile(repo: string): {
23
+ globs: string[];
24
+ created: boolean;
25
+ };
@@ -8,8 +8,10 @@ export { CallableIndex, PROSE_SCOPE, TypeIndex, TypeLinker, type TypeScope } fro
8
8
  export { FileRenderer, type RenderedFile } from './content';
9
9
  export { type ParsedDecision, type ParsedDecisions, parseDecisions } from './decisions/parse';
10
10
  export { DecisionPlanner } from './decisions/planner';
11
- export { type DocFile, type DocKind, DocPlanner, docKind } from './docs';
12
- export { compareTreePaths, DEFAULT_EXCLUDES, type FileLister, RepoFileLister, type Source } from './files';
11
+ export { ConfigPlanner } from './config';
12
+ export { addFilePage, type DocFile, type DocKind, DocPlanner, docKind } from './docs';
13
+ export { compareTreePaths, type FileLister, RepoFileLister, type Source } from './files';
14
+ export { DEFAULT_IGNORE_LINES, IGNORE_FILE, ignoreGlobs, loadIgnoreFile } from './ignore';
13
15
  export { type ParsedGlossary, type ParsedTerm, parseGlossary } from './glossary/parse';
14
16
  export { GlossaryPlanner } from './glossary/planner';
15
17
  export { type TermFinder, TermIndex, TermLinker, type TermMatch } from './glossary/terms';
@@ -19,6 +21,7 @@ export { type LinkOrigin, ProseResolvers } from './markdown/links';
19
21
  export { joinLines, type MarkdownLine, outlineLines, plainText } from './markdown/outline';
20
22
  export { type LinkResolver, MarkdownRenderer, type RenderedMarkdown } from './markdown/renderer';
21
23
  export { OpenApiPlanner } from './openapi/planner';
24
+ export { detectPackages, type PackageInfo } from './packages';
22
25
  export { type Reporter, silentReporter } from './reporter';
23
26
  export { RepositoryScanner, type ScanInput, type ScannerOptions } from './scanner';
24
27
  export { type DefinitionOwner, DefinitionPlanner } from './schema/definitions';
@@ -1,9 +1,24 @@
1
- /** A markdown document split into its YAML frontmatter and the rest. */
1
+ /**
2
+ * @brief A markdown document split into its YAML frontmatter and the rest.
3
+ *
4
+ * @property data - Parsed frontmatter fields. `{}` when there is no valid frontmatter.
5
+ * @property body - The markdown after the frontmatter block, as written.
6
+ */
2
7
  export interface Frontmatter {
3
8
  readonly data: Readonly<Record<string, unknown>>;
4
9
  readonly body: string;
5
10
  }
6
- /** Splits a leading YAML block from a markdown document. Invalid YAML yields empty data. */
11
+ /**
12
+ * @brief Splits a leading YAML block from a markdown document. Invalid YAML yields empty data.
13
+ *
14
+ * @param source - Markdown text, with or without frontmatter.
15
+ * @returns The parsed frontmatter and the text after it.
16
+ */
7
17
  export declare function splitFrontmatter(source: string): Frontmatter;
8
- /** Reads a frontmatter field as trimmed text, or `null` when it is missing, blank or no string. */
18
+ /**
19
+ * @brief Reads a frontmatter field as trimmed text, or `null` when it is missing, blank or no string.
20
+ *
21
+ * @param data - Parsed frontmatter, as `Frontmatter.data` holds it.
22
+ * @param key - Name of the field, such as `title`.
23
+ */
9
24
  export declare function stringField(data: Readonly<Record<string, unknown>>, key: string): string | null;
@@ -3,19 +3,22 @@ import { type TypeLinker, type TypeScope } from '../code/types';
3
3
  import type { TermLinker } from '../glossary/terms';
4
4
  import type { GraphBuilder } from '../graph/builder';
5
5
  import type { LinkResolver } from './renderer';
6
- /** The markdown file whose links are resolved. */
6
+ /**
7
+ * @brief The markdown file whose links are resolved.
8
+ *
9
+ * @property node - The node that shows the text. Edges start here.
10
+ * @property root - Absolute directory `path` is relative to.
11
+ * @property path - Path of the file inside `root`.
12
+ * @property prefix - Prefix the bundle puts in front of paths from `root`.
13
+ */
7
14
  export interface LinkOrigin {
8
- /** The node that shows the text. Edges start here. */
9
15
  readonly node: NodeRef;
10
- /** Absolute directory `path` is relative to. */
11
16
  readonly root: string;
12
- /** Path of the file inside `root`. */
13
17
  readonly path: string;
14
- /** Prefix the bundle puts in front of paths from `root`. */
15
18
  readonly prefix: string;
16
19
  }
17
20
  /**
18
- * Creates the link resolver for each piece of markdown of a scan. One place
21
+ * @brief Creates the link resolver for each piece of markdown of a scan. One place
19
22
  * decides what prose can link to: files, types, functions and glossary terms.
20
23
  *
21
24
  * Holds the graph, the type linker and the term linker. Created once per scan
@@ -28,17 +31,24 @@ export declare class ProseResolvers {
28
31
  private readonly graph;
29
32
  private readonly linker;
30
33
  private readonly terms;
31
- /** Creates the resolver factory. */
34
+ /**
35
+ * @brief Creates the resolver factory.
36
+ *
37
+ * @param graph - Receives the edges that resolved references record.
38
+ * @param linker - Links type and function names in inline code.
39
+ * @param terms - Links glossary terms in prose.
40
+ */
32
41
  constructor(graph: GraphBuilder, linker: TypeLinker, terms: TermLinker);
33
42
  /**
34
- * Resolver for markdown that comes from a file: a page, a term, a decision.
43
+ * @brief Makes the resolver for markdown that comes from a file: a page, a term, a decision.
35
44
  *
45
+ * @param origin - The file the markdown is in.
36
46
  * @param relation - Kind of the edge a link to a file, type or function records.
37
47
  * @returns A resolver for one render of that text.
38
48
  */
39
49
  forFile(origin: LinkOrigin, relation?: EdgeKind): LinkResolver;
40
50
  /**
41
- * Resolver for the description of a symbol, parameter or field. A doc
51
+ * @brief Makes the resolver for the description of a symbol, parameter or field. A doc
42
52
  * comment has no links to files, so only inline code and terms resolve.
43
53
  *
44
54
  * @param from - Node the description belongs to.
@@ -1,27 +1,35 @@
1
- /** One line of a markdown text. */
1
+ /**
2
+ * @brief One line of a markdown text.
3
+ *
4
+ * @property text - The line as written, without its line break.
5
+ * @property heading - Depth and plain text of the line when it is an ATX heading such as `## Terms`. `null` otherwise.
6
+ */
2
7
  export interface MarkdownLine {
3
8
  readonly text: string;
4
- /** Set when the line is an ATX heading such as `## Terms`. */
5
9
  readonly heading: {
6
10
  readonly depth: number;
7
11
  readonly text: string;
8
12
  } | null;
9
13
  }
10
14
  /**
11
- * Splits markdown into lines and marks the headings. A `#` line inside a
15
+ * @brief Splits markdown into lines and marks the headings. A `#` line inside a
12
16
  * fenced code block is code, not a heading.
13
17
  *
14
18
  * @param markdown - Markdown text without frontmatter.
19
+ * @returns One entry per line, in order.
15
20
  */
16
21
  export declare function outlineLines(markdown: string): MarkdownLine[];
17
22
  /**
18
- * Removes inline markdown markers from a short text such as a heading.
23
+ * @brief Removes inline markdown markers from a short text such as a heading.
19
24
  *
20
25
  * @param markdown - Inline markdown, for example `**Lane** (_route_)`.
21
26
  * @returns The text a reader sees, for example `Lane (route)`.
22
27
  */
23
28
  export declare function plainText(markdown: string): string;
24
29
  /**
25
- * Joins lines back into markdown and drops blank lines at both ends.
30
+ * @brief Joins lines back into markdown and drops blank lines at both ends.
31
+ *
32
+ * @param lines - Lines to join, in order.
33
+ * @returns The markdown text, with no blank lines at either end.
26
34
  */
27
35
  export declare function joinLines(lines: readonly MarkdownLine[]): string;
@@ -1,44 +1,63 @@
1
1
  import type { Heading } from '../../model';
2
2
  import type { TermMatch } from '../glossary/terms';
3
3
  import type { CodeHighlighter } from '../highlight';
4
- /** Turns what one document refers to into links inside the site. */
4
+ /**
5
+ * @brief Turns what one document refers to into links inside the site.
6
+ *
7
+ * @property link - In-site href for a relative link, or `null` when it points outside the bundle.
8
+ * @property image - `data:` URI for a relative image, or `null` when it cannot be embedded.
9
+ * @property code - In-site href for inline code that names something in the bundle, such as a class. Optional.
10
+ * @property terms - The glossary terms in one run of prose that should become links. Optional.
11
+ */
5
12
  export interface LinkResolver {
6
- /** In-site href for a relative link, or `null` when it points outside the bundle. */
7
13
  link(href: string): string | null;
8
- /** `data:` URI for a relative image, or `null` when it cannot be embedded. */
9
14
  image(src: string): Promise<string | null>;
10
- /** In-site href for inline code that names something in the bundle, such as a class. */
11
15
  code?(text: string): string | null;
12
- /** The glossary terms in one run of prose that should become links. */
13
16
  terms?(text: string): TermMatch[];
14
17
  }
15
- /** The HTML of a markdown text, with its headings and title. */
18
+ /**
19
+ * @brief The HTML of a markdown text, with its headings and title.
20
+ *
21
+ * @property html - The rendered HTML.
22
+ * @property headings - Headings of depth 2 and 3 that have an id, in document order.
23
+ * @property title - Text of the first level-1 heading, or `null` when there is none.
24
+ */
16
25
  export interface RenderedMarkdown {
17
26
  readonly html: string;
18
27
  readonly headings: Heading[];
19
- /** Text of the first level-1 heading. */
20
28
  readonly title: string | null;
21
29
  }
22
30
  /**
23
- * Markdown to HTML. Raw HTML in the source is dropped, so the output is safe
31
+ * @brief Markdown to HTML. Raw HTML in the source is dropped, so the output is safe
24
32
  * to inject into the generated page. Code blocks are highlighted, and links,
25
33
  * images, inline code and glossary terms are resolved through a `LinkResolver`.
26
34
  *
27
- * Holds only the code highlighter. Created once per scan by
28
- * `RepositoryScanner` and used by `FileRenderer` and the planners in
35
+ * Holds only the code highlighter. Created once by the constructor of
36
+ * `RepositoryScanner`, and used by `FileRenderer` and the planners in
29
37
  * `code/`, `sql/`, `schema/`, `openapi/`, `glossary/`, `decisions/` and `tasks/`.
38
+ *
39
+ * @example
40
+ * const renderer = new MarkdownRenderer(new ShikiHighlighter());
30
41
  */
31
42
  export declare class MarkdownRenderer {
32
43
  private readonly highlighter;
33
- /** Creates a renderer that highlights code blocks with `highlighter`. */
44
+ /**
45
+ * @brief Creates a renderer that highlights code blocks.
46
+ *
47
+ * @param highlighter - Highlights the code blocks of the markdown.
48
+ */
34
49
  constructor(highlighter: CodeHighlighter);
35
50
  /**
36
- * Renders markdown to HTML.
51
+ * @brief Renders markdown to HTML.
37
52
  *
38
53
  * @param resolver - Resolves links, images, inline code and terms. Without one, relative links lose their href and relative images become their alt text.
39
54
  * @returns The HTML, the level-2 and level-3 headings, and the text of the first level-1 heading as title.
40
55
  */
41
56
  render(markdown: string, resolver?: LinkResolver): Promise<RenderedMarkdown>;
42
- /** Replaces the content of every `<pre><code>` block with highlighted HTML. */
57
+ /**
58
+ * @brief Replaces the content of every `<pre><code>` block with highlighted HTML.
59
+ *
60
+ * @param tree - The hast tree, changed in place.
61
+ */
43
62
  private highlightCode;
44
63
  }