Skip to content

Commit

Permalink
fix(docs): make docs index link relative
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Apr 23, 2023
1 parent 7f2a3b7 commit 41e0ce3
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 29 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,10 @@ jar {
manifest {
attributes (
"Main-Class": mainClassName,
"X-Kestra-Title": project.name,
"X-Kestra-Group": project.group,
"X-Kestra-Version": project.version
"X-Kestra-Name": project.name,
"X-Kestra-Title": project.name,
"X-Kestra-Group": project.group,
"X-Kestra-Version": project.version
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ void run() throws IOException, URISyntaxException {
assertThat(directory.isDirectory(), is(true));
assertThat(directory.listFiles().length, is(3));

var readme = directory.toPath().resolve("README.md");
var readme = directory.toPath().resolve("index.md");
assertThat(new String(Files.readAllBytes(readme)), containsString("---\n" +
"title: Plugin template test\n" +
"description: Plugin template for Kestra\n" +
"title: Template test\n" +
"description: \"Plugin template for Kestra\"\n" +
"editLink: false\n\n" +
"---\n" +
"# Plugin template test\n" +
"# Template test\n" +
"\n" +
"Plugin template for Kestra\n" +
"\n" +
Expand All @@ -74,12 +74,12 @@ void run() throws IOException, URISyntaxException {
"Subgroup description\n" +
"### Tasks\n" +
"\n" +
"* [ExampleTask](tasks/io.kestra.plugin.templates.ExampleTask.html)\n" +
"* [ExampleTask](./tasks/io.kestra.plugin.templates.ExampleTask.md)\n" +
"\n" +
"## Guides\n" +
"* [Authentication](guides/authentication.html)\n" +
"* [Authentication](./guides/authentication.md)\n" +
" \n" +
"* [Reporting](guides/reporting.html)\n" +
"* [Reporting](./guides/reporting.md)\n" +
" \n"));

// check @PluginProperty from an interface
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private ClassPluginDocumentation(JsonSchemaGenerator jsonSchemaGenerator, Regist
this.pluginTitle = plugin.title();
this.icon = DocumentationGenerator.icon(plugin, cls);

if (this.group != null && cls.getPackageName().startsWith(this.group) && cls.getPackageName().length() > this.group.length()) {
if (this.group != null && cls.getPackageName().startsWith(this.group) && cls.getPackageName().length() > this.group.length() && cls.getPackageName().charAt(this.group.length()) == '.') {
this.subGroup = cls.getPackageName().substring(this.group.length() + 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static List<Document> index(RegisteredPlugin plugin) throws IOException
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();

if (plugin.getManifest() != null) {
builder.put("title", plugin.getManifest().getMainAttributes().getValue("X-Kestra-Title"));
builder.put("title", plugin.getManifest().getMainAttributes().getValue("X-Kestra-Title").replace("plugin-", ""));

if (plugin.getManifest().getMainAttributes().getValue("X-Kestra-Description") != null) {
builder.put("description", plugin.getManifest().getMainAttributes().getValue("X-Kestra-Description"));
Expand Down Expand Up @@ -204,13 +204,13 @@ public static String icon(RegisteredPlugin plugin, String iconName) {
}

private static <T> String docPath(RegisteredPlugin registeredPlugin) {
String pluginName = Slugify.of(registeredPlugin.title());
String pluginName = Slugify.of(registeredPlugin.path());

return pluginName + "/README.md";
return pluginName + "/index.md";
}

private static <T> String docPath(RegisteredPlugin registeredPlugin, String type, ClassPluginDocumentation<T> classPluginDocumentation) {
String pluginName = Slugify.of(registeredPlugin.title());
String pluginName = Slugify.of(registeredPlugin.path());

return pluginName + "/" + type + "/" +
(classPluginDocumentation.getSubGroup() != null ? classPluginDocumentation.getSubGroup() + "/" : "") +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public Map<String, List<Class>> allClassGrouped() {
return result;
}

public String path() {
return ObjectUtils.firstNonNull(
this.getManifest() != null ? this.getManifest().getMainAttributes().getValue("X-Kestra-Name") : null,
this.getExternalPlugin() != null ? FilenameUtils.getBaseName(this.getExternalPlugin().getLocation().getPath()) : null,
"Core"
);
}

public String title() {
return ObjectUtils.firstNonNull(
this.getManifest() != null ? this.getManifest().getMainAttributes().getValue("X-Kestra-Title") : null,
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/resources/docs/index.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: {{ capitalizeFirst (replace title "-" " ") }}
{{#if description}}description: {{ description }}{{~/if}}
{{#if description}}description: {{ json description }}{{~/if}}
editLink: false
{{#if icon}}icon: {{ icon }}{{~/if}}
---
Expand All @@ -22,7 +22,7 @@ editLink: false
### {{ capitalizeFirst type }}

{{#each classes as | class | ~}}
* [{{simpleName}}]({{ type }}/{{#and subgroup.name}}{{#not subgroup.subgroupIsGroup}}{{subgroup.name}}/{{/not}}{{/and}}{{ name }}.html)
* [{{simpleName}}](./{{ type }}/{{#and subgroup.name}}{{#not subgroup.subgroupIsGroup}}{{subgroup.name}}/{{/not}}{{/and}}{{ name }}.md)
{{/each ~}}

{{/each ~}}
Expand All @@ -31,6 +31,6 @@ editLink: false
{{~#if guides }}
## Guides
{{~#each guides as | guide | }}
* [{{ capitalizeFirst guide }}](guides/{{ guide }}.html)
* [{{ capitalizeFirst guide }}](./guides/{{ guide }}.md)
{{/each}}
{{/if}}
16 changes: 8 additions & 8 deletions core/src/main/resources/docs/task.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: {{ capitalizeFirst (replace pluginTitle "-" " ") }} {{shortName}}
title: {{shortName}}
editLink: false
{{#if docDescription}}
description: {{ docDescription }}
description: {{ json docDescription }}
{{~/if}}
{{#if icon}}
icon: {{ icon }}
Expand All @@ -29,9 +29,9 @@ icon: {{ icon }}

{{~#*inline "type"~}}
{{~#if $ref~}}
[{{~ definitionName (substring $ref 8) ~}}](#{{~ lower (definitionName (substring $ref 8)) ~}})
[=={{~ definitionName (substring $ref 8) ~}}==](#{{~ lower (definitionName (substring $ref 8)) ~}})
{{~else~}}
{{~ type ~}}
=={{~ type ~}}==
{{~/if}}
{{~/inline~}}

Expand All @@ -41,19 +41,19 @@ icon: {{ icon }}
{{~/if}}

{{~#if type }}
* **Type:** =={{> type }}==
* **Type:** {{> type }}
{{~else if $ref }}
* **Type:** =={{> type }}==
* **Type:** {{> type }}
{{~else if anyOf }}
* **Type:**
{{~#each anyOf as | current |}}
=={{>type current}}==
{{>type current}}
{{~/each~}}
{{~else}}
* **Type:** ==object==
{{~/if~}}
{{~#if items }}
* **SubType:** =={{> type items }}==
* **SubType:** {{> type items }}
{{~/if~}}
{{~#if additionalProperties }}
* **SubType:** =={{ additionalProperties.type }}==
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void tasks() throws URISyntaxException {

assertThat(doc.getDocExamples().size(), is(2));
assertThat(doc.getIcon(), is(notNullValue()));
assertThat(doc.getInputs().size(), is(2));
assertThat(doc.getInputs().size(), is(5));

// simple
assertThat(((Map<String, String>) doc.getInputs().get("format")).get("type"), is("string"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void tasks() throws URISyntaxException, IOException {
String render = DocumentationGenerator.render(doc);

assertThat(render, containsString("ExampleTask"));
assertThat(render, containsString("description: Short description for this task"));
assertThat(render, containsString("description: \"Short description for this task\""));
assertThat(render, containsString("`VALUE_1`"));
assertThat(render, containsString("`VALUE_2`"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void tasks() throws URISyntaxException {
Class<? extends Task> cls = scan.get(0).getTasks().get(0);

Map<String, Object> generate = jsonSchemaGenerator.properties(Task.class, cls);
assertThat(((Map<String, Map<String, Object>>) generate.get("properties")).size(), is(2));
assertThat(((Map<String, Map<String, Object>>) generate.get("properties")).size(), is(5));

Map<String, Object> format = properties(generate).get("format");
assertThat(format.get("default"), is("{}"));
Expand Down
Binary file not shown.

0 comments on commit 41e0ce3

Please sign in to comment.