From 9c4315e1e2ed6ff519317aacdb1c5458b9075854 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Fri, 14 Jan 2022 22:12:03 -0500 Subject: [PATCH] ci: update documentation builder [skip ci] --- .github/scripts/build.mjs | 4 ++- source/app/metrics/metadata.mjs | 46 ++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/scripts/build.mjs b/.github/scripts/build.mjs index 2f2e69ec..cfdf27d5 100644 --- a/.github/scripts/build.mjs +++ b/.github/scripts/build.mjs @@ -63,10 +63,11 @@ for (const id of Object.keys(plugins)) { //Templates for (const id of Object.keys(templates)) { - const {examples, readme, tests} = await template(id) + const {examples, readme, tests, header} = await template(id) //Readme await fs.writeFile(readme.path, readme.content + .replace(/()[\s\S]*()/g, `$1\n${header}\n$2`) .replace(/()[\s\S]*()/g, `$1\n${examples.map(({test, prod, ...step}) => ["```yaml", yaml.dump(step), "```"].join("\n")).join("\n")}\n$2`) ) console.log(`Generating source/templates/${id}/README.md`) @@ -139,6 +140,7 @@ async function template(id) { path:tests }, examples:fss.existsSync(examples) ? yaml.load(await fs.readFile(examples), "utf8") ?? [] : [], + header:templates[id].readme.header } } diff --git a/source/app/metrics/metadata.mjs b/source/app/metrics/metadata.mjs index d9998766..9a937f0a 100644 --- a/source/app/metrics/metadata.mjs +++ b/source/app/metrics/metadata.mjs @@ -382,9 +382,52 @@ metadata.template = async function({__templates, name, plugins, logger}) { } } + //Header table + const header = [ + "
${meta.name ?? "(unnamed template)"} | |
|---|---|
| ${(meta.description ?? "").replaceAll("\n", " ")} | |
| Supported features → Full specification | `,
+ ` ${Object.entries(compatibility).filter(([_, value]) => value).map(([id]) => `${plugins[id].icon}`).join(" ")} | `, + `
| ${[ + meta.supports?.includes("user") ? "👤 Users" : "", + meta.supports?.includes("organization") ? "👥 Organizations" : "", + meta.supports?.includes("repository") ? "📓 Repositories" : "" + ].filter(v => v).join(", ")} | `, + `|
| ${[ + meta.formats?.includes("svg") ? "*️⃣ SVG" : "", + meta.formats?.includes("png") ? "*️⃣ PNG" : "", + meta.formats?.includes("jpeg") ? "*️⃣ JPEG" : "", + meta.formats?.includes("json") ? "#️⃣ JSON" : "", + meta.formats?.includes("markdown") ? "🔠 Markdown" : "", + meta.formats?.includes("markdown-pdf") ? "🔠 Markdown (PDF)" : "", + ].filter(v => v).join(", ")} | `, + `|
`,
+ `${Object.entries(meta.examples ?? {}).map(([text, link]) => {
+ let img = `${open ? text.substring(1) : text}${img} | `,
+ ` |