From 98de580429bca62369a5c010c2e4528b8017ddf3 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Tue, 18 May 2021 22:59:38 +0200 Subject: [PATCH] Update markdown documentation --- source/app/metrics/utils.mjs | 10 ++++++---- source/templates/markdown/example.md | 9 ++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/source/app/metrics/utils.mjs b/source/app/metrics/utils.mjs index 3974ce82..e29d0ed8 100644 --- a/source/app/metrics/utils.mjs +++ b/source/app/metrics/utils.mjs @@ -262,12 +262,14 @@ export const svg = { page.on("console", ({_text:text}) => console.debug(`metrics/svg/pdf > puppeteer > ${text}`)) await page.setContent(`
${rendered}
`, {waitUntil:["load", "domcontentloaded", "networkidle2"]}) console.debug("metrics/svg/pdf > loaded svg successfully") + const margins = (Array.isArray(paddings) ? paddings : paddings.split(",")).join(" ") + console.log(`metrics/svg/pdf > margins set to ${margins}`) await page.addStyleTag({ content:` - main { margin: ${(Array.isArray(paddings) ? paddings : paddings.split(",")).join(" ")}; } - main svg { height: 1em; width: 1em; } - ${await fs.readFile(paths.join(__module(import.meta.url), "../../../node_modules", "@primer/css/dist/markdown.css")).catch(_ => "")}${style} - `, + main { margin: ${margins}; } + main svg { height: 1em; width: 1em; } + ${await fs.readFile(paths.join(__module(import.meta.url), "../../../node_modules", "@primer/css/dist/markdown.css")).catch(_ => "")}${style} + `, }) rendered = await page.pdf() //Result diff --git a/source/templates/markdown/example.md b/source/templates/markdown/example.md index 262fe6de..99e03816 100644 --- a/source/templates/markdown/example.md +++ b/source/templates/markdown/example.md @@ -50,9 +50,16 @@ ___ To include SVGs metrics images without creating additional jobs, use the `embed` function: -<%- await embed(`example-isocalendar`, {isocalendar:true, isocalendar_duration:"full-year"}) %> +<%- await embed(`example-isocalendar`, {isocalendar:true, isocalendar_duration:"full-year", config_display:"large"}) %> + +<%- await embed(`example-languages-pdf`, {languages:true, languages_details:"percentage, bytes-size", config_display:"large"}) %> It takes two arguments: - An unique identifier which will be used as filename withing `markdown_cache` folder - Configuration options (see [action.yml](https://github.com/lowlighter/metrics/blob/master/action.yml)) - Tokens options are automatically passed down from your workflow job, do not pass them again + +Note that unlike regular workflow jobs, `embed` function does not have `base` plugin enabled by default. +If you wish to diplay parts of it, they must be explicitely enabled: + +<%- await embed(`example-base-pdf`, {base:"activity, community, repositories"}) %>