patram 0.8.0 → 0.9.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/{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 +239 -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} +6 -6
- package/lib/cli/main.js +76 -0
- package/lib/{parse-cli-arguments-helpers.js → cli/parse-arguments-helpers.js} +7 -7
- 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} +3 -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} +147 -191
- package/lib/config/schema.js +324 -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/{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 +30 -0
- package/lib/{resolve-where-clause.js → graph/query/resolve.js} +1 -1
- 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} +9 -9
- package/lib/{list-queries.js → output/list-queries.js} +1 -1
- 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} +1 -1
- package/lib/{render-plain-output.js → output/renderers/plain.js} +19 -7
- package/lib/{render-rich-output.js → output/renderers/rich.js} +29 -13
- 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} +6 -52
- 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} +9 -8
- 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,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { CliColorMode } from '
|
|
3
|
-
* @import { OutputNodeItem, OutputResolvedLinkItem, OutputStoredQueryItem, OutputView, QueryOutputView, RefsOutputView, ShowOutputView } from '
|
|
2
|
+
* @import { CliColorMode } from '../../cli/arguments.types.ts';
|
|
3
|
+
* @import { OutputNodeItem, OutputResolvedLinkItem, OutputStoredQueryItem, OutputView, QueryOutputView, RefsOutputView, ShowOutputView } from '../output-view.types.ts';
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { Ansis } from 'ansis';
|
|
@@ -8,13 +8,13 @@ import { Ansis } from 'ansis';
|
|
|
8
8
|
import {
|
|
9
9
|
formatOutputNodeMetadataRows,
|
|
10
10
|
formatResolvedLinkMetadataRows,
|
|
11
|
-
} from '
|
|
12
|
-
import { formatNodeHeader } from '
|
|
13
|
-
import { formatOutputItemBlock } from '
|
|
14
|
-
import { layoutIncomingReferenceLines } from '
|
|
15
|
-
import { layoutIncomingSummaryLines } from '
|
|
16
|
-
import { layoutStoredQueries } from '
|
|
17
|
-
import { renderRichSource } from '
|
|
11
|
+
} from '../format-output-metadata.js';
|
|
12
|
+
import { formatNodeHeader } from '../format-node-header.js';
|
|
13
|
+
import { formatOutputItemBlock } from '../format-output-item-block.js';
|
|
14
|
+
import { layoutIncomingReferenceLines } from '../layout-incoming-references.js';
|
|
15
|
+
import { layoutIncomingSummaryLines } from '../layout-incoming-summary-lines.js';
|
|
16
|
+
import { layoutStoredQueries } from '../layout-stored-queries.js';
|
|
17
|
+
import { renderRichSource } from '../rich-source/render.js';
|
|
18
18
|
|
|
19
19
|
const FULL_WIDTH_DIVIDER = ` ${'─'.repeat(78)} `;
|
|
20
20
|
|
|
@@ -112,6 +112,14 @@ async function renderRichShowOutput(output_view, render_options, ansi) {
|
|
|
112
112
|
: '';
|
|
113
113
|
const incoming_summary = renderRichIncomingSummary(output_view, ansi);
|
|
114
114
|
|
|
115
|
+
if (
|
|
116
|
+
document_summary.length === 0 &&
|
|
117
|
+
output_view.items.length === 0 &&
|
|
118
|
+
incoming_summary.length === 0
|
|
119
|
+
) {
|
|
120
|
+
return `${rendered_source}\n`;
|
|
121
|
+
}
|
|
122
|
+
|
|
115
123
|
/** @type {string[]} */
|
|
116
124
|
const summary_items = [];
|
|
117
125
|
|
|
@@ -195,18 +203,26 @@ function formatRichResolvedLinkItem(output_item, ansi) {
|
|
|
195
203
|
* @returns {string}
|
|
196
204
|
*/
|
|
197
205
|
function renderRichIncomingSummary(output_view, ansi) {
|
|
206
|
+
if (!hasIncomingSummary(output_view.incoming_summary)) {
|
|
207
|
+
return '';
|
|
208
|
+
}
|
|
209
|
+
|
|
198
210
|
const output_lines = layoutIncomingSummaryLines(output_view.incoming_summary);
|
|
199
211
|
output_lines[0] = ansi.bold(output_lines[0]);
|
|
200
212
|
|
|
201
|
-
if (Object.keys(output_view.incoming_summary).length === 0) {
|
|
202
|
-
output_lines[1] = ` ${ansi.gray('none')}`;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
213
|
output_lines.push('', ansi.gray(`Hint: patram refs ${output_view.path}`));
|
|
206
214
|
|
|
207
215
|
return output_lines.join('\n');
|
|
208
216
|
}
|
|
209
217
|
|
|
218
|
+
/**
|
|
219
|
+
* @param {Record<string, number>} incoming_summary
|
|
220
|
+
* @returns {boolean}
|
|
221
|
+
*/
|
|
222
|
+
function hasIncomingSummary(incoming_summary) {
|
|
223
|
+
return Object.keys(incoming_summary).length > 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
210
226
|
/**
|
|
211
227
|
* @param {boolean} color_enabled
|
|
212
228
|
* @returns {Ansis}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @import { ComarkElement, ComarkNode } from 'md4x';
|
|
4
4
|
* @import { BundledLanguage } from 'shiki';
|
|
5
|
-
* @import { CliColorMode } from '
|
|
6
|
-
* @import { OutputResolvedLinkItem, ShowOutputView } from '
|
|
5
|
+
* @import { CliColorMode } from '../../cli/arguments.types.ts';
|
|
6
|
+
* @import { OutputResolvedLinkItem, ShowOutputView } from '../output-view.types.ts';
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { extname } from 'node:path';
|
|
@@ -969,8 +969,8 @@ function shouldRenderListItemGap(previous_item, next_item, has_blank_line_gap) {
|
|
|
969
969
|
}
|
|
970
970
|
|
|
971
971
|
return (
|
|
972
|
-
|
|
973
|
-
|
|
972
|
+
isSingleParagraphTopLevelListItem(previous_item) &&
|
|
973
|
+
isSingleParagraphTopLevelListItem(next_item)
|
|
974
974
|
);
|
|
975
975
|
}
|
|
976
976
|
|
|
@@ -978,7 +978,7 @@ function shouldRenderListItemGap(previous_item, next_item, has_blank_line_gap) {
|
|
|
978
978
|
* @param {ComarkElement} item_node
|
|
979
979
|
* @returns {boolean}
|
|
980
980
|
*/
|
|
981
|
-
function
|
|
981
|
+
function isSingleParagraphTopLevelListItem(item_node) {
|
|
982
982
|
const item_children = getElementChildren(item_node);
|
|
983
983
|
|
|
984
984
|
if (item_children.length !== 1) {
|
|
@@ -994,7 +994,7 @@ function isSimpleTopLevelListItem(item_node) {
|
|
|
994
994
|
return false;
|
|
995
995
|
}
|
|
996
996
|
|
|
997
|
-
return
|
|
997
|
+
return true;
|
|
998
998
|
}
|
|
999
999
|
|
|
1000
1000
|
/**
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
/**
|
|
3
|
-
* @import { BuildGraphResult, GraphNode } from '
|
|
4
|
-
* @import { PatramClaim } from '
|
|
5
|
-
* @import { PatramDiagnostic } from '
|
|
3
|
+
* @import { BuildGraphResult, GraphNode } from '../graph/build-graph.types.ts';
|
|
4
|
+
* @import { PatramClaim } from '../parse/parse-claims.types.ts';
|
|
5
|
+
* @import { PatramDiagnostic } from '../config/load-patram-config.types.ts';
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { readFile } from 'node:fs/promises';
|
|
9
9
|
import { posix, relative, resolve } from 'node:path';
|
|
10
10
|
|
|
11
|
-
import { resolveDocumentNodeId } from '
|
|
12
|
-
import { inspectReverseReferences } from '
|
|
13
|
-
import { parseSourceFile } from '
|
|
11
|
+
import { resolveDocumentNodeId } from '../graph/build-graph-identity.js';
|
|
12
|
+
import { inspectReverseReferences } from '../graph/inspect-reverse-references.js';
|
|
13
|
+
import { parseSourceFile } from '../parse/parse-claims.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Show command document rendering.
|
|
@@ -20,12 +20,12 @@ import { parseSourceFile } from './parse-claims.js';
|
|
|
20
20
|
*
|
|
21
21
|
* Kind: output
|
|
22
22
|
* Status: active
|
|
23
|
-
* Tracked in:
|
|
24
|
-
* Decided by:
|
|
25
|
-
* Decided by:
|
|
23
|
+
* Tracked in: ../../docs/plans/v0/source-anchor-dogfooding.md
|
|
24
|
+
* Decided by: ../../docs/decisions/show-output.md
|
|
25
|
+
* Decided by: ../../docs/decisions/source-rendering.md
|
|
26
26
|
* @patram
|
|
27
27
|
* @see {@link ./render-output-view.js}
|
|
28
|
-
* @see {@link
|
|
28
|
+
* @see {@link ../../docs/decisions/show-output.md}
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -107,7 +107,7 @@ export async function loadShowOutput(
|
|
|
107
107
|
* @param {string} source_text
|
|
108
108
|
* @param {PatramClaim[]} claims
|
|
109
109
|
* @param {BuildGraphResult} graph
|
|
110
|
-
* @param {import('
|
|
110
|
+
* @param {import('../graph/build-graph.types.ts').BuildGraphResult['document_node_ids']} document_node_ids
|
|
111
111
|
* @param {Record<string, GraphNode>} graph_nodes
|
|
112
112
|
* @returns {{ incoming_summary: Record<string, number>, path: string, rendered_source: string, resolved_links: Array<{ label: string, reference: number, target: { kind?: string, path: string, status?: string, title: string } }>, source: string }}
|
|
113
113
|
*/
|
|
@@ -219,7 +219,7 @@ function renderResolvedSourceLine(
|
|
|
219
219
|
* @param {string} source_file_path
|
|
220
220
|
* @param {PatramClaim} claim
|
|
221
221
|
* @param {number} reference
|
|
222
|
-
* @param {import('
|
|
222
|
+
* @param {import('../graph/build-graph.types.ts').BuildGraphResult['document_node_ids']} document_node_ids
|
|
223
223
|
* @param {Record<string, GraphNode>} graph_nodes
|
|
224
224
|
* @returns {{ label: string, reference: number, target: { kind?: string, path: string, status?: string, title: string } }}
|
|
225
225
|
*/
|
|
@@ -1,31 +1,12 @@
|
|
|
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.
|
|
@@ -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
|
/**
|
|
@@ -132,33 +113,6 @@ export function createRefsOutputView(refs_output, command_options = {}) {
|
|
|
132
113
|
};
|
|
133
114
|
}
|
|
134
115
|
|
|
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
116
|
/**
|
|
163
117
|
* @param {GraphNode[]} graph_nodes
|
|
164
118
|
* @param {{ derived_summary_evaluator?: DerivedSummaryEvaluator, hints?: string[], limit?: number, offset?: number, repo_config?: PatramRepoConfig, total_count?: number }=} command_options
|
|
@@ -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';
|