chore(glossaire): aligner l'audit des paths sur les defaults
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user