Automatically build supported language list and SSxx selectors
This commit is contained in:
parent
b52d32e80b
commit
89f3a92f81
7 changed files with 247 additions and 104 deletions
|
@ -1,9 +1,10 @@
|
|||
const ejs = require("ejs");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const parseVariantsData = require("../generate-snapshot-page/parse-variants-data");
|
||||
const parseLigationData = require("../generate-snapshot-page/ligation-data");
|
||||
const getSupportedLanguageList = require("../generate-supported-languages/proc");
|
||||
|
||||
const charMapPath = process.argv[2];
|
||||
main().catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
|
@ -14,16 +15,28 @@ async function main() {
|
|||
const readmePath = path.resolve(__dirname, "../../README.md");
|
||||
let readme = await fs.readFile(readmePath, "utf-8");
|
||||
readme = (await processCv()).apply(readme);
|
||||
readme = (await processSs()).apply(readme);
|
||||
readme = (await processLigSetCherryPicking()).apply(readme);
|
||||
readme = (await processLigSetPreDef()).apply(readme);
|
||||
readme = (await processLangList()).apply(readme);
|
||||
await fs.writeFile(readmePath, readme);
|
||||
}
|
||||
|
||||
async function processSs() {
|
||||
const variantsData = await parseVariantsData();
|
||||
const md = new MdCol("Section-Stylistic-Sets");
|
||||
md.log(`* Styles as stylistic sets:\n`);
|
||||
for (const gr of variantsData.ssData) {
|
||||
if (!gr.effective) continue;
|
||||
md.log(` * \`${gr.tag}\`: Set character variant to “${gr.description}”.`);
|
||||
}
|
||||
return md;
|
||||
}
|
||||
async function processCv() {
|
||||
const variantsData = await parseVariantsData();
|
||||
const md = new MdCol("Section-Cherry-Picking-Styles");
|
||||
md.log(
|
||||
`* Styles for individual characters. They are easy-to-understand names of the \`cv##\` styles, including:`
|
||||
`* Styles for individual characters. They are easy-to-understand names of the \`cv##\` styles, including:\n`
|
||||
);
|
||||
for (const gr of variantsData.cvData) {
|
||||
md.log(` * Styles for ${gr.descSampleText.map(c => `\`${c}\``).join(", ")}:`);
|
||||
|
@ -31,7 +44,7 @@ async function processCv() {
|
|||
for (const config of gr.configs) {
|
||||
const tag = config.tag || config.tagItalic;
|
||||
md.log(
|
||||
` * \`${config.selector}\` (\`${tag}\`): ` +
|
||||
` * \`${config.selector}\`, \`${tag}\`: ` +
|
||||
`${config.description}${formatDefaults(config.selector, defaults)}.`
|
||||
);
|
||||
}
|
||||
|
@ -127,7 +140,7 @@ function figureOutDefaults(variantsData, gr) {
|
|||
async function processLigSetCherryPicking() {
|
||||
const ligData = await parseLigationData();
|
||||
const md = new MdCol("Section-Cherry-Picking-Ligation-Sets");
|
||||
md.log(`* Styles for further customizing default (\`calt\`) ligation sets:`);
|
||||
md.log(`* Styles for further customizing default (\`calt\`) ligation sets:\n`);
|
||||
for (const gr in ligData.cherry) {
|
||||
md.log(` * \`${gr}\`: ${ligData.cherry[gr].desc}.`);
|
||||
}
|
||||
|
@ -137,7 +150,7 @@ async function processLigSetCherryPicking() {
|
|||
async function processLigSetPreDef() {
|
||||
const ligData = await parseLigationData();
|
||||
const md = new MdCol("Section-Cherry-Picking-Predefined");
|
||||
md.log(`* Styles for ligation sets, include:`);
|
||||
md.log(`* Styles for ligation sets, include:\n`);
|
||||
for (const gr in ligData.rawSets) {
|
||||
if (ligData.rawSets[gr].disableHives) continue;
|
||||
const longDesc =
|
||||
|
@ -147,3 +160,11 @@ async function processLigSetPreDef() {
|
|||
}
|
||||
return md;
|
||||
}
|
||||
|
||||
async function processLangList() {
|
||||
const langs = await getSupportedLanguageList(charMapPath);
|
||||
const md = new MdCol("Section-Language-List");
|
||||
md.log(`${langs.length} Supported Languages: \n`);
|
||||
md.log(langs.join(", "));
|
||||
return md;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue