graphify-link-docs: RFC, concetti con nome uguale e nodo documento alternativo
Collega i documenti alle RFC che nominano, unisce con archi describes (INFERRED) i concetti che hanno lo stesso nome esatto di un simbolo, e trova il nodo del documento anche quando l'estrazione gli ha dato un id diverso (25 documenti, tra cui DD-026, prima restavano senza archi). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
916d3ab0d8
commit
d57f81c176
3 files changed
+178
-5
No files matched your search
@@ -1,7 +1,10 @@
|
||||
/** Check del collegamento documenti ↔ codice nel grafo: `bun test/unit/graphify-link-docs.test.ts`. */
|
||||
import assert from "node:assert/strict";
|
||||
import {
|
||||
archiConcetti,
|
||||
archiDocumento,
|
||||
archiRfc,
|
||||
estraiRfc,
|
||||
estraiPercorsi,
|
||||
estraiSimboli,
|
||||
idDocumento,
|
||||
@@ -68,4 +71,74 @@ assert.deepEqual(
|
||||
"file non nel grafo",
|
||||
);
|
||||
|
||||
// --- RFC: tutte le forme, anche «8188/8291» ------------------------------------
|
||||
assert.deepEqual([...estraiRfc("cifrata (RFC 8188/8291), poi RFC-8030 e RFC 123")].sort(), [
|
||||
"8030",
|
||||
"8188",
|
||||
"8291",
|
||||
]);
|
||||
const conRfc = {
|
||||
nodes: [
|
||||
{ id: "docs_decisions_dd_026", label: "DD" },
|
||||
{ id: "r8291", label: "RFC-8291" },
|
||||
{ id: "r8030", label: "RFC-8030" },
|
||||
],
|
||||
links: [],
|
||||
};
|
||||
assert.deepEqual(
|
||||
archiRfc(conRfc, "docs/decisions/DD-026.md", "cifrata (RFC 8188/8291)").map((a) => a.target),
|
||||
["r8291"],
|
||||
"solo le RFC che esistono come nodi",
|
||||
);
|
||||
|
||||
// --- concetti: nome esatto e unico, solo dai documenti --------------------------
|
||||
const conc = {
|
||||
nodes: [
|
||||
{
|
||||
id: "c1",
|
||||
label: "mediePagelle()",
|
||||
source_file: "docs/modules/pagelle.md",
|
||||
file_type: "concept",
|
||||
},
|
||||
{
|
||||
id: "k1",
|
||||
label: "mediePagelle()",
|
||||
source_file: "src/lib/pagelle.ts",
|
||||
file_type: "code",
|
||||
_origin: "ast",
|
||||
},
|
||||
{ id: "c2", label: "Altra cosa", source_file: "docs/modules/pagelle.md", file_type: "concept" },
|
||||
{ id: "c3", label: "dup()", source_file: "docs/x.md", file_type: "concept" },
|
||||
{ id: "k2", label: "dup()", source_file: "src/a.ts", file_type: "code", _origin: "ast" },
|
||||
{ id: "k3", label: "dup()", source_file: "src/b.ts", file_type: "code", _origin: "ast" },
|
||||
],
|
||||
links: [],
|
||||
};
|
||||
const ac = archiConcetti(conc);
|
||||
assert.deepEqual(
|
||||
ac.map((a) => [a.source, a.target]),
|
||||
[["c1", "k1"]],
|
||||
"esatto e unico; ambiguo scartato",
|
||||
);
|
||||
assert.equal(ac[0]?.["confidence"], "INFERRED");
|
||||
|
||||
// --- nodo-documento con id diverso da quello derivato dal percorso -------------
|
||||
const altro = {
|
||||
nodes: [
|
||||
{
|
||||
id: "docs_decisions_dd_026_dd_026",
|
||||
label: "DD-026",
|
||||
source_file: "docs/decisions/DD-026.md",
|
||||
file_type: "document",
|
||||
},
|
||||
{ id: "src_lib_rosa", label: "rosa.ts", source_file: "src/lib/rosa.ts", source_location: "L1" },
|
||||
],
|
||||
links: [],
|
||||
};
|
||||
assert.equal(
|
||||
archiDocumento(altro, "docs/decisions/DD-026.md", "src/lib/rosa.ts")[0]?.source,
|
||||
"docs_decisions_dd_026_dd_026",
|
||||
"usa il nodo document del file se l'id derivato non esiste",
|
||||
);
|
||||
|
||||
console.log("graphify-link-docs: ok");
|
||||
Reference in new issue
Block a user