Skip to content

Commit

Permalink
chore: clean up README
Browse files Browse the repository at this point in the history
Remove external references from dictionary info.
  • Loading branch information
Jason3S committed Jan 3, 2025
1 parent 94c55c6 commit 99dcf07
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 625 deletions.
4 changes: 4 additions & 0 deletions scripts/lib/dictionaryInfo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export async function fetchDictionaryInfo(dictURL) {
/** @type {CSpellSettings} */
const cspellExt = extConfigFile.settings;
const isBundle = extractImports(cspellExt).filter((i) => i.startsWith('@cspell/')).length > 2 || undefined;
// Remove package imports from the list of imports.
extConfigFile.settings.import = Array.isArray(extConfigFile.settings.import)
? extConfigFile.settings.import.filter((i) => i.startsWith('./'))
: extConfigFile.settings.import;
const dictionaries = await extractDictionaryInfo(extConfigFile);
const hasEnabledByDefault = dictionaries.some((d) => d.enabled) || undefined;
return {
Expand Down
16 changes: 15 additions & 1 deletion scripts/lib/packageInfoToMarkdown.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function listDictionaryIds(packages) {
const cspell = dict.pkg.cspell ? ' <sup>1</sup>' : '';
const enabled = dict.enabled ? ' <sup>2</sup>' : '';
const locales = dict.locales ? `${dict.locales.sort().join('<br>')}` : '-';
const fileTypes = dict.fileTypes ? `${dict.fileTypes.sort().join('<br>')}` : '-';
const fileTypes = dict.fileTypes ? `${take(4, dict.fileTypes.sort()).join('<br>')}` : '-';
// | Name | Description | Locale | File Type |
md += `| [\`${dict.name}\`](${dict.pkg.dir})${cspell}${enabled} | ${dict.description} | ${locales} | ${fileTypes} |\n`;
}
Expand Down Expand Up @@ -179,3 +179,17 @@ function groupByCategory(packages) {
}
return byCategory;
}

/**
*
* @param {number} n
* @param {string[]} arr
* @returns {string[]}
*/
function take(n, arr) {
const result = arr.slice(0, n);
if (result.length < arr.length) {
result.push('...');
}
return result;
}
Loading

0 comments on commit 99dcf07

Please sign in to comment.