Skip to content

Commit

Permalink
feat(core): add long description from group markdown file
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu authored and tchiotludo committed Feb 2, 2023
1 parent 23c1d69 commit a349f63
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void run() throws IOException, URISyntaxException {
"# Plugin template test\n" +
"\n" +
"Plugin template for Kestra\n" +
"\n" +
"This is a more complex description of the plugin.\n" +
"\n" +
"This is in markdown and will be inline inside the plugin page.\n" +
"## Subgroup title\n" +
" \n" +
"Subgroup description\n" +
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ private static List<Document> index(RegisteredPlugin plugin) throws IOException
if (plugin.getManifest() != null) {
builder.put("title", plugin.getManifest().getMainAttributes().getValue("X-Kestra-Title"));
builder.put("description", plugin.getManifest().getMainAttributes().getValue("X-Kestra-Description"));
builder.put("group", plugin.getManifest().getMainAttributes().getValue("X-Kestra-Group"));
var group = plugin.getManifest().getMainAttributes().getValue("X-Kestra-Group");
builder.put("group", group);
longDescription(plugin, builder, group);
builder.put("classPlugins", pluginDocumentation.getClassPlugins());
}

Expand All @@ -96,6 +98,17 @@ private static List<Document> index(RegisteredPlugin plugin) throws IOException
));
}

private static void longDescription(RegisteredPlugin plugin, ImmutableMap.Builder<String, Object> builder, String group) {
try (var is = plugin.getClassLoader().getResourceAsStream("doc/" + group + ".md")) {
if(is != null) {
builder.put("longDescription", IOUtils.toString(is, Charsets.UTF_8));
}
}
catch (Exception e) {
// silently fail
}
}

private <T> List<Document> generate(RegisteredPlugin registeredPlugin, List<Class<? extends T>> cls, Class<T> baseCls, String type) {
return cls
.stream()
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/docs/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ editLink: false

{{ description }}

{{ longDescription }}

{{~#each classPlugins }}
{{~#if @key.title}}
## {{ @key.title }}
Expand Down

0 comments on commit a349f63

Please sign in to comment.