From 404c643bcff19a5032039c9d3ca9d2f4134ab6c0 Mon Sep 17 00:00:00 2001
From: lowlighter <22963968+lowlighter@users.noreply.github.com>
Date: Wed, 17 Feb 2021 14:09:20 +0100
Subject: [PATCH] Update documentation and reorder plugins by categorie
---
.github/quickstart/plugin/metadata.yml | 15 +++++----------
.github/readme/README.md | 2 +-
.../partials/documentation/compatibility.md | 4 ++--
.github/readme/partials/documentation/plugins.md | 9 ++++++---
.github/readme/partials/license.md | 2 +-
CONTRIBUTING.md | 1 +
source/app/metrics/metadata.mjs | 11 +++++++++--
source/plugins/contributors/metadata.yml | 1 +
source/plugins/licenses/metadata.yml | 1 +
9 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/.github/quickstart/plugin/metadata.yml b/.github/quickstart/plugin/metadata.yml
index b99c23dd..595fefa5 100644
--- a/.github/quickstart/plugin/metadata.yml
+++ b/.github/quickstart/plugin/metadata.yml
@@ -1,15 +1,10 @@
name: "🧩 <%= `${name.charAt(0).toLocaleUpperCase()}${name.substring(1)}` %>"
-
-# Estimate of how many GitHub requests will be used
-cost: N/A
-
-# Supported modes
+cost: Estimates how many GitHub requests is used during plugin execution ("N/A" for Third-Party services)
+categorie: other # Set plugin categorie ("github", "social", "health" or "other")
supports:
- - user
- - organization
- - repository
-
-# Inputs list
+ - user # Support users account
+ - organization # Support organizations account
+ - repository # Support repositories metrics
inputs:
# Enable or disable plugin
diff --git a/.github/readme/README.md b/.github/readme/README.md
index 7f32bddd..c76a2036 100644
--- a/.github/readme/README.md
+++ b/.github/readme/README.md
@@ -2,6 +2,6 @@

-<% for (const partial of ["introduction", "shared", "setup", "documentation", "references", "license"]) { -%>
+<% for (const partial of ["introduction", "shared", "setup", "documentation", "license", "references"]) { -%>
<%- await include(`/partials/${partial}.md`) %>
<% } %>
diff --git a/.github/readme/partials/documentation/compatibility.md b/.github/readme/partials/documentation/compatibility.md
index c5a79764..53b9d885 100644
--- a/.github/readme/partials/documentation/compatibility.md
+++ b/.github/readme/partials/documentation/compatibility.md
@@ -3,8 +3,8 @@
| Template\Plugin | <%# -%>
- <% for (const [plugin, {icon}] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %>
- <%= icon %> | <% } %>
+ <% for (const [plugin, {name, icon}] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %>
+ <%= icon %> | <% } %>
<%# -%>
<% for (const [template, {name, readme}] of Object.entries(templates).filter(([key, value]) => (value)&&(!["community"].includes(key)))) { %>
diff --git a/.github/readme/partials/documentation/plugins.md b/.github/readme/partials/documentation/plugins.md
index 812f2fe3..9771d1d5 100644
--- a/.github/readme/partials/documentation/plugins.md
+++ b/.github/readme/partials/documentation/plugins.md
@@ -2,6 +2,9 @@
Plugins are features which provide additional content and lets you customize your rendered metrics.
See their respective documentation for more informations about how to setup them:
-<% for (const [plugin, {name}] of Object.entries(plugins).filter(([key, value]) => value)) { %>
-* [<%= name %>](/source/plugins/<%= plugin %>/README.md)<%# -%>
-<% } %>
+<% { let previous = null; for (const [plugin, {name, categorie}] of Object.entries(plugins).filter(([key, value]) => value)) { %>
+<% if (previous !== categorie) { previous = categorie -%>
+* **<%= `${categorie.charAt(0).toLocaleUpperCase()}${categorie.substring(1)}` %>**
+<% } -%>
+ * [<%= name %>](/source/plugins/<%= plugin %>/README.md)<%# -%>
+<% }} %>
diff --git a/.github/readme/partials/license.md b/.github/readme/partials/license.md
index 0aa05032..93473e23 100644
--- a/.github/readme/partials/license.md
+++ b/.github/readme/partials/license.md
@@ -5,4 +5,4 @@ MIT License
Copyright (c) 2020 lowlighter
```
-
\ No newline at end of file
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a5af245d..e71b3b1d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -298,6 +298,7 @@ Here's an example:
```yaml
name: "🧩 Plugin name (with emoji icon)"
cost: Estimates how many GitHub requests is used during plugin execution ("N/A" for Third-Party services)
+categorie: github # Plugin categorie ("github", "social", "health" or "other")
supports:
- user # Support users account
- organization # Support organizations account
diff --git a/source/app/metrics/metadata.mjs b/source/app/metrics/metadata.mjs
index c32df2ad..c5039b63 100644
--- a/source/app/metrics/metadata.mjs
+++ b/source/app/metrics/metadata.mjs
@@ -4,6 +4,9 @@
import url from "url"
import yaml from "js-yaml"
+//Defined categories
+ const categories = ["core", "github", "social", "health", "other"]
+
/**Metadata descriptor parser */
export default async function metadata({log = true} = {}) {
//Paths
@@ -25,7 +28,7 @@
}
//Reorder keys
const {base, core, ...plugins} = Plugins
- Plugins = {base, core, ...plugins}
+ Plugins = Object.fromEntries(Object.entries(Plugins).sort(([_an, a], [_bn, b]) => categories.indexOf(a.categorie) - categories.indexOf(b.categorie)))
//Load templates metadata
let Templates = {}
@@ -53,6 +56,10 @@
const raw = `${await fs.promises.readFile(path.join(__plugins, name, "metadata.yml"), "utf-8")}`
const {inputs, ...meta} = yaml.load(raw)
+ //Categorie
+ if (!categories.includes(meta.categorie))
+ meta.categorie = "other"
+
//Inputs parser
{
meta.inputs = function({data:{user = null} = {}, q, account}, defaults = {}) {
@@ -260,7 +267,7 @@
return {
name:raw.match(/^### (?[\s\S]+?)\n/)?.groups?.name?.trim(),
readme:{
- demo:raw.match(/(?[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? (name === "community" ? "| See documentation 🌍 | " : " | "),
+ demo:raw.match(/(?[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? (name === "community" ? " | " : " | "),
compatibility:{...compatibility, base:true},
},
}
diff --git a/source/plugins/contributors/metadata.yml b/source/plugins/contributors/metadata.yml
index 3143b2ce..7d9742bf 100644
--- a/source/plugins/contributors/metadata.yml
+++ b/source/plugins/contributors/metadata.yml
@@ -1,5 +1,6 @@
name: "🏅 Contributors"
cost: N/A
+categorie: github
supports:
- repository
inputs:
diff --git a/source/plugins/licenses/metadata.yml b/source/plugins/licenses/metadata.yml
index 77d43e4a..85f5ff40 100644
--- a/source/plugins/licenses/metadata.yml
+++ b/source/plugins/licenses/metadata.yml
@@ -1,5 +1,6 @@
name: "📜 Licenses"
cost: N/A
+categorie: github
supports:
- repository
inputs: