You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2019/10/23 07:19:41 UTC
[isis] 02/02: ISIS-2062: cleans up generated asciidoc a bit
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-2062
in repository https://gitbox.apache.org/repos/asf/isis.git
commit a887d0b9d6d2d413a7537c97cd3323f38ff68770
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Oct 23 08:19:13 2019 +0100
ISIS-2062: cleans up generated asciidoc a bit
---
.../isis/commons/internal/strings/FormatTest.java | 66 +++++++++++++++++++++
.../modules/cfg/pages/spring-configuration.adoc | 26 ++++-----
extensions/asciidoc/_adoc/antora.yml | 2 +-
extensions/markdown/_adoc/antora.yml | 2 +-
extensions/viewer-wicket-excel/_adoc/antora.yml | 2 +-
scripts/generateConfigDocs.groovy | 68 ++++++++++++++++++++--
site.yml | 3 +
7 files changed, 148 insertions(+), 21 deletions(-)
diff --git a/core/commons/src/test/java/org/apache/isis/commons/internal/strings/FormatTest.java b/core/commons/src/test/java/org/apache/isis/commons/internal/strings/FormatTest.java
new file mode 100644
index 0000000..c61e84c
--- /dev/null
+++ b/core/commons/src/test/java/org/apache/isis/commons/internal/strings/FormatTest.java
@@ -0,0 +1,66 @@
+package org.apache.isis.commons.internal.strings;
+
+
+import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+
+public class FormatTest {
+
+ // copy of code in scripts/generateConfigDocs.groovy
+ public static String format(final String str, int len) {
+ if(str.length() <= len) {
+ return str;
+ }
+
+ final StringBuilder buf = new StringBuilder();
+ String remaining = str;
+
+ while(remaining.length() > 0) {
+ int lastDot = remaining.substring(0, len).lastIndexOf('.');
+ int lastDash = remaining.substring(0, len).lastIndexOf('-');
+ int splitAt = lastDot > 0
+ ? lastDot + 1
+ : lastDash > 0
+ ? lastDash + 1
+ : len;
+ if(buf.length() > 0) {
+ buf.append("\n");
+ }
+ buf.append(remaining, 0, splitAt);
+ remaining = remaining.substring(splitAt);
+
+ if(remaining.length() <= len) {
+ buf.append("\n").append(remaining);
+ remaining = "";
+ }
+ }
+ return buf.toString();
+ }
+
+ @Test
+ public void split_once() {
+ Assertions.assertEquals("abc.def.ghi.jkl.mno.\npqr.stu.vwx.yza", format("abc.def.ghi.jkl.mno.pqr.stu.vwx.yza", 20));
+ }
+
+ @Test
+ public void split_twice() {
+ Assertions.assertEquals("abc.def.ghi.jkl.\nmno.pqr.stu.vwx.\nyza", format("abc.def.ghi.jkl.mno.pqr.stu.vwx.yza", 16));
+ }
+
+ @Test
+ public void split_not_on_divider() {
+ Assertions.assertEquals("abc.def.ghi.\njkl.mno.pqr.\nstu.vwx.yza", format("abc.def.ghi.jkl.mno.pqr.stu.vwx.yza", 15));
+ }
+
+ @Test
+ public void no_divider() {
+ Assertions.assertEquals("abcdefghij\nklmnopqrst\nuvwxyza", format("abcdefghijklmnopqrstuvwxyza", 10));
+ }
+
+ @Test
+ public void real_world() {
+ Assertions.assertEquals("isis.persistor.\ndatanucleus.\nclass-metadata-\nloaded-listener", format("isis.persistor.datanucleus.class-metadata-loaded-listener", 20));
+ }
+
+
+}
diff --git a/core/config/_adoc/modules/cfg/pages/spring-configuration.adoc b/core/config/_adoc/modules/cfg/pages/spring-configuration.adoc
index 744b27c..be8d31e 100644
--- a/core/config/_adoc/modules/cfg/pages/spring-configuration.adoc
+++ b/core/config/_adoc/modules/cfg/pages/spring-configuration.adoc
@@ -7,7 +7,7 @@ include::_attributes.adoc[]
== Shiro Authentication
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -22,7 +22,7 @@ include::rg:cfg:example$generated/isis.authentication.shiro.adoc[]
== Persistors (in general)
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -36,7 +36,7 @@ include::rg:cfg:example$generated/isis.persistor.adoc[]
== DataNucleus Persistor
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -52,7 +52,7 @@ include::rg:cfg:example$generated/isis.persistor.datanucleus.adoc[]
== DataNucleus Persistor Pass-thru Settings
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -67,7 +67,7 @@ include::rg:cfg:example$generated/isis.persistor.datanucleus.impl.adoc[]
== Metamodel Reflector
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -83,7 +83,7 @@ include::rg:cfg:example$generated/isis.reflector.adoc[]
== MetaModel Facets
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -99,7 +99,7 @@ include::rg:cfg:example$generated/isis.reflector.facet.adoc[]
== Metamodel Validation
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -114,7 +114,7 @@ include::rg:cfg:example$generated/isis.reflector.validator.adoc[]
== Individual Domain Services
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -129,7 +129,7 @@ include::rg:cfg:example$generated/isis.service.email.adoc[]
== Domain Services (in general)
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -144,7 +144,7 @@ include::rg:cfg:example$generated/isis.services.adoc[]
== Restful Objects Viewer
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -159,7 +159,7 @@ include::rg:cfg:example$generated/isis.viewer.restfulobjects.adoc[]
== Wicket Viewer
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -174,7 +174,7 @@ include::rg:cfg:example$generated/isis.viewer.wicket.adoc[]
== Viewers (in general)
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
@@ -188,7 +188,7 @@ include::rg:cfg:example$generated/isis.viewers.adoc[]
== Other
-[cols="2a,1,3a", options="header"]
+[cols="2a,2a,3a", options="header"]
|===
|Property
|Value +
diff --git a/extensions/asciidoc/_adoc/antora.yml b/extensions/asciidoc/_adoc/antora.yml
index d93aa8f..cb832ae 100644
--- a/extensions/asciidoc/_adoc/antora.yml
+++ b/extensions/asciidoc/_adoc/antora.yml
@@ -1,2 +1,2 @@
-name: uvw
+name: vw
version: master
diff --git a/extensions/markdown/_adoc/antora.yml b/extensions/markdown/_adoc/antora.yml
index d93aa8f..cb832ae 100644
--- a/extensions/markdown/_adoc/antora.yml
+++ b/extensions/markdown/_adoc/antora.yml
@@ -1,2 +1,2 @@
-name: uvw
+name: vw
version: master
diff --git a/extensions/viewer-wicket-excel/_adoc/antora.yml b/extensions/viewer-wicket-excel/_adoc/antora.yml
index d93aa8f..cb832ae 100644
--- a/extensions/viewer-wicket-excel/_adoc/antora.yml
+++ b/extensions/viewer-wicket-excel/_adoc/antora.yml
@@ -1,2 +1,2 @@
-name: uvw
+name: vw
version: master
diff --git a/scripts/generateConfigDocs.groovy b/scripts/generateConfigDocs.groovy
index 14f8c0e..1f6d5c2 100644
--- a/scripts/generateConfigDocs.groovy
+++ b/scripts/generateConfigDocs.groovy
@@ -190,20 +190,21 @@ for (PropertyGroup group in groups) {
if(group.properties.size() > 0) {
for (Property property in group.properties) {
- buf << "| ${property.name}\n"
+ buf << "| "
+ buf << format("${property.name}\n")
// buf << "|"
// if(property.type) {
// buf << " ${property.type}"
// }
// buf << "\n"
- buf << "|"
+ buf << "| "
if(property.defaultValue) {
- buf << " ${property.defaultValue}"
+ buf << format(" ${property.defaultValue}")
}
buf << "\n"
- buf << "|"
+ buf << "| "
if(property.description) {
- buf << " ${property.description}"
+ buf << toAsciidoc(" ${property.description}")
}
buf << "\n"
buf << "\n"
@@ -214,3 +215,60 @@ for (PropertyGroup group in groups) {
outputFile.write(buf.toString())
}
}
+
+static String toAsciidoc(String str) {
+
+ String lineFeed = " +\n";
+
+ // simple html -> asciidoc substitutions
+ str = str.replace("<p>", lineFeed);
+ str = str.replace("</p>", "");
+
+ str = str.replace("<i>", "_");
+ str = str.replace("<b>", "*");
+ //str = str.replaceAll("<a href=\"(.*)\">(.*?)</a>", "link:$1[$2]");
+
+ str = str.replace("<code>", "`");
+ str = str.replace("<\\code>", "`");
+ str = str.replace("<tt>", "`");
+ str = str.replace("<\\tt>", "`");
+
+ return str;
+}
+
+static String format(String str, int len = 30) {
+
+ String lineFeed = " +\n";
+
+ if(str.length() <= len) {
+ return str;
+ }
+
+ final StringBuilder buf = new StringBuilder();
+ String remaining = str;
+
+ while(remaining.length() > 0) {
+ int lastDot = remaining.substring(0, len).lastIndexOf('.');
+ int lastDash = remaining.substring(0, len).lastIndexOf('-');
+ int splitAt = lastDot > 0
+ ? lastDot + 1
+ : lastDash > 0
+ ? lastDash + 1
+ : len;
+ if(buf.length() > 0) {
+ buf.append(lineFeed);
+ }
+ buf.append(remaining, 0, splitAt);
+ remaining = remaining.substring(splitAt);
+
+ if(remaining.length() <= len) {
+ buf.append(lineFeed).append(remaining);
+ remaining = "";
+ }
+ }
+
+ def string = buf.toString()
+// System.out.println(str)
+// System.out.println(string)
+ return string;
+}
diff --git a/site.yml b/site.yml
index 6b1f569..12ec137 100644
--- a/site.yml
+++ b/site.yml
@@ -98,6 +98,9 @@ content:
start_path: antora/components/security
branches: HEAD
- url: .
+ start_path: core/security/api/_adoc
+ branches: HEAD
+ - url: .
start_path: core/security/bypass/_adoc
branches: HEAD
- url: .