Skip to content

Commit 48c1d5c

Browse files
committedJan 14, 2022
ci(docs): add support for option flags
1 parent adc2924 commit 48c1d5c

File tree

15 files changed

+108
-41
lines changed

15 files changed

+108
-41
lines changed
 

‎source/app/metrics/metadata.mjs

+36-10
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ metadata.plugin = async function({__plugins, name, logger}) {
106106
}
107107
//Inputs checks
108108
const result = Object.fromEntries(
109-
Object.entries(inputs).map(([key, {type, format, default:defaulted, min, max, values}]) => [
109+
Object.entries(inputs).map(([key, {type, format, default:defaulted, min, max, values, inherits}]) => [
110110
//Format key
111111
metadata.to.query(key, {name}),
112112
//Format value
@@ -269,25 +269,46 @@ metadata.plugin = async function({__plugins, name, logger}) {
269269
const demo = raw.match(/(?<demo><table>[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? "<td></td>"
270270

271271
//Options table
272+
let flags = new Set()
272273
const table = [
273274
"| Option | Type *(format)* **[default]** *{allowed values}* | Description |",
274275
"| ------ | -------------------------------- | ----------- |",
275276
Object.entries(inputs).map(([option, {description, type, ...o}]) => {
276277
let row = []
277278
{
278-
const cell = [`${"`"}${option}${"`"}`]
279+
let cell = []
280+
if (o.required)
281+
cell.push("✔️"), flags.add("required")
279282
if (type === "token")
280-
cell.push("🔐")
283+
cell.push("🔐"), flags.add("secret")
284+
if (o.inherits)
285+
cell.push("⏩"), flags.add("inherits")
286+
if (o.global)
287+
cell.push("⏭️"), flags.add("global")
288+
if (o.testing)
289+
cell.push("🔧"), flags.add("testing")
281290
if (!Object.keys(previous?.inputs ?? {}).includes(option))
282-
cell.push("✨")
291+
cell.push("✨"), flags.add("beta")
292+
if (o.extras)
293+
cell.push("🧰"), flags.add("extras")
294+
cell = cell.map(flag => `<sup>${flag}</sup>`)
295+
cell.unshift(`${"`"}${option}${"`"}`)
283296
row.push(cell.join(" "))
284297
}
285298
{
286299
const cell = [`${"`"}${type}${"`"}`]
287300
if ("format" in o)
288-
cell.push(`*(${o.format})*`)
289-
if ("default" in o)
290-
cell.push(`**[${o.default}]**`)
301+
cell.push(`*(${Array.isArray(o.format) ? o.format[0] : o.format})*`)
302+
if ("default" in o) {
303+
let text = o.default
304+
if (o.default === ".user.login")
305+
text = "*→ User login*"
306+
if (o.default === ".user.twitter")
307+
text = "*→ User attached twitter*"
308+
if (o.default === ".user.website")
309+
text = "*→ User attached website*"
310+
cell.push(`**[${text}]**`)
311+
}
291312
if ("values" in o)
292313
cell.push(`*{${o.values.map(value => `"${value}"`).join(", ")}}*`)
293314
if ("min" in o)
@@ -302,9 +323,14 @@ metadata.plugin = async function({__plugins, name, logger}) {
302323
return `| ${row.join(" | ")} |`
303324
}).join("\n"),
304325
"\n",
305-
"Legend for option icons:",
306-
"* 🔐 Value should be stored in repository secrets",
307-
"* ✨ New feature currently in testing on `master`/`main`"
326+
flags.size ? "Legend for option icons:" : "",
327+
flags.has("required") ? "* ✔️ Value must be provided" : "",
328+
flags.has("secret") ? "* 🔐 Value should be stored in repository secrets" : "",
329+
flags.has("inherits") ? "* ⏩ Value inherits from its related global-level option" : "",
330+
flags.has("global") ? "* ⏭️ Value be inherited by its related plugin-level option" : "",
331+
flags.has("testing") ? "* 🔧 For development purposes, use with caution" : "",
332+
flags.has("beta") ? "* ✨ Currently in beta-testing on `master`/`main`" : "",
333+
flags.has("extras") ? "* 🧰 Must be enabled in `settings.json` (for web instances)" : "",
308334
].flat(Infinity).filter(s => s).join("\n")
309335

310336
//Readme descriptor

‎source/plugins/activity/metadata.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ inputs:
8888
format: comma-separated
8989
default: ""
9090
example: my-repo-1, my-repo-2, owner/repo-3, ...
91+
inherits: repositories_skipped
9192

9293
# Ignored actors (useful to ignore bots users)
9394
plugin_activity_ignored:
9495
description: Actors to ignore
95-
default: github-actions[bot], dependabot[bot], dependabot-preview[bot]
96+
default: ""
97+
inherits: users_ignored

‎source/plugins/base/metadata.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ inputs:
2929
default: 100
3030
min: 0
3131

32-
3332
# Number of repositories to load at once by queries
3433
# If you encounter GitHub queries timeouts, using a lower value here may solve issues
3534
repositories_batch:
@@ -66,6 +65,16 @@ inputs:
6665
format: comma-separated
6766
default: ""
6867
example: my-repo-1, my-repo-2, owner/repo-3, ...
68+
global: yes
69+
70+
# List of default ignored users
71+
# Plugins supporting a "skip users option" will automatically append users listed in this option
72+
users_ignored:
73+
description: Default users to ignore
74+
type: array
75+
format: comma-separated
76+
default: github-actions[bot], dependabot[bot], dependabot-preview[bot]
77+
global: yes
6978

7079
# List of surnames or email addresses you use when authoring commits
7180
# These are mostly used to perform commits analysis to detect ownership
@@ -75,3 +84,4 @@ inputs:
7584
format: comma-seperated
7685
default: .user.login
7786
example: lowlighter, lowlighter@users.noreply.github.com
87+
global: yes

‎source/plugins/code/metadata.yml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ inputs:
4545
format: comma-separated
4646
default: ""
4747
example: my-repo-1, my-repo-2, owner/repo-3, ...
48+
inherits: repositories_skipped
4849

4950
# Restrict code snippet languages
5051
# These are guessed through linguist

‎source/plugins/contributors/metadata.yml

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ inputs:
3232
type: array
3333
format: comma-separated
3434
default: github-actions[bot], dependabot[bot], dependabot-preview[bot]
35+
inherits: users_ignored
3536

3637
# Display total contributions for each contributor
3738
plugin_contributors_contributions:
@@ -65,3 +66,4 @@ inputs:
6566
"💻 Code": ["source/**", "src/**"],
6667
"#️⃣ Others": ["*"]
6768
}
69+
extras: yes

‎source/plugins/core/examples.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
- name: 📗 Classic template
1+
- name: Classic template
22
uses: lowlighter/metrics@latest
33
with:
44
filename: metrics.classic.svg
55
token: ${{ secrets.METRICS_TOKEN }}
66
base: header, repositories
77
plugin_lines: yes
88

9-
- name: 📘 Repository template
9+
- name: Repository template
1010
uses: lowlighter/metrics@latest
1111
with:
1212
template: repository
@@ -19,15 +19,15 @@
1919
plugin_projects: yes
2020
plugin_projects_repositories: lowlighter/metrics/projects/1
2121

22-
- name: 📙 Terminal template
22+
- name: Terminal template
2323
uses: lowlighter/metrics@latest
2424
with:
2525
template: terminal
2626
filename: metrics.terminal.svg
2727
token: ${{ secrets.METRICS_TOKEN }}
2828
base: header, metadata
2929

30-
- name: 📒 Markdown template
30+
- name: Markdown template
3131
uses: lowlighter/metrics@latest
3232
with:
3333
template: markdown
@@ -36,7 +36,7 @@
3636
config_output: markdown
3737
token: ${{ secrets.METRICS_TOKEN }}
3838

39-
- name: 📒 Markdown template (with plugins)
39+
- name: Markdown template (with plugins)
4040
uses: lowlighter/metrics@latest
4141
with:
4242
template: markdown
@@ -66,7 +66,7 @@
6666
plugin_languages: yes
6767
token: ${{ secrets.METRICS_TOKEN }}
6868

69-
- name: 📒 Markdown template (pdf output)
69+
- name: Markdown template (pdf output)
7070
uses: lowlighter/metrics@latest
7171
with:
7272
template: markdown
@@ -81,7 +81,7 @@
8181
config_padding: 5%
8282
token: ${{ secrets.METRICS_TOKEN }}
8383

84-
- name: 📕 Community templates
84+
- name: Community templates
8585
uses: lowlighter/metrics@latest
8686
with:
8787
token: ${{ secrets.METRICS_TOKEN }}

‎source/plugins/core/metadata.yml

+33-17
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ inputs:
124124
- comma-separated
125125
- /(?<user>[-a-z0-9]+)[/](?<repo>[-a-z0-9]+)@(?<branch>[-a-z0-9]+):(?<template>[-a-z0-9]+)/
126126
default: ""
127+
extras: yes
127128

128129
# Template to use
129130
# To use community template, prefix its name with "@"
@@ -150,13 +151,15 @@ inputs:
150151
description: Extra CSS
151152
type: string
152153
default: ""
154+
extras: yes
153155

154156
# Timezone used by metrics
155157
# See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
156158
config_timezone:
157159
description: Timezone used
158160
type: string
159161
default: ""
162+
global: yes
160163

161164
# Specify in which order metrics content will be displayed
162165
# If you omit some partials, they'll be appended at the end in default order
@@ -167,20 +170,23 @@ inputs:
167170
format: comma-separated
168171
default: ""
169172
example: base.header, base.repositories
173+
global: yes
170174

171175
# Use twemojis instead of emojis
172176
# May increase filesize but emojis will be rendered the same across all platforms
173177
config_twemoji:
174178
description: Use twemojis instead of emojis
175179
type: boolean
176180
default: no
181+
global: yes
177182

178183
# Render GitHub custom emojis (like ":octocat:", see full list at https://api.github.com/emojis)
179184
# May increase filesize
180185
config_gemoji:
181186
description: Use GitHub custom emojis
182187
type: boolean
183188
default: yes
189+
global: yes
184190

185191
# Render display width
186192
config_display:
@@ -191,19 +197,22 @@ inputs:
191197
- regular # 480px width
192198
- large # 960px width (may not be supported by all templates)
193199
- columns # Full width with two columns on desktop / One column on mobile
200+
global: yes
194201

195202
# Enable SVG CSS animations
196203
config_animations:
197204
description: SVG CSS animations
198205
type: boolean
199206
default: yes
207+
global: yes
200208

201209
# Encode images links into base64 data
202210
# Advised to be true when generating images and false when generating texts or JSON
203211
config_base64:
204212
description: Encode images links into base64 data
205213
type: boolean
206214
default: yes
215+
global: yes
207216

208217
# Configure padding for output image (percentage value)
209218
# It can be used to add padding to generated metrics if rendering is cropped or has too much empty space
@@ -260,6 +269,23 @@ inputs:
260269
min: 0
261270
max: 3600
262271

272+
# Time to wait (in seconds) at the end of job
273+
# Use this to avoid triggering abuse mechanics on large workflows
274+
delay:
275+
description: Use this to avoid triggering abuse mechanics on large workflows
276+
type: number
277+
default: 0
278+
min: 0
279+
max: 3600
280+
281+
# Use a pre-built image from GitHub registry when using unreleased versions of "lowlighter/metrics"
282+
# This option has no effect on forks (images will always be rebuilt from Dockerfile)
283+
# See https://github.com/users/lowlighter/packages/container/package/metrics for more information
284+
use_prebuilt_image:
285+
description: Use pre-built image from GitHub registry
286+
type: boolean
287+
default: yes
288+
263289
# ====================================================================================
264290
# 🚧 Options below are mostly used for testing
265291

@@ -269,19 +295,22 @@ inputs:
269295
description: Die on plugins errors
270296
type: boolean
271297
default: no
298+
testing: yes
272299

273300
# Debug mode
274301
# Note that this will automatically be enabled if job fails
275302
debug:
276303
description: Debug logs
277304
type: boolean
278305
default: no
306+
testing: yes
279307

280308
# Ensure SVG can be correctly parsed after generation
281309
verify:
282310
description: Verify SVG
283311
type: boolean
284312
default: no
313+
testing: yes
285314

286315
# Debug flags
287316
debug_flags:
@@ -294,13 +323,15 @@ inputs:
294323
- --hireable
295324
- --halloween
296325
- --error
326+
testing: yes
297327

298328
# Dry-run mode (perform generation without output)
299329
# Unlike "output_action" set to "none", output file won't be available in "/metrics_renders"
300330
dryrun:
301331
description: Enable dry-run
302332
type: boolean
303333
default: no
334+
testing: yes
304335

305336
# Experimental features
306337
# Note that no backward compatibility are guaranteed for these features
@@ -311,26 +342,11 @@ inputs:
311342
default: ""
312343
values:
313344
- --optimize-svg
345+
testing: yes
314346

315347
# Use mocked data to bypass external APIs
316348
use_mocked_data:
317349
description: Use mocked data instead of live APIs
318350
type: boolean
319351
default: no
320-
321-
# Use a pre-built image from GitHub registry when using unreleased versions of "lowlighter/metrics"
322-
# This option has no effect on forks (images will always be rebuilt from Dockerfile)
323-
# See https://github.com/users/lowlighter/packages/container/package/metrics for more information
324-
use_prebuilt_image:
325-
description: Use pre-built image from GitHub registry
326-
type: boolean
327-
default: yes
328-
329-
# Time to wait (in seconds) at the end of job
330-
# Use this to avoid triggering abuse mechanics on large workflows
331-
delay:
332-
description: Use this to avoid triggering abuse mechanics on large workflows
333-
type: number
334-
default: 0
335-
min: 0
336-
max: 3600
352+
testing: yes

‎source/plugins/followup/metadata.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ inputs:
2929
plugin_followup_indepth:
3030
description: Indepth follow-up processing
3131
type: boolean
32-
default: no
32+
default: no
33+
extras: yes

‎source/plugins/habits/metadata.yml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ inputs:
4444
description: Display coding habits charts based on recent activity
4545
type: boolean
4646
default: no
47+
extras: yes
4748

4849
# Trim unused hours on daily chart
4950
plugin_habits_trim:

0 commit comments

Comments
 (0)
Failed to load comments.