chore(glossaire): aligner l'audit des paths sur les defaults
All checks were successful
SMOKE / smoke (push) Successful in 5s
CI / build-and-anchors (push) Successful in 46s
CI / build-and-anchors (pull_request) Successful in 38s

This commit is contained in:
2026-04-30 09:24:39 +02:00
parent d4df080f1d
commit 7910a3964a

View File

@@ -9,8 +9,24 @@ const HUB_LIMIT = 5;
const defaultsRaw = fs.readFileSync(DEFAULTS_FILE, "utf-8");
const defaultFamilies = new Set(
[...defaultsRaw.matchAll(/^\s{4}"?([a-z0-9-]+)"?\s*:/gm)].map((m) => m[1]),
);
[...defaultsRaw.matchAll(/^\s{4}"?([a-z0-9-]+)"?\s*:/gm)].map((m) => m[1]),
);
const defaultPathKeysByFamily = new Map();
for (const match of defaultsRaw.matchAll(/^\s{4}"?([a-z0-9-]+)"?\s*:\s*\{([\s\S]*?)^\s{4}\},/gm)) {
const family = match[1];
const body = match[2];
const keys = new Set();
for (const key of ["understand", "deepen", "compare", "apply"]) {
if (new RegExp(`\\b${key}\\s*:\\s*\\[[^\\]]+\\]`).test(body)) {
keys.add(key);
}
}
defaultPathKeysByFamily.set(family, keys);
}
const files = fs.readdirSync(ROOT).filter((f) => f.endsWith(".md"));
const slugs = new Set(files.map((f) => f.replace(".md", "")));
@@ -66,10 +82,14 @@ for (const { slug, data, noFrontmatter } of entries) {
if (!nav.primaryReason) missingReason.push(slug);
}
const paths = nav.paths || {};
const pathCount = ["understand", "deepen", "compare", "apply"].filter(
(key) => Array.isArray(paths[key]) && paths[key].length > 0,
).length;
const explicitPaths = nav.paths || {};
const familyDefaults = defaultPathKeysByFamily.get(data.family) || new Set();
const pathCount = ["understand", "deepen", "compare", "apply"].filter((key) => {
const explicit = Array.isArray(explicitPaths[key]) && explicitPaths[key].length > 0;
const fromDefault = familyDefaults.has(key);
return explicit || fromDefault;
}).length;
if (pathCount < 2) weakPaths.push(slug);
}