You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/09/10 06:02:14 UTC
[isis] branch master updated: ISIS-2426: Adds README (Tooling -
AsciiDoc Model)
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new a4b2155 ISIS-2426: Adds README (Tooling - AsciiDoc Model)
a4b2155 is described below
commit a4b2155544bb44ad565cce5437f6ba8a9e746f51
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Sep 10 08:01:57 2020 +0200
ISIS-2426: Adds README (Tooling - AsciiDoc Model)
---
tooling/asciidoc-model/README.adoc | 63 ++++++++++++++++++++++
.../isis/tooling/adocmodel/AsciiDocFactory.java | 6 +++
2 files changed, 69 insertions(+)
diff --git a/tooling/asciidoc-model/README.adoc b/tooling/asciidoc-model/README.adoc
new file mode 100644
index 0000000..0db0916
--- /dev/null
+++ b/tooling/asciidoc-model/README.adoc
@@ -0,0 +1,63 @@
+= Tooling - AsciiDoc Model
+
+Allows for programmatic generation of ascii-doc representing document models.
+
+WARNING: This is work-in-progress, no official Maven artifacts are published yet at the time of writing.
+However, snapshots are available with our nightly-builds:
+https://github.com/apache-isis-committers/isis-nightly[]
+
+== Usage
+
+[source,java]
+----
+
+import static org.apache.isis.tooling.adocmodel.AsciiDocFactory.*;
+
+...
+
+Document doc = doc();
+Table table = table(doc);
+table.setTitle("Some table");
+table.setAttribute("cols", "3m,2a", true);
+table.setAttribute("header-option", "", true);
+
+headCell(table, 0, 0, "Col-1");
+headCell(table, 0, 1, "Col-2");
+
+cell(table, 0, 0, "1-1");
+cell(table, 0, 1, "1-2");
+
+String adoc = AsciiDocWriter.toString(doc);
+
+System.out.println(adoc);
+----
+
+ascii-doc syntax generated:
+
+[source]
+----
+.Some table
+[cols="3m,2a", options="header"]
+|===
+|Col-1 |Col-2
+
+|1-1
+|1-2
+|===
+----
+
+which renders as
+
+.Some table
+[cols="3m,2a", options="header"]
+|===
+|Col-1 |Col-2
+
+|1-1
+|1-2
+|===
+
+
+
+
+
\ No newline at end of file
diff --git a/tooling/asciidoc-model/src/main/java/org/apache/isis/tooling/adocmodel/AsciiDocFactory.java b/tooling/asciidoc-model/src/main/java/org/apache/isis/tooling/adocmodel/AsciiDocFactory.java
index 78832a2..a6f2aaf 100644
--- a/tooling/asciidoc-model/src/main/java/org/apache/isis/tooling/adocmodel/AsciiDocFactory.java
+++ b/tooling/asciidoc-model/src/main/java/org/apache/isis/tooling/adocmodel/AsciiDocFactory.java
@@ -80,6 +80,12 @@ public class AsciiDocFactory {
cell.setSource(source);
return cell;
}
+
+ public static Cell cell(Table table, Row row, String source) {
+ val colIndex = row.getCells().size();
+ val column = getOrCreateColumn(table, colIndex);
+ return cell(row, column, source);
+ }
public static Cell cell(Table table, int rowIndex, int colIndex, String source) {
val row = getOrCreateRow(table, rowIndex);