Skip to content

Commit 404c643

Browse files
committed
Update documentation and reorder plugins by categorie
1 parent 27ff658 commit 404c643

File tree

9 files changed

+27
-19
lines changed

9 files changed

+27
-19
lines changed

.github/quickstart/plugin/metadata.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
name: "🧩 <%= `${name.charAt(0).toLocaleUpperCase()}${name.substring(1)}` %>"
2-
3-
# Estimate of how many GitHub requests will be used
4-
cost: N/A
5-
6-
# Supported modes
2+
cost: Estimates how many GitHub requests is used during plugin execution ("N/A" for Third-Party services)
3+
categorie: other # Set plugin categorie ("github", "social", "health" or "other")
74
supports:
8-
- user
9-
- organization
10-
- repository
11-
12-
# Inputs list
5+
- user # Support users account
6+
- organization # Support organizations account
7+
- repository # Support repositories metrics
138
inputs:
149

1510
# Enable or disable plugin

.github/readme/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
![Build](https://github.com/lowlighter/metrics/workflows/Build/badge.svg)
44

5-
<% for (const partial of ["introduction", "shared", "setup", "documentation", "references", "license"]) { -%>
5+
<% for (const partial of ["introduction", "shared", "setup", "documentation", "license", "references"]) { -%>
66
<%- await include(`/partials/${partial}.md`) %>
77
<% } %>

.github/readme/partials/documentation/compatibility.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<table>
44
<tr>
55
<th nowrap="nowrap">Template\Plugin</th><%# -%>
6-
<% for (const [plugin, {icon}] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %>
7-
<th nowrap="nowrap" align="center"><%= icon %></th><% } %>
6+
<% for (const [plugin, {name, icon}] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %>
7+
<th nowrap="nowrap" align="center" title="<%= name %>"><%= icon %></th><% } %>
88
</tr><%# -%>
99
<% for (const [template, {name, readme}] of Object.entries(templates).filter(([key, value]) => (value)&&(!["community"].includes(key)))) { %>
1010
<tr>

.github/readme/partials/documentation/plugins.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Plugins are features which provide additional content and lets you customize your rendered metrics.
44
See their respective documentation for more informations about how to setup them:
5-
<% for (const [plugin, {name}] of Object.entries(plugins).filter(([key, value]) => value)) { %>
6-
* [<%= name %>](/source/plugins/<%= plugin %>/README.md)<%# -%>
7-
<% } %>
5+
<% { let previous = null; for (const [plugin, {name, categorie}] of Object.entries(plugins).filter(([key, value]) => value)) { %>
6+
<% if (previous !== categorie) { previous = categorie -%>
7+
* **<%= `${categorie.charAt(0).toLocaleUpperCase()}${categorie.substring(1)}` %>**
8+
<% } -%>
9+
* [<%= name %>](/source/plugins/<%= plugin %>/README.md)<%# -%>
10+
<% }} %>

.github/readme/partials/license.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ MIT License
55
Copyright (c) 2020 lowlighter
66
```
77

8-
![License details](https://github.com/lowlighter/lowlighter/blob/master/metrics.licenses.svg)
8+
![License details](https://github.com/lowlighter/lowlighter/blob/master/metrics.licenses.svg)

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ Here's an example:
298298
```yaml
299299
name: "🧩 Plugin name (with emoji icon)"
300300
cost: Estimates how many GitHub requests is used during plugin execution ("N/A" for Third-Party services)
301+
categorie: github # Plugin categorie ("github", "social", "health" or "other")
301302
supports:
302303
- user # Support users account
303304
- organization # Support organizations account

source/app/metrics/metadata.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import url from "url"
55
import yaml from "js-yaml"
66

7+
//Defined categories
8+
const categories = ["core", "github", "social", "health", "other"]
9+
710
/**Metadata descriptor parser */
811
export default async function metadata({log = true} = {}) {
912
//Paths
@@ -25,7 +28,7 @@
2528
}
2629
//Reorder keys
2730
const {base, core, ...plugins} = Plugins
28-
Plugins = {base, core, ...plugins}
31+
Plugins = Object.fromEntries(Object.entries(Plugins).sort(([_an, a], [_bn, b]) => categories.indexOf(a.categorie) - categories.indexOf(b.categorie)))
2932

3033
//Load templates metadata
3134
let Templates = {}
@@ -53,6 +56,10 @@
5356
const raw = `${await fs.promises.readFile(path.join(__plugins, name, "metadata.yml"), "utf-8")}`
5457
const {inputs, ...meta} = yaml.load(raw)
5558

59+
//Categorie
60+
if (!categories.includes(meta.categorie))
61+
meta.categorie = "other"
62+
5663
//Inputs parser
5764
{
5865
meta.inputs = function({data:{user = null} = {}, q, account}, defaults = {}) {
@@ -260,7 +267,7 @@
260267
return {
261268
name:raw.match(/^### (?<name>[\s\S]+?)\n/)?.groups?.name?.trim(),
262269
readme:{
263-
demo:raw.match(/(?<demo><table>[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? (name === "community" ? "<td align=\"center\">See <a href=\"/source/templates/community/README.md\">documentation</a> 🌍</td>" : "<td></td>"),
270+
demo:raw.match(/(?<demo><table>[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? (name === "community" ? "<td align=\"center\"><h3>See <a href=\"/source/templates/community/README.md\">documentation</a> 🌍</h3></td>" : "<td></td>"),
264271
compatibility:{...compatibility, base:true},
265272
},
266273
}

source/plugins/contributors/metadata.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: "🏅 Contributors"
22
cost: N/A
3+
categorie: github
34
supports:
45
- repository
56
inputs:

source/plugins/licenses/metadata.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: "📜 Licenses"
22
cost: N/A
3+
categorie: github
34
supports:
45
- repository
56
inputs:

0 commit comments

Comments
 (0)