From d21b1309c20971668f244d5fd2c85f59fa3f8353 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Sun, 11 Feb 2024 11:51:08 +0100 Subject: [PATCH] Update IT --- .../src/site/asciidoc/sample.adoc | 13 +++++ .../src/it/maven-site-plugin/validate.groovy | 19 +++++++ .../DescriptionListNodeProcessorTest.java | 57 ++++++++++--------- .../maven/site/ast/processors/test/Html.java | 49 ++++++++++++++++ ...parser-module-setup-and-configuration.adoc | 2 + 5 files changed, 114 insertions(+), 26 deletions(-) create mode 100644 asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/Html.java diff --git a/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/sample.adoc b/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/sample.adoc index 63b3da47..364d2c9d 100644 --- a/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/sample.adoc +++ b/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/sample.adoc @@ -75,3 +75,16 @@ public class HelloWorld { . Protons . Electrons . Neutrons + +==== Description list + +Operating Systems:: +Linux::: +. Fedora +* Desktop +. Ubuntu +* Desktop +* Server +BSD::: +. FreeBSD +. NetBSD diff --git a/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/validate.groovy b/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/validate.groovy index 7cc629ed..49cbe17b 100644 --- a/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/validate.groovy +++ b/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/validate.groovy @@ -42,6 +42,15 @@ new HtmlAsserter(htmlContent).with { asserter -> asserter.containsSectionTitle("Ordered list", 4) asserter.containsOrderedList("Protons", "Electrons", "Neutrons") + asserter.containsSectionTitle("Description list", 4) + asserter.descriptionListTerm("Operating Systems") + asserter.descriptionListTerm("Linux") + asserter.contains("
  • Fedora") + asserter.containsUnorderedList("Desktop") + asserter.contains("
  • Ubuntu") + asserter.containsUnorderedList("Desktop", "Server") + asserter.descriptionListTerm("BSD") + asserter.containsOrderedList("FreeBSD", "NetBSD") } String strong(String text) { @@ -111,6 +120,11 @@ class HtmlAsserter { return content.indexOf(value, lastAssertionCursor) } + void contains(String text) { + def found = find(text) + assertFound("HTML text", text, found) + } + void containsDocumentTitle(String value) { def found = find("

    $value

    ") assertFound("Document Title", value, found) @@ -160,6 +174,11 @@ class HtmlAsserter { assertFound("Ordered list", values.join(','), found) } + void descriptionListTerm(String term) { + def found = find("
    ${term}
    ") + assertFound("Description list", term, found) + } + void containsTable(int columns, int rows, List headers, String caption) { def start = content.indexOf("", lastAssertionCursor) + "".length() diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/DescriptionListNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/DescriptionListNodeProcessorTest.java index 35ec5b1b..8a3864c4 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/DescriptionListNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/DescriptionListNodeProcessorTest.java @@ -13,6 +13,15 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.asciidoctor.maven.site.ast.processors.test.Html.LIST_STYLE_TYPE_DECIMAL; +import static org.asciidoctor.maven.site.ast.processors.test.Html.dd; +import static org.asciidoctor.maven.site.ast.processors.test.Html.dt; +import static org.asciidoctor.maven.site.ast.processors.test.Html.italics; +import static org.asciidoctor.maven.site.ast.processors.test.Html.li; +import static org.asciidoctor.maven.site.ast.processors.test.Html.monospace; +import static org.asciidoctor.maven.site.ast.processors.test.Html.ol; +import static org.asciidoctor.maven.site.ast.processors.test.Html.strong; +import static org.asciidoctor.maven.site.ast.processors.test.Html.ul; import static org.asciidoctor.maven.site.ast.processors.test.StringTestUtils.clean; import static org.assertj.core.api.Assertions.assertThat; @@ -48,10 +57,8 @@ void should_convert_simple_list() { // TODO: document We are not adding additional
    /

    , unlike Asciidoctor assertThat(html) .isEqualTo("

    " + - "
    CPU
    " + - "
    The brain of the computer.
    " + - "
    RAM
    " + - "
    Temporarily stores information the CPU uses during operation.
    " + + dt("CPU") + dd("The brain of the computer.") + + dt("RAM") + dd("Temporarily stores information the CPU uses during operation.") + "
    "); } @@ -63,10 +70,8 @@ void should_convert_simple_list_with_formatting() { assertThat(html) .isEqualTo("
    " + - "
    CPU
    " + - "
    The brain of the computer.
    " + - "
    RAM
    " + - "
    Temporarily stores information the CPU uses during operation.
    " + + dt(strong("CPU")) + dd("The brain of " + italics("the computer") + ".") + + dt(monospace("RAM")) + dd(strong("Temporarily stores information") + " the CPU uses during operation.") + "
    "); } @@ -78,18 +83,13 @@ void should_convert_simple_list_with_nested_list() { assertThat(html) .isEqualTo("
    " + - "
    Dairy
    " + + dt("Dairy") + "
    " + - "
      " + - "
    • Milk
    • " + - "
    • Eggs
    • " + - "
    " + + ul(li("Milk"), li("Eggs")) + "
    " + - "
    Bakery
    " + + dt("Bakery") + "
    " + - "
      " + - "
    1. Bread
    2. " + - "
    " + + ol(LIST_STYLE_TYPE_DECIMAL, li("Bread")) + "
    " + "
    " ); @@ -103,18 +103,23 @@ void should_convert_nested_description_lists() { assertThat(html) .isEqualTo("
    " + - "
    Dairy
    " + + dt("Operating Systems") + "
    " + - "
      " + - "
    • Milk
    • " + - "
    • Eggs
    • " + - "
    " + + "
    " + + + dt("Linux") + + "
    " + + ol(LIST_STYLE_TYPE_DECIMAL, + li("Fedora" + ul(li("Desktop"))), + li("Ubuntu" + ul(li("Desktop"), li("Server"))) + ) + "
    " + - "
    Bakery
    " + + dt("BSD") + "
    " + - "
      " + - "
    1. Bread
    2. " + - "
    " + + ol(LIST_STYLE_TYPE_DECIMAL, li("FreeBSD"), li("NetBSD")) + + "
    " + + "
    " + + "
    " + "
    " ); diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/Html.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/Html.java new file mode 100644 index 00000000..d3e9abf6 --- /dev/null +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/Html.java @@ -0,0 +1,49 @@ +package org.asciidoctor.maven.site.ast.processors.test; + +public class Html { + + public static final String LIST_STYLE_TYPE_DECIMAL = "list-style-type: decimal"; + + public static String strong(String text) { + return htmlElement("strong", text); + } + + public static String italics(String text) { + return htmlElement("em", text); + } + + public static String monospace(String text) { + return htmlElement("code", text); + } + + public static String ul(String... elements) { + return htmlElement("ul", String.join("", elements)); + } + + public static String ol(String style, String... elements) { + return htmlElement("ol", style, String.join("", elements)); + } + + public static String li(String text) { + return htmlElement("li", text); + } + + public static String dt(String text) { + return htmlElement("dt", text); + } + + public static String dd(String text) { + return htmlElement("dd", text); + } + + static String htmlElement(String element, String text) { + return htmlElement(element, null, text); + } + + static String htmlElement(String element, String style, String text) { + if (style == null) { + return String.format("<%1$s>%2$s", element, text).trim(); + } + return String.format("<%1$s style=\"%3$s\">%2$s", element, text, style).trim(); + } +} diff --git a/docs/modules/site-integration/pages/parser-module-setup-and-configuration.adoc b/docs/modules/site-integration/pages/parser-module-setup-and-configuration.adoc index 5526a2d8..154f5750 100644 --- a/docs/modules/site-integration/pages/parser-module-setup-and-configuration.adoc +++ b/docs/modules/site-integration/pages/parser-module-setup-and-configuration.adoc @@ -180,6 +180,8 @@ This module is still under development, here is a summary of supported features: ** Ordered, only arabic numerals ** Description lists, with nested ordered, unordered and description lists ** Formatted text in list items ++ +NOTE: Unlike in Asciidoctor lists, descriptions are not surrounded by `

    ` and list themselves are not surrounded by `

    ` elements. * Code blocks with source-highlighting using https://maven.apache.org/skins/maven-fluido-skin/#source-code-line-numbers[Fluido Skin Pretiffy]. ** Support for numbered lines with `linenums`