patram 0.8.0 → 0.10.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.
- package/bin/patram.js +2 -2
- package/lib/cli/arguments.types.d.ts +63 -0
- package/lib/{parse-cli-color-options.js → cli/color-options.js} +2 -2
- package/lib/cli/command-helpers.js +35 -0
- package/lib/cli/commands/check.js +73 -0
- package/lib/cli/commands/fields.js +57 -0
- package/lib/cli/commands/queries.js +41 -0
- package/lib/cli/commands/query.js +242 -0
- package/lib/cli/commands/refs.js +72 -0
- package/lib/cli/commands/show.js +58 -0
- package/lib/{cli-help-metadata.js → cli/help-metadata.js} +7 -102
- package/lib/cli/main.js +76 -0
- package/lib/{parse-cli-arguments-helpers.js → cli/parse-arguments-helpers.js} +24 -12
- package/lib/{parse-cli-arguments.js → cli/parse-arguments.js} +12 -12
- package/lib/{parse-cli-query-pagination.js → cli/query-pagination.js} +2 -2
- package/lib/{render-cli-help.js → cli/render-help.js} +84 -3
- package/lib/{resolve-output-mode.js → cli/resolve-output-mode.js} +2 -2
- package/lib/cli/test-helpers.js +30 -0
- package/lib/config/defaults.d.ts +10 -0
- package/lib/config/defaults.js +80 -0
- package/lib/config/load-patram-config.d.ts +76 -0
- package/lib/config/load-patram-config.js +315 -0
- package/lib/config/load-patram-config.types.d.ts +45 -0
- package/lib/{patram-config.d.ts → config/patram-config.d.ts} +31 -31
- package/lib/{patram-config.js → config/patram-config.js} +3 -3
- package/lib/{patram-config.types.d.ts → config/patram-config.types.d.ts} +1 -1
- package/lib/{resolve-patram-graph-config.d.ts → config/resolve-patram-graph-config.d.ts} +2 -2
- package/lib/{resolve-patram-graph-config.js → config/resolve-patram-graph-config.js} +3 -3
- package/lib/{load-patram-config.d.ts → config/schema.d.ts} +149 -191
- package/lib/config/schema.js +328 -0
- package/lib/{source-file-defaults.d.ts → config/source-file-defaults.d.ts} +0 -1
- package/lib/{source-file-defaults.js → config/source-file-defaults.js} +1 -1
- package/lib/config/validation.d.ts +27 -0
- package/lib/config/validation.js +615 -0
- package/lib/directive-validation-test-helpers.js +1 -1
- package/lib/find-close-match.d.ts +8 -0
- package/lib/find-close-match.js +98 -0
- package/lib/{build-graph-identity.d.ts → graph/build-graph-identity.d.ts} +2 -2
- package/lib/{build-graph-identity.js → graph/build-graph-identity.js} +1 -1
- package/lib/{build-graph.d.ts → graph/build-graph.d.ts} +3 -3
- package/lib/{build-graph.js → graph/build-graph.js} +17 -13
- package/lib/{build-graph.types.d.ts → graph/build-graph.types.d.ts} +1 -1
- package/lib/graph/check-directive-metadata.d.ts +23 -0
- package/lib/{check-directive-metadata.js → graph/check-directive-metadata.js} +7 -7
- package/lib/graph/check-directive-path-target.d.ts +32 -0
- package/lib/{check-directive-path-target.js → graph/check-directive-path-target.js} +4 -4
- package/lib/graph/check-directive-value.d.ts +19 -0
- package/lib/{check-directive-value.js → graph/check-directive-value.js} +3 -3
- package/lib/graph/check-graph.d.ts +29 -0
- package/lib/{check-graph.js → graph/check-graph.js} +6 -6
- package/lib/graph/directive-diagnostics.d.ts +20 -0
- package/lib/{directive-diagnostics.js → graph/directive-diagnostics.js} +2 -2
- package/lib/graph/directive-type-rules.d.ts +18 -0
- package/lib/{directive-type-rules.js → graph/directive-type-rules.js} +3 -3
- package/lib/{document-node-identity.d.ts → graph/document-node-identity.d.ts} +2 -2
- package/lib/{document-node-identity.js → graph/document-node-identity.js} +2 -2
- package/lib/graph/inspect-reverse-references.d.ts +22 -0
- package/lib/{inspect-reverse-references.js → graph/inspect-reverse-references.js} +2 -2
- package/lib/{load-project-graph.d.ts → graph/load-project-graph.d.ts} +10 -10
- package/lib/{load-project-graph.js → graph/load-project-graph.js} +12 -12
- package/lib/{parse-where-clause.types.d.ts → graph/parse-where-clause.types.d.ts} +1 -1
- package/lib/{query-graph.d.ts → graph/query/execute.d.ts} +11 -11
- package/lib/{query-graph.js → graph/query/execute.js} +12 -12
- package/lib/{query-inspection.d.ts → graph/query/inspect.d.ts} +10 -8
- package/lib/{query-inspection.js → graph/query/inspect.js} +16 -17
- package/lib/{parse-where-clause.d.ts → graph/query/parse.d.ts} +6 -6
- package/lib/{parse-where-clause.js → graph/query/parse.js} +2 -2
- package/lib/graph/query/resolve.d.ts +28 -0
- package/lib/{resolve-where-clause.js → graph/query/resolve.js} +39 -5
- package/lib/graph/reverse-reference-test-helpers.d.ts +55 -0
- package/lib/{command-output.js → output/command-output.js} +5 -5
- package/lib/{derived-summary.js → output/derived-summary.js} +7 -7
- package/lib/{layout-incoming-references.js → output/layout-incoming-references.js} +4 -4
- package/lib/{layout-incoming-summary-lines.js → output/layout-incoming-summary-lines.js} +0 -5
- package/lib/{layout-stored-queries.js → output/layout-stored-queries.js} +27 -11
- package/lib/{list-queries.js → output/list-queries.js} +3 -2
- package/lib/{render-check-output.js → output/render-check-output.js} +1 -1
- package/lib/{render-field-discovery.js → output/render-field-discovery.js} +3 -3
- package/lib/output/render-output-view.js +56 -0
- package/lib/{render-json-output.js → output/renderers/json.js} +10 -6
- package/lib/{render-plain-output.js → output/renderers/plain.js} +34 -33
- package/lib/{render-rich-output.js → output/renderers/rich.js} +44 -32
- package/lib/{resolve-check-target.js → output/resolve-check-target.js} +1 -1
- package/lib/{render-rich-source.js → output/rich-source/render.js} +6 -6
- package/lib/{show-document.js → output/show-document.js} +12 -12
- package/lib/{render-output-view.js → output/view-model/index.js} +11 -70
- package/lib/{write-paged-output.js → output/write-paged-output.js} +9 -5
- package/lib/{claim-helpers.d.ts → parse/claim-helpers.d.ts} +2 -2
- package/lib/{parse-jsdoc-claims.d.ts → parse/jsdoc/parse-jsdoc-claims.d.ts} +2 -2
- package/lib/{parse-jsdoc-claims.js → parse/jsdoc/parse-jsdoc-claims.js} +9 -9
- package/lib/{parse-jsdoc-prose.d.ts → parse/jsdoc/parse-jsdoc-prose.d.ts} +1 -1
- package/lib/{parse-jsdoc-prose.js → parse/jsdoc/parse-jsdoc-prose.js} +1 -1
- package/lib/{parse-markdown-claims.d.ts → parse/markdown/parse-markdown-claims.d.ts} +3 -3
- package/lib/{parse-markdown-claims.js → parse/markdown/parse-markdown-claims.js} +8 -8
- package/lib/{parse-markdown-directives.d.ts → parse/markdown/parse-markdown-directives.d.ts} +2 -2
- package/lib/{parse-markdown-directives.js → parse/markdown/parse-markdown-directives.js} +3 -3
- package/lib/{parse-claims.d.ts → parse/parse-claims.d.ts} +4 -13
- package/lib/{parse-claims.js → parse/parse-claims.js} +18 -26
- package/lib/{parse-claims.types.d.ts → parse/parse-claims.types.d.ts} +1 -1
- package/lib/{tagged-fenced-block-error.d.ts → parse/tagged-fenced/tagged-fenced-block-error.d.ts} +2 -2
- package/lib/{tagged-fenced-block-parser.d.ts → parse/tagged-fenced/tagged-fenced-block-parser.d.ts} +3 -3
- package/lib/{tagged-fenced-blocks.d.ts → parse/tagged-fenced/tagged-fenced-blocks.d.ts} +7 -7
- package/lib/{tagged-fenced-blocks.js → parse/tagged-fenced/tagged-fenced-blocks.js} +3 -3
- package/lib/{parse-yaml-claims.d.ts → parse/yaml/parse-yaml-claims.d.ts} +4 -4
- package/lib/{parse-yaml-claims.js → parse/yaml/parse-yaml-claims.js} +22 -13
- package/lib/patram.d.ts +29 -28
- package/lib/patram.js +5 -6
- package/lib/{discover-fields.js → scan/discover-fields.js} +145 -18
- package/lib/scan/list-repo-files.d.ts +16 -0
- package/lib/{list-source-files.js → scan/list-repo-files.js} +2 -35
- package/lib/{list-source-files.d.ts → scan/list-source-files.d.ts} +4 -11
- package/lib/scan/list-source-files.js +45 -0
- package/package.json +8 -7
- package/lib/build-graph.types.ts +0 -27
- package/lib/discover-fields.types.ts +0 -52
- package/lib/load-patram-config.js +0 -1215
- package/lib/load-patram-config.types.d.ts +0 -45
- package/lib/load-patram-config.types.ts +0 -56
- package/lib/output-view.types.d.ts +0 -88
- package/lib/output-view.types.ts +0 -113
- package/lib/overlay-graph.d.ts +0 -43
- package/lib/overlay-graph.js +0 -191
- package/lib/parse-claims.types.ts +0 -41
- package/lib/parse-cli-arguments.types.ts +0 -75
- package/lib/parse-where-clause.types.ts +0 -87
- package/lib/patram-cli.js +0 -593
- package/lib/patram-config.types.ts +0 -22
- package/lib/tagged-fenced-blocks.types.ts +0 -38
- /package/lib/{reverse-reference-test-helpers.js → graph/reverse-reference-test-helpers.js} +0 -0
- /package/lib/{format-derived-summary-row.js → output/format-derived-summary-row.js} +0 -0
- /package/lib/{format-node-header.js → output/format-node-header.js} +0 -0
- /package/lib/{format-output-item-block.js → output/format-output-item-block.js} +0 -0
- /package/lib/{format-output-metadata.js → output/format-output-metadata.js} +0 -0
- /package/lib/{claim-helpers.js → parse/claim-helpers.js} +0 -0
- /package/lib/{parse-jsdoc-blocks.d.ts → parse/jsdoc/parse-jsdoc-blocks.d.ts} +0 -0
- /package/lib/{parse-jsdoc-blocks.js → parse/jsdoc/parse-jsdoc-blocks.js} +0 -0
- /package/lib/{tagged-fenced-block-error.js → parse/tagged-fenced/tagged-fenced-block-error.js} +0 -0
- /package/lib/{tagged-fenced-block-markdown.d.ts → parse/tagged-fenced/tagged-fenced-block-markdown.d.ts} +0 -0
- /package/lib/{tagged-fenced-block-markdown.js → parse/tagged-fenced/tagged-fenced-block-markdown.js} +0 -0
- /package/lib/{tagged-fenced-block-metadata.d.ts → parse/tagged-fenced/tagged-fenced-block-metadata.d.ts} +0 -0
- /package/lib/{tagged-fenced-block-metadata.js → parse/tagged-fenced/tagged-fenced-block-metadata.js} +0 -0
- /package/lib/{tagged-fenced-block-parser.js → parse/tagged-fenced/tagged-fenced-block-parser.js} +0 -0
- /package/lib/{tagged-fenced-blocks.types.d.ts → parse/tagged-fenced/tagged-fenced-blocks.types.d.ts} +0 -0
|
@@ -1,37 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { BuildGraphResult, GraphNode } from '
|
|
3
|
-
* @import { DerivedSummaryEvaluator } from '
|
|
4
|
-
* @import { PatramRepoConfig } from '
|
|
5
|
-
* @import {
|
|
6
|
-
* @import { OutputDerivedSummary, OutputMetadataField, OutputNodeItem, OutputResolvedLinkItem, OutputResolvedLinkTarget, OutputStoredQueryItem, OutputView, RefsOutputView, ResolvedOutputMode, ShowOutputView } from './output-view.types.ts';
|
|
2
|
+
* @import { BuildGraphResult, GraphNode } from '../../graph/build-graph.types.ts';
|
|
3
|
+
* @import { DerivedSummaryEvaluator } from '../derived-summary.js';
|
|
4
|
+
* @import { PatramRepoConfig } from '../../config/load-patram-config.types.ts';
|
|
5
|
+
* @import { OutputDerivedSummary, OutputMetadataField, OutputNodeItem, OutputResolvedLinkItem, OutputResolvedLinkTarget, OutputStoredQueryItem, OutputView, RefsOutputView, ShowOutputView } from '../output-view.types.ts';
|
|
7
6
|
*/
|
|
8
7
|
/* eslint-disable max-lines */
|
|
9
8
|
|
|
10
|
-
import {
|
|
11
|
-
import { renderPlainOutput } from './render-plain-output.js';
|
|
12
|
-
import { renderRichOutput } from './render-rich-output.js';
|
|
13
|
-
import { resolveDocumentNodeId } from './build-graph-identity.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Shared command output views.
|
|
17
|
-
*
|
|
18
|
-
* Normalizes `query`, `queries`, and `show` results into renderer-specific
|
|
19
|
-
* output models.
|
|
20
|
-
*
|
|
21
|
-
* Kind: output
|
|
22
|
-
* Status: active
|
|
23
|
-
* Tracked in: ../docs/plans/v0/source-anchor-dogfooding.md
|
|
24
|
-
* Decided by: ../docs/decisions/cli-output-architecture.md
|
|
25
|
-
* @patram
|
|
26
|
-
* @see {@link ./show-document.js}
|
|
27
|
-
* @see {@link ../docs/decisions/cli-output-architecture.md}
|
|
28
|
-
*/
|
|
9
|
+
import { resolveDocumentNodeId } from '../../graph/build-graph-identity.js';
|
|
29
10
|
|
|
30
11
|
/**
|
|
31
12
|
* Create a shared output view from one command result.
|
|
32
13
|
*
|
|
33
14
|
* @param {'query' | 'queries'} command_name
|
|
34
|
-
* @param {GraphNode[] | { name: string, where: string }[]} command_items
|
|
15
|
+
* @param {GraphNode[] | { name: string, where: string, description?: string }[]} command_items
|
|
35
16
|
* @param {{ derived_summary_evaluator?: DerivedSummaryEvaluator, hints?: string[], limit?: number, offset?: number, repo_config?: PatramRepoConfig, total_count?: number }=} command_options
|
|
36
17
|
* @returns {OutputView}
|
|
37
18
|
*/
|
|
@@ -49,7 +30,7 @@ export function createOutputView(command_name, command_items, command_options) {
|
|
|
49
30
|
);
|
|
50
31
|
}
|
|
51
32
|
|
|
52
|
-
throw new Error(
|
|
33
|
+
throw new Error('Unsupported output view command.');
|
|
53
34
|
}
|
|
54
35
|
|
|
55
36
|
/**
|
|
@@ -60,23 +41,8 @@ export function createOutputView(command_name, command_items, command_options) {
|
|
|
60
41
|
* @returns {ShowOutputView}
|
|
61
42
|
*/
|
|
62
43
|
export function createShowOutputView(show_output, command_options = {}) {
|
|
63
|
-
const shown_document_node = resolveDocumentGraphNode(
|
|
64
|
-
command_options.graph_nodes,
|
|
65
|
-
command_options.document_node_ids,
|
|
66
|
-
show_output.path,
|
|
67
|
-
);
|
|
68
|
-
|
|
69
44
|
return {
|
|
70
45
|
command: 'show',
|
|
71
|
-
document: shown_document_node
|
|
72
|
-
? createOutputNodeItem(
|
|
73
|
-
shown_document_node,
|
|
74
|
-
command_options.derived_summary_evaluator?.evaluate(
|
|
75
|
-
shown_document_node,
|
|
76
|
-
) ?? null,
|
|
77
|
-
command_options.repo_config?.fields ?? {},
|
|
78
|
-
)
|
|
79
|
-
: undefined,
|
|
80
46
|
hints: [],
|
|
81
47
|
incoming_summary: show_output.incoming_summary,
|
|
82
48
|
items: show_output.resolved_links.map((resolved_link) =>
|
|
@@ -132,33 +98,6 @@ export function createRefsOutputView(refs_output, command_options = {}) {
|
|
|
132
98
|
};
|
|
133
99
|
}
|
|
134
100
|
|
|
135
|
-
/**
|
|
136
|
-
* Render one shared output view through the resolved renderer.
|
|
137
|
-
*
|
|
138
|
-
* @param {OutputView} output_view
|
|
139
|
-
* @param {ResolvedOutputMode} output_mode
|
|
140
|
-
* @param {ParsedCliArguments} parsed_arguments
|
|
141
|
-
* @returns {Promise<string>}
|
|
142
|
-
*/
|
|
143
|
-
export async function renderOutputView(
|
|
144
|
-
output_view,
|
|
145
|
-
output_mode,
|
|
146
|
-
parsed_arguments,
|
|
147
|
-
) {
|
|
148
|
-
if (output_mode.renderer_name === 'json') {
|
|
149
|
-
return renderJsonOutput(output_view);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (output_mode.renderer_name === 'plain') {
|
|
153
|
-
return renderPlainOutput(output_view);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return renderRichOutput(output_view, {
|
|
157
|
-
color_enabled: output_mode.color_enabled,
|
|
158
|
-
color_mode: parsed_arguments.color_mode,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
101
|
/**
|
|
163
102
|
* @param {GraphNode[]} graph_nodes
|
|
164
103
|
* @param {{ derived_summary_evaluator?: DerivedSummaryEvaluator, hints?: string[], limit?: number, offset?: number, repo_config?: PatramRepoConfig, total_count?: number }=} command_options
|
|
@@ -190,17 +129,19 @@ function createQueryOutputView(graph_nodes, command_options = {}) {
|
|
|
190
129
|
}
|
|
191
130
|
|
|
192
131
|
/**
|
|
193
|
-
* @param {{ name: string, where: string }[]} stored_queries
|
|
132
|
+
* @param {{ name: string, where: string, description?: string }[]} stored_queries
|
|
194
133
|
* @returns {OutputView}
|
|
195
134
|
*/
|
|
196
135
|
function createStoredQueriesOutputView(stored_queries) {
|
|
197
136
|
return {
|
|
198
137
|
command: 'queries',
|
|
199
|
-
hints:
|
|
138
|
+
hints:
|
|
139
|
+
stored_queries.length === 0 ? [] : ['Hint: patram help query-language'],
|
|
200
140
|
items: stored_queries.map((stored_query) => ({
|
|
201
141
|
kind: 'stored_query',
|
|
202
142
|
name: stored_query.name,
|
|
203
143
|
where: stored_query.where,
|
|
144
|
+
description: stored_query.description,
|
|
204
145
|
})),
|
|
205
146
|
summary: {
|
|
206
147
|
count: stored_queries.length,
|
|
@@ -42,10 +42,10 @@ async function writeOutputThroughPager(
|
|
|
42
42
|
|
|
43
43
|
await writeToPagerInput(pager_process.stdin, output_text);
|
|
44
44
|
|
|
45
|
-
const [
|
|
46
|
-
close_promise,
|
|
47
|
-
|
|
48
|
-
]
|
|
45
|
+
const pager_result = /** @type {[number | null, NodeJS.Signals | null]} */ (
|
|
46
|
+
await Promise.race([close_promise, error_promise])
|
|
47
|
+
);
|
|
48
|
+
const [exit_code, signal_code] = pager_result;
|
|
49
49
|
|
|
50
50
|
if (exit_code === 0) {
|
|
51
51
|
return;
|
|
@@ -72,7 +72,11 @@ function writeToPagerInput(pager_input, output_text) {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
reject(
|
|
75
|
+
reject(
|
|
76
|
+
error instanceof Error
|
|
77
|
+
? error
|
|
78
|
+
: new Error('Pager input failed with a non-Error rejection.'),
|
|
79
|
+
);
|
|
76
80
|
});
|
|
77
81
|
pager_input.end(output_text, 'utf8', resolve);
|
|
78
82
|
});
|
|
@@ -16,5 +16,5 @@ export function createClaim(file_path: string, claim_number: number, claim_type:
|
|
|
16
16
|
* @returns {string}
|
|
17
17
|
*/
|
|
18
18
|
export function getFileExtension(file_path: string): string;
|
|
19
|
-
import type { PatramClaimFields } from './parse-claims.types.ts';
|
|
20
|
-
import type { PatramClaim } from './parse-claims.types.ts';
|
|
19
|
+
import type { PatramClaimFields } from './parse-claims.types.d.ts';
|
|
20
|
+
import type { PatramClaim } from './parse-claims.types.d.ts';
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @returns {ParseSourceFileResult}
|
|
6
6
|
*/
|
|
7
7
|
export function parseJsdocClaims(parse_input: ParseClaimsInput): ParseSourceFileResult;
|
|
8
|
-
import type { ParseClaimsInput } from '
|
|
9
|
-
import type { ParseSourceFileResult } from '
|
|
8
|
+
import type { ParseClaimsInput } from '../parse-claims.types.d.ts';
|
|
9
|
+
import type { ParseSourceFileResult } from '../parse-claims.types.d.ts';
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { PatramDiagnostic } from '
|
|
3
|
-
* @import { ParseClaimsInput, ParseSourceFileResult, PatramClaimFields } from '
|
|
2
|
+
* @import { PatramDiagnostic } from '../../config/load-patram-config.types.ts';
|
|
3
|
+
* @import { ParseClaimsInput, ParseSourceFileResult, PatramClaimFields } from '../parse-claims.types.ts';
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
createClaim,
|
|
8
8
|
getFileExtension,
|
|
9
9
|
isPathLikeTarget,
|
|
10
|
-
} from '
|
|
11
|
-
import { normalizeDirectiveName } from '
|
|
10
|
+
} from '../claim-helpers.js';
|
|
11
|
+
import { normalizeDirectiveName } from '../markdown/parse-markdown-directives.js';
|
|
12
12
|
import { collectJsdocBlocks } from './parse-jsdoc-blocks.js';
|
|
13
13
|
import {
|
|
14
14
|
createJsdocProseClaimEntries,
|
|
15
15
|
pushJsdocParagraph,
|
|
16
16
|
} from './parse-jsdoc-prose.js';
|
|
17
|
-
import { JSDOC_SOURCE_FILE_EXTENSIONS } from '
|
|
17
|
+
import { JSDOC_SOURCE_FILE_EXTENSIONS } from '../../config/source-file-defaults.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* JSDoc @patram claim parsing.
|
|
@@ -24,11 +24,11 @@ import { JSDOC_SOURCE_FILE_EXTENSIONS } from './source-file-defaults.js';
|
|
|
24
24
|
*
|
|
25
25
|
* Kind: parse
|
|
26
26
|
* Status: active
|
|
27
|
-
* Tracked in:
|
|
28
|
-
* Decided by:
|
|
27
|
+
* Tracked in: ../../../docs/plans/v0/source-anchor-dogfooding.md
|
|
28
|
+
* Decided by: ../../../docs/decisions/jsdoc-metadata-directive-syntax.md
|
|
29
29
|
* @patram
|
|
30
|
-
* @see {@link
|
|
31
|
-
* @see {@link
|
|
30
|
+
* @see {@link ../parse-claims.js}
|
|
31
|
+
* @see {@link ../../../docs/decisions/jsdoc-metadata-directive-syntax.md}
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
const JSDOC_EXTENSIONS = new Set(JSDOC_SOURCE_FILE_EXTENSIONS);
|
|
@@ -25,4 +25,4 @@ export function createJsdocProseClaimEntries(file_path: string, prose_paragraphs
|
|
|
25
25
|
claim_type: string;
|
|
26
26
|
order: number;
|
|
27
27
|
}>;
|
|
28
|
-
import type { PatramClaimFields } from '
|
|
28
|
+
import type { PatramClaimFields } from '../parse-claims.types.d.ts';
|
|
@@ -9,6 +9,6 @@ export function parseMarkdownClaims(parse_input: ParseClaimsInput, parse_options
|
|
|
9
9
|
claims: PatramClaim[];
|
|
10
10
|
diagnostics: PatramDiagnostic[];
|
|
11
11
|
};
|
|
12
|
-
import type { ParseClaimsInput } from '
|
|
13
|
-
import type { PatramClaim } from '
|
|
14
|
-
import type { PatramDiagnostic } from '
|
|
12
|
+
import type { ParseClaimsInput } from '../parse-claims.types.d.ts';
|
|
13
|
+
import type { PatramClaim } from '../parse-claims.types.d.ts';
|
|
14
|
+
import type { PatramDiagnostic } from '../../config/load-patram-config.types.d.ts';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { PatramClaim, ParseClaimsInput, PatramClaimFields } from '
|
|
3
|
-
* @import { PatramDiagnostic } from '
|
|
2
|
+
* @import { PatramClaim, ParseClaimsInput, PatramClaimFields } from '../parse-claims.types.ts';
|
|
3
|
+
* @import { PatramDiagnostic } from '../../config/load-patram-config.types.ts';
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createClaim, isPathLikeTarget } from '
|
|
6
|
+
import { createClaim, isPathLikeTarget } from '../claim-helpers.js';
|
|
7
7
|
import {
|
|
8
8
|
matchHiddenDirectiveFields,
|
|
9
9
|
matchVisibleDirectiveFields,
|
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
*
|
|
19
19
|
* Kind: parse
|
|
20
20
|
* Status: active
|
|
21
|
-
* Tracked in:
|
|
22
|
-
* Decided by:
|
|
23
|
-
* Decided by:
|
|
21
|
+
* Tracked in: ../../../docs/plans/v0/source-anchor-dogfooding.md
|
|
22
|
+
* Decided by: ../../../docs/decisions/markdown-metadata-directive-syntax.md
|
|
23
|
+
* Decided by: ../../../docs/decisions/markdown-link-claim-scope.md
|
|
24
24
|
* @patram
|
|
25
|
-
* @see {@link
|
|
26
|
-
* @see {@link
|
|
25
|
+
* @see {@link ../parse-claims.js}
|
|
26
|
+
* @see {@link ../../../docs/decisions/markdown-metadata-directive-syntax.md}
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
const HEADING_PATTERN = /^#\s+(.+)$/du;
|
package/lib/{parse-markdown-directives.d.ts → parse/markdown/parse-markdown-directives.d.ts}
RENAMED
|
@@ -30,5 +30,5 @@ export function matchHiddenDirectiveFields(file_path: string, line: string, line
|
|
|
30
30
|
* @returns {string}
|
|
31
31
|
*/
|
|
32
32
|
export function normalizeDirectiveName(directive_label: string): string;
|
|
33
|
-
import type { PatramDiagnostic } from '
|
|
34
|
-
import type { PatramClaimFields } from '
|
|
33
|
+
import type { PatramDiagnostic } from '../../config/load-patram-config.types.d.ts';
|
|
34
|
+
import type { PatramClaimFields } from '../parse-claims.types.d.ts';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { MarkdownDirectiveStyle, PatramClaimFields } from '
|
|
3
|
-
* @import { PatramDiagnostic } from '
|
|
2
|
+
* @import { MarkdownDirectiveStyle, PatramClaimFields } from '../parse-claims.types.ts';
|
|
3
|
+
* @import { PatramDiagnostic } from '../../config/load-patram-config.types.ts';
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { parseYamlDirectiveFields } from '
|
|
6
|
+
import { parseYamlDirectiveFields } from '../yaml/parse-yaml-claims.js';
|
|
7
7
|
|
|
8
8
|
const FRONT_MATTER_BOUNDARY_PATTERN = /^---$/du;
|
|
9
9
|
const MARKDOWN_HIDDEN_DIRECTIVE_PATTERN =
|
|
@@ -8,16 +8,6 @@
|
|
|
8
8
|
export function parseSourceFile(parse_input: ParseClaimsInput, parse_options?: {
|
|
9
9
|
multi_value_directive_names?: ReadonlySet<string>;
|
|
10
10
|
}): ParseSourceFileResult;
|
|
11
|
-
/**
|
|
12
|
-
* Parse a file into neutral Patram claims.
|
|
13
|
-
*
|
|
14
|
-
* @param {ParseClaimsInput} parse_input
|
|
15
|
-
* @param {{ multi_value_directive_names?: ReadonlySet<string> }} [parse_options]
|
|
16
|
-
* @returns {PatramClaim[]}
|
|
17
|
-
*/
|
|
18
|
-
export function parseClaims(parse_input: ParseClaimsInput, parse_options?: {
|
|
19
|
-
multi_value_directive_names?: ReadonlySet<string>;
|
|
20
|
-
}): PatramClaim[];
|
|
21
11
|
/**
|
|
22
12
|
* Build parser options from repo config.
|
|
23
13
|
*
|
|
@@ -35,6 +25,7 @@ export function createParseOptions(repo_config: {
|
|
|
35
25
|
} | undefined): {
|
|
36
26
|
multi_value_directive_names: Set<string>;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
export type ClaimOrigin = import("./parse-claims.types.d.ts").ClaimOrigin;
|
|
29
|
+
export type ParseClaimsInput = import("./parse-claims.types.d.ts").ParseClaimsInput;
|
|
30
|
+
export type ParseSourceFileResult = import("./parse-claims.types.d.ts").ParseSourceFileResult;
|
|
31
|
+
export type PatramClaim = import("./parse-claims.types.d.ts").PatramClaim;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import { ParseClaimsInput, ParseSourceFileResult, PatramClaim } from './parse-claims.types.ts';
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
import { getFileExtension } from './claim-helpers.js';
|
|
6
|
-
import { parseJsdocClaims } from './parse-jsdoc-claims.js';
|
|
7
|
-
import { parseMarkdownClaims } from './parse-markdown-claims.js';
|
|
8
|
-
import { parseYamlClaims } from './parse-yaml-claims.js';
|
|
2
|
+
import { parseJsdocClaims } from './jsdoc/parse-jsdoc-claims.js';
|
|
3
|
+
import { parseMarkdownClaims } from './markdown/parse-markdown-claims.js';
|
|
4
|
+
import { parseYamlClaims } from './yaml/parse-yaml-claims.js';
|
|
9
5
|
import {
|
|
10
6
|
MARKDOWN_SOURCE_FILE_EXTENSIONS,
|
|
11
7
|
YAML_SOURCE_FILE_EXTENSIONS,
|
|
12
|
-
} from '
|
|
8
|
+
} from '../config/source-file-defaults.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import('./parse-claims.types.ts').ClaimOrigin} ClaimOrigin
|
|
12
|
+
* @typedef {import('./parse-claims.types.ts').ParseClaimsInput} ParseClaimsInput
|
|
13
|
+
* @typedef {import('./parse-claims.types.ts').ParseSourceFileResult} ParseSourceFileResult
|
|
14
|
+
* @typedef {import('./parse-claims.types.ts').PatramClaim} PatramClaim
|
|
15
|
+
*/
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Source claim dispatch.
|
|
@@ -19,14 +22,14 @@ import {
|
|
|
19
22
|
*
|
|
20
23
|
* Kind: parse
|
|
21
24
|
* Status: active
|
|
22
|
-
* Uses Term:
|
|
23
|
-
* Uses Term:
|
|
24
|
-
* Tracked in:
|
|
25
|
-
* Decided by:
|
|
26
|
-
* Implements:
|
|
25
|
+
* Uses Term: ../../docs/reference/terms/claim.md
|
|
26
|
+
* Uses Term: ../../docs/reference/terms/document.md
|
|
27
|
+
* Tracked in: ../../docs/plans/v0/source-anchor-dogfooding.md
|
|
28
|
+
* Decided by: ../../docs/decisions/jsdoc-metadata-directive-syntax.md
|
|
29
|
+
* Implements: ../../docs/tasks/v0/parse-claims.md
|
|
27
30
|
* @patram
|
|
28
|
-
* @see {@link ./parse-markdown-claims.js}
|
|
29
|
-
* @see {@link ./parse-jsdoc-claims.js}
|
|
31
|
+
* @see {@link ./markdown/parse-markdown-claims.js}
|
|
32
|
+
* @see {@link ./jsdoc/parse-jsdoc-claims.js}
|
|
30
33
|
*/
|
|
31
34
|
|
|
32
35
|
const MARKDOWN_EXTENSIONS = new Set(MARKDOWN_SOURCE_FILE_EXTENSIONS);
|
|
@@ -53,17 +56,6 @@ export function parseSourceFile(parse_input, parse_options) {
|
|
|
53
56
|
return parseJsdocClaims(parse_input);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
/**
|
|
57
|
-
* Parse a file into neutral Patram claims.
|
|
58
|
-
*
|
|
59
|
-
* @param {ParseClaimsInput} parse_input
|
|
60
|
-
* @param {{ multi_value_directive_names?: ReadonlySet<string> }} [parse_options]
|
|
61
|
-
* @returns {PatramClaim[]}
|
|
62
|
-
*/
|
|
63
|
-
export function parseClaims(parse_input, parse_options) {
|
|
64
|
-
return parseSourceFile(parse_input, parse_options).claims;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
59
|
/**
|
|
68
60
|
* Build parser options from repo config.
|
|
69
61
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PatramDiagnostic } from '
|
|
1
|
+
import type { PatramDiagnostic } from '../config/load-patram-config.types.d.ts';
|
|
2
2
|
export type MarkdownDirectiveStyle = 'front_matter' | 'visible_line' | 'list_item' | 'hidden_tag';
|
|
3
3
|
export interface ParseClaimsInput {
|
|
4
4
|
path: string;
|
package/lib/{tagged-fenced-block-error.d.ts → parse/tagged-fenced/tagged-fenced-block-error.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { TaggedFencedBlockError } from './tagged-fenced-blocks.types.ts';
|
|
2
|
+
* @import { TaggedFencedBlockError } from './tagged-fenced-blocks.types.d.ts';
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* @param {string} code
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* @returns {TaggedFencedBlockError}
|
|
8
8
|
*/
|
|
9
9
|
export function createTaggedFencedBlockError(code: string, message: string): TaggedFencedBlockError;
|
|
10
|
-
import type { TaggedFencedBlockError } from './tagged-fenced-blocks.types.ts';
|
|
10
|
+
import type { TaggedFencedBlockError } from './tagged-fenced-blocks.types.d.ts';
|
package/lib/{tagged-fenced-block-parser.d.ts → parse/tagged-fenced/tagged-fenced-block-parser.d.ts}
RENAMED
|
@@ -56,6 +56,6 @@ export type TaggedBlockScannerState = {
|
|
|
56
56
|
pending_tag_set: PendingTagSet | null;
|
|
57
57
|
title: string;
|
|
58
58
|
};
|
|
59
|
-
import type { TaggedFencedBlocksInput } from './tagged-fenced-blocks.types.ts';
|
|
60
|
-
import type { TaggedFencedBlockFile } from './tagged-fenced-blocks.types.ts';
|
|
61
|
-
import type { TaggedFencedBlock } from './tagged-fenced-blocks.types.ts';
|
|
59
|
+
import type { TaggedFencedBlocksInput } from './tagged-fenced-blocks.types.d.ts';
|
|
60
|
+
import type { TaggedFencedBlockFile } from './tagged-fenced-blocks.types.d.ts';
|
|
61
|
+
import type { TaggedFencedBlock } from './tagged-fenced-blocks.types.d.ts';
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Kind: parse
|
|
8
8
|
* Status: active
|
|
9
|
-
* Tracked in:
|
|
10
|
-
* Decided by:
|
|
9
|
+
* Tracked in: ../../../docs/plans/v0/tagged-fenced-block-extraction.md
|
|
10
|
+
* Decided by: ../../../docs/decisions/tagged-fenced-block-extraction.md
|
|
11
11
|
* @patram
|
|
12
|
-
* @see {@link
|
|
12
|
+
* @see {@link ../../../docs/decisions/tagged-fenced-block-extraction.md}
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
15
|
* @param {TaggedFencedBlocksInput} input
|
|
@@ -33,7 +33,7 @@ export function selectTaggedBlocks(blocks: TaggedFencedBlock[], criteria: Tagged
|
|
|
33
33
|
* @returns {TaggedFencedBlock}
|
|
34
34
|
*/
|
|
35
35
|
export function selectTaggedBlock(blocks: TaggedFencedBlock[], criteria: TaggedFencedBlockCriteria): TaggedFencedBlock;
|
|
36
|
-
import type { TaggedFencedBlocksInput } from './tagged-fenced-blocks.types.ts';
|
|
37
|
-
import type { TaggedFencedBlockFile } from './tagged-fenced-blocks.types.ts';
|
|
38
|
-
import type { TaggedFencedBlock } from './tagged-fenced-blocks.types.ts';
|
|
39
|
-
import type { TaggedFencedBlockCriteria } from './tagged-fenced-blocks.types.ts';
|
|
36
|
+
import type { TaggedFencedBlocksInput } from './tagged-fenced-blocks.types.d.ts';
|
|
37
|
+
import type { TaggedFencedBlockFile } from './tagged-fenced-blocks.types.d.ts';
|
|
38
|
+
import type { TaggedFencedBlock } from './tagged-fenced-blocks.types.d.ts';
|
|
39
|
+
import type { TaggedFencedBlockCriteria } from './tagged-fenced-blocks.types.d.ts';
|
|
@@ -20,10 +20,10 @@ import { extractTaggedFencedBlocksFromSource } from './tagged-fenced-block-parse
|
|
|
20
20
|
*
|
|
21
21
|
* Kind: parse
|
|
22
22
|
* Status: active
|
|
23
|
-
* Tracked in:
|
|
24
|
-
* Decided by:
|
|
23
|
+
* Tracked in: ../../../docs/plans/v0/tagged-fenced-block-extraction.md
|
|
24
|
+
* Decided by: ../../../docs/decisions/tagged-fenced-block-extraction.md
|
|
25
25
|
* @patram
|
|
26
|
-
* @see {@link
|
|
26
|
+
* @see {@link ../../../docs/decisions/tagged-fenced-block-extraction.md}
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -32,7 +32,7 @@ export function parseYamlDirectiveFields(parse_input: {
|
|
|
32
32
|
diagnostics: PatramDiagnostic[];
|
|
33
33
|
directive_fields: PatramClaimFields[];
|
|
34
34
|
};
|
|
35
|
-
import type { ParseClaimsInput } from '
|
|
36
|
-
import type { ParseSourceFileResult } from '
|
|
37
|
-
import type { PatramDiagnostic } from '
|
|
38
|
-
import type { PatramClaimFields } from '
|
|
35
|
+
import type { ParseClaimsInput } from '../parse-claims.types.d.ts';
|
|
36
|
+
import type { ParseSourceFileResult } from '../parse-claims.types.d.ts';
|
|
37
|
+
import type { PatramDiagnostic } from '../../config/load-patram-config.types.d.ts';
|
|
38
|
+
import type { PatramClaimFields } from '../parse-claims.types.d.ts';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/** @import * as yaml from 'yaml'; */
|
|
2
2
|
/* eslint-disable max-lines */
|
|
3
3
|
/**
|
|
4
|
-
* @import { PatramDiagnostic } from '
|
|
5
|
-
* @import { ParseClaimsInput, ParseSourceFileResult, PatramClaimFields } from '
|
|
4
|
+
* @import { PatramDiagnostic } from '../../config/load-patram-config.types.ts';
|
|
5
|
+
* @import { ParseClaimsInput, ParseSourceFileResult, PatramClaimFields } from '../parse-claims.types.ts';
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { isMap, isScalar, isSeq, LineCounter, parseAllDocuments } from 'yaml';
|
|
9
9
|
|
|
10
|
-
import { createClaim, getFileExtension } from '
|
|
11
|
-
import { YAML_SOURCE_FILE_EXTENSIONS } from '
|
|
10
|
+
import { createClaim, getFileExtension } from '../claim-helpers.js';
|
|
11
|
+
import { YAML_SOURCE_FILE_EXTENSIONS } from '../../config/source-file-defaults.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* YAML claim parsing.
|
|
@@ -18,11 +18,11 @@ import { YAML_SOURCE_FILE_EXTENSIONS } from './source-file-defaults.js';
|
|
|
18
18
|
*
|
|
19
19
|
* Kind: parse
|
|
20
20
|
* Status: active
|
|
21
|
-
* Tracked in:
|
|
22
|
-
* Decided by:
|
|
21
|
+
* Tracked in: ../../../docs/plans/v0/yaml-source-and-front-matter.md
|
|
22
|
+
* Decided by: ../../../docs/decisions/yaml-source-and-front-matter.md
|
|
23
23
|
* @patram
|
|
24
|
-
* @see {@link
|
|
25
|
-
* @see {@link
|
|
24
|
+
* @see {@link ../parse-claims.js}
|
|
25
|
+
* @see {@link ../markdown/parse-markdown-directives.js}
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
const YAML_EXTENSIONS = new Set(YAML_SOURCE_FILE_EXTENSIONS);
|
|
@@ -107,7 +107,7 @@ export function parseYamlDirectiveFields(parse_input) {
|
|
|
107
107
|
* file_path: string,
|
|
108
108
|
* start_line: number,
|
|
109
109
|
* }} parse_input
|
|
110
|
-
* @param {
|
|
110
|
+
* @param {yaml.Document.Parsed[]} yaml_documents
|
|
111
111
|
* @param {LineCounter} line_counter
|
|
112
112
|
* @returns {{
|
|
113
113
|
success: true,
|
|
@@ -221,12 +221,13 @@ function collectDirectiveFields(parse_input, yaml_map, line_counter) {
|
|
|
221
221
|
* markdown_style?: 'front_matter',
|
|
222
222
|
* multi_value_directive_names?: ReadonlySet<string>,
|
|
223
223
|
* }} parse_input
|
|
224
|
-
* @param {
|
|
224
|
+
* @param {yaml.Pair<unknown, unknown>} yaml_pair
|
|
225
225
|
* @param {LineCounter} line_counter
|
|
226
226
|
* @returns {PatramClaimFields[]}
|
|
227
227
|
*/
|
|
228
228
|
function createPairDirectiveFields(parse_input, yaml_pair, line_counter) {
|
|
229
229
|
const directive_name = resolveDirectiveName(yaml_pair.key);
|
|
230
|
+
const key_node = isNodeWithOptionalRange(yaml_pair.key) ? yaml_pair.key : {};
|
|
230
231
|
|
|
231
232
|
if (!directive_name || yaml_pair.value === null) {
|
|
232
233
|
return [];
|
|
@@ -236,7 +237,7 @@ function createPairDirectiveFields(parse_input, yaml_pair, line_counter) {
|
|
|
236
237
|
return createScalarDirectiveFields(
|
|
237
238
|
parse_input,
|
|
238
239
|
directive_name,
|
|
239
|
-
|
|
240
|
+
key_node,
|
|
240
241
|
yaml_pair.value.value,
|
|
241
242
|
line_counter,
|
|
242
243
|
);
|
|
@@ -303,7 +304,7 @@ function createScalarDirectiveFields(
|
|
|
303
304
|
* }} parse_input
|
|
304
305
|
* @param {string} directive_name
|
|
305
306
|
* @param {unknown} yaml_value
|
|
306
|
-
* @returns {boolean}
|
|
307
|
+
* @returns {yaml_value is yaml.YAMLSeq<yaml.Scalar<string | boolean | number>>}
|
|
307
308
|
*/
|
|
308
309
|
function shouldCollectSequence(parse_input, directive_name, yaml_value) {
|
|
309
310
|
return (
|
|
@@ -379,7 +380,15 @@ function normalizeScalarValue(scalar_value) {
|
|
|
379
380
|
|
|
380
381
|
/**
|
|
381
382
|
* @param {unknown} yaml_node
|
|
382
|
-
* @returns {
|
|
383
|
+
* @returns {yaml_node is { range?: [number, number, number] }}
|
|
384
|
+
*/
|
|
385
|
+
function isNodeWithOptionalRange(yaml_node) {
|
|
386
|
+
return typeof yaml_node === 'object' && yaml_node !== null;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* @param {unknown} yaml_node
|
|
391
|
+
* @returns {yaml_node is yaml.Scalar<string | boolean | number>}
|
|
383
392
|
*/
|
|
384
393
|
function isNonNullScalarNode(yaml_node) {
|
|
385
394
|
return isScalar(yaml_node) && normalizeScalarValue(yaml_node.value) !== null;
|