From 4ad1e9a77829464e1962bd13044ce16cf51c5466 Mon Sep 17 00:00:00 2001 From: rmpestano Date: Fri, 4 Sep 2020 15:24:41 +0200 Subject: [PATCH] Fixes #1.5.8 --- cukedoctor-converter/pom.xml | 2 - cukedoctor-extension/pom.xml | 11 --- .../CukedoctorExtensionRegistry.java | 2 +- .../extension/CukedoctorFilterExtension.java | 10 +-- .../extension/CukedoctorFooterExtension.java | 76 +++++++++---------- .../extension/CukedoctorMinMaxExtension.java | 15 +--- .../extension/CukedoctorScriptExtension.java | 30 ++++---- .../extension/CukedoctorStyleExtension.java | 21 ++--- .../extension/CukedoctorThemeExtension.java | 4 - ...tor.jruby.extension.spi.ExtensionRegistry} | 0 cukedoctor-main/pom.xml | 9 +-- .../com/github/cukedoctor/CukedoctorMain.java | 2 - cukedoctor-maven-plugin/pom.xml | 4 - pom.xml | 16 +--- 14 files changed, 64 insertions(+), 138 deletions(-) rename cukedoctor-extension/src/main/resources/META-INF/services/{org.asciidoctor.extension.spi.ExtensionRegistry => org.asciidoctor.jruby.extension.spi.ExtensionRegistry} (100%) diff --git a/cukedoctor-converter/pom.xml b/cukedoctor-converter/pom.xml index 16d332e0..bb4233d2 100644 --- a/cukedoctor-converter/pom.xml +++ b/cukedoctor-converter/pom.xml @@ -36,7 +36,6 @@ cukedoctor-extension ${project.parent.version} - io.github.robwin markup-document-builder @@ -52,7 +51,6 @@ 1.11.3 provided - io.cucumber cucumber-junit diff --git a/cukedoctor-extension/pom.xml b/cukedoctor-extension/pom.xml index dc408d9b..59595482 100644 --- a/cukedoctor-extension/pom.xml +++ b/cukedoctor-extension/pom.xml @@ -23,17 +23,6 @@ org.asciidoctor asciidoctorj provided - - - org.jruby - jruby-complete - - - - - org.jruby - jruby-complete - provided org.jsoup diff --git a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorExtensionRegistry.java b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorExtensionRegistry.java index 48e88b20..bef5341b 100644 --- a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorExtensionRegistry.java +++ b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorExtensionRegistry.java @@ -2,7 +2,7 @@ import org.asciidoctor.Asciidoctor; import org.asciidoctor.extension.ExtensionGroup; -import org.asciidoctor.extension.spi.ExtensionRegistry; +import org.asciidoctor.jruby.extension.spi.ExtensionRegistry; public class CukedoctorExtensionRegistry implements ExtensionRegistry { diff --git a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorFilterExtension.java b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorFilterExtension.java index 08d423f5..bf3711c1 100644 --- a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorFilterExtension.java +++ b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorFilterExtension.java @@ -1,14 +1,12 @@ package com.github.cukedoctor.extension; -import static com.github.cukedoctor.extension.CukedoctorExtensionRegistry.*; - import org.asciidoctor.ast.Document; import org.asciidoctor.extension.Postprocessor; import org.jsoup.Jsoup; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; -import java.util.Map; +import static com.github.cukedoctor.extension.CukedoctorExtensionRegistry.FILTER_DISABLE_EXT_KEY; /** * Created by pestano on 20/07/15. @@ -16,13 +14,9 @@ */ public class CukedoctorFilterExtension extends Postprocessor { - public CukedoctorFilterExtension(Map config) { - super(config); - } - @Override public String process(Document document, String output) { - if (document.basebackend("html") && System.getProperty(FILTER_DISABLE_EXT_KEY) == null) { + if (document.isBasebackend("html") && System.getProperty(FILTER_DISABLE_EXT_KEY) == null) { org.jsoup.nodes.Document doc = Jsoup.parse(output, "UTF-8"); Elements sect1 = doc.getElementsByClass("sect1"); diff --git a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorFooterExtension.java b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorFooterExtension.java index 6b596a70..b7a912f7 100644 --- a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorFooterExtension.java +++ b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorFooterExtension.java @@ -15,47 +15,43 @@ */ public class CukedoctorFooterExtension extends Postprocessor { - private static final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT); - - public CukedoctorFooterExtension(Map config) { - super(config); - } - - @Override - public String process(Document document, String output) { - if (document.basebackend("html") && System.getProperty("cukedoctor.disable.footer") == null) { - String stopWatch = System.getProperty("cukedoctor.stopwatch"); - Double generationTimeInSeconds = new Double(0); - String documentationDate = dateFormat.format(new Date()); - String cukedoctorVersion = ""; - try { - ResourceBundle bundle = new PropertyResourceBundle(CukedoctorFooterExtension.class.getResourceAsStream("/cukedoctor-extension.properties")); - cukedoctorVersion = bundle.getString("cukedoctor.version"); - } catch (Exception e) { - Logger.getLogger(getClass().getName()).warning("Could not find bundle cukedoctor-extension"); - } - - if (stopWatch != null && !"".equals(stopWatch)) { - long begin = 0; - try { - begin = Long.parseLong(stopWatch); - generationTimeInSeconds = (System.currentTimeMillis() - begin) / 1000.0; - } catch (NumberFormatException e) { + private static final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT); + + @Override + public String process(Document document, String output) { + if (document.isBasebackend("html") && System.getProperty("cukedoctor.disable.footer") == null) { + String stopWatch = System.getProperty("cukedoctor.stopwatch"); + Double generationTimeInSeconds = new Double(0); + String documentationDate = dateFormat.format(new Date()); + String cukedoctorVersion = ""; + try { + ResourceBundle bundle = new PropertyResourceBundle(CukedoctorFooterExtension.class.getResourceAsStream("/cukedoctor-extension.properties")); + cukedoctorVersion = bundle.getString("cukedoctor.version"); + } catch (Exception e) { + Logger.getLogger(getClass().getName()).warning("Could not find bundle cukedoctor-extension"); + } + + if (stopWatch != null && !"".equals(stopWatch)) { + long begin = 0; + try { + begin = Long.parseLong(stopWatch); + generationTimeInSeconds = (System.currentTimeMillis() - begin) / 1000.0; + } catch (NumberFormatException e) { + } + } + org.jsoup.nodes.Document doc = Jsoup.parse(output, "UTF-8"); + Element contentElement = doc.getElementById("footer"); + contentElement.attr("style", "color:gray;font-size:11px"); + contentElement.text("Generated by ").append(" Cukedoctor " + + cukedoctorVersion + + ""); + contentElement.append(" - " + documentationDate); + contentElement.append(" Execution time: " + + +generationTimeInSeconds + " seconds"); + return doc.html(); + } else { + return output; } - } - org.jsoup.nodes.Document doc = Jsoup.parse(output, "UTF-8"); - Element contentElement = doc.getElementById("footer"); - contentElement.attr("style","color:gray;font-size:11px"); - contentElement.text("Generated by ").append(" Cukedoctor " + - cukedoctorVersion + - ""); - contentElement.append(" - " + documentationDate); - contentElement.append(" Execution time: " + - + generationTimeInSeconds + " seconds"); - return doc.html(); - } else { - return output; } - } } diff --git a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorMinMaxExtension.java b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorMinMaxExtension.java index cdc387d3..98ed7cfc 100644 --- a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorMinMaxExtension.java +++ b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorMinMaxExtension.java @@ -2,10 +2,7 @@ import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.extension.BlockMacroProcessor; -import org.asciidoctor.extension.Reader; -import java.util.Arrays; -import java.util.HashMap; import java.util.Map; /** @@ -13,14 +10,9 @@ */ public class CukedoctorMinMaxExtension extends BlockMacroProcessor { - public CukedoctorMinMaxExtension(String name, Map config) { - super(name, config); - } - @Override public Object process(StructuralNode parent, String target, Map map) { - String backend = parent.getAttribute("backend") != null ? parent.getAttribute("backend").toString() : ""; - if (backend.contains("html")) { + if (!parent.getDocument().isBasebackend("pdf")) { StringBuilder minMax = new StringBuilder(); minMax.append(" append(""); - - return createBlock(parent, "pass", Arrays.asList(minMax.toString()), this.getConfig(),new HashMap()); + return createBlock(parent, "pass", minMax.toString()); } else { - return parent; + return null; } } diff --git a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorScriptExtension.java b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorScriptExtension.java index d6464173..77e112a4 100644 --- a/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorScriptExtension.java +++ b/cukedoctor-extension/src/main/java/com/github/cukedoctor/extension/CukedoctorScriptExtension.java @@ -17,10 +17,6 @@ public class CukedoctorScriptExtension extends Postprocessor { private static final Boolean HIDE_FEATURES_SECTION = System.getProperty("HIDE_FEATURES_SECTION") == null ? Boolean.FALSE : Boolean.valueOf(System.getProperty("HIDE_FEATURES_SECTION")); - public CukedoctorScriptExtension(Map config) { - super(config); - } - @Override public String process(Document document, String output) { if (document.isBasebackend("html")) { @@ -171,7 +167,7 @@ private String getMinMaxScriptForDocWithoutFeaturesSection() { private void addSearchScript(Element contentElement) { String searchScripts = "