diff --git a/README.adoc b/README.adoc index a0debc51..9b1a46a8 100755 --- a/README.adoc +++ b/README.adoc @@ -45,7 +45,7 @@ ____ image::cukedoctor-sample.png[] -The feature file for the above sample can be https://github.com/rmpestano/dbunit-rules/blob/master/cdi/src/test/resources/features/core/core-seed-database.feature[found here^]. +The feature file for the above sample can be https://github.com/database-rider/database-rider/blob/master/rider-core/src/test/resources/features/rider-core/core-seed-database.feature[found here^]. Failing steps are rendered as follows: @@ -71,6 +71,10 @@ Here are some bdd documentation examples generated by Cukedoctor: |=== |Project | Living documentation +|https://github.com/database-rider/databae-rider[Database Rider^] +|https://database-rider.github.io/database-rider/#documentation + + |https://github.com/asciidoctor/asciidoctor[Asciidoctor^] |http://rmpestano.github.io/cukedoctor/asciidoctor/asciidoctor-documentation.html[html^] / http://rmpestano.github.io/cukedoctor/asciidoctor/asciidoctor-documentation.pdf[pdf^] @@ -86,8 +90,6 @@ Here are some bdd documentation examples generated by Cukedoctor: |https://github.com/sdkman/sdkman-cli[Sdkman^] |http://rmpestano.github.io/cukedoctor/sdkman/sdkman-documentation.html[html^] / http://rmpestano.github.io/cukedoctor/sdkman/sdkman-documentation.pdf[pdf^] -|https://github.com/rmpestano/dbunit-rules[DBUnit Rules^] -|http://rmpestano.github.io/dbunit-rules/documentation.html[html^] / http://rmpestano.github.io/dbunit-rules/documentation.pdf[pdf^] |=== @@ -99,9 +101,9 @@ Here are some bdd documentation examples generated by Cukedoctor: If you use maven and execute your cucumber tests through maven you can use cukedoctor-maven plugin. For more details see https://github.com/rmpestano/cukedoctor/tree/master/cukedoctor-maven-plugin[cukedoctor-maven-plugin]. -=== Standalone jar +=== Standalone jar (a.k.a cli) -To use Cukedoctor as a standalone jar you can https://bintray.com/artifact/download/rmpestano/cukedoctor/com/github/cukedoctor/cukedoctor-main/1.0.4/cukedoctor-main-1.0.4.jar[download it here^]. For more details, see https://github.com/rmpestano/cukedoctor/tree/master/cukedoctor-main[cukedoctor-main]. +To use Cukedoctor as a standalone jar you can https://bintray.com/artifact/download/rmpestano/cukedoctor/com/github/cukedoctor/cukedoctor-main/1.0.6/cukedoctor-main-1.0.6.jar[download it here^]. For more details, see https://github.com/rmpestano/cukedoctor/tree/master/cukedoctor-main[cukedoctor-main]. === Converter diff --git a/cukedoctor-converter/README.adoc b/cukedoctor-converter/README.adoc index 62ce237a..d0ae4741 100644 --- a/cukedoctor-converter/README.adoc +++ b/cukedoctor-converter/README.adoc @@ -13,11 +13,11 @@ This module is responsible for generating adoc files from .json cucumber executi public void shouldSaveDocumentationIntoDisk(){ List pathToCucumberJsonFiles = FileUtil.findJsonFiles("target/test-classes/json-output/"); List features = FeatureParser.parse(pathToCucumberJsonFiles); - DocumentAttributes attrs = new DocumentAttributes(); + DocumentAttributes attrs = DefaultConfig.getInstance().getDocumentAttributes; attrs.toc("left").backend("html5") .docType("book") .icons("font").numbered(false) - .sectAnchors(true).sectLink(true); + .sectAnchors(true).sectLink(true); CukedoctorConverter converter = Cukedoctor.instance(features, "Living Documentation", attrs); converter.setFilename("/target/living_documentation.adoc"); diff --git a/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/CukedoctorConfig.java b/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/CukedoctorConfig.java index 67c53884..db0f3719 100644 --- a/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/CukedoctorConfig.java +++ b/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/CukedoctorConfig.java @@ -4,7 +4,10 @@ /** * Created by pestano on 22/06/15. + * @deprecated use GlobalConfig + * @see GlobalConfig */ +@Deprecated public abstract class CukedoctorConfig { public static final int ERROR_MESSAGE_SIZE = getProperty("ERROR_MESSAGE_SIZE",Integer.class) == null ? 400 : getProperty("ERROR_MESSAGE_SIZE",Integer.class); public static final String DOCUMENT_TITLE= getProperty("DOCUMENT_TITLE") == null ? "Documentation" : getProperty("DOCUMENT_TITLE"); @@ -14,23 +17,23 @@ public abstract class CukedoctorConfig { //lazy evaluation public static Boolean hideSummarySection(){ - return getProperty("HIDE_SUMMARY_SECTION") == null ? GlobalConfig.getInstance().isHideSummarySection() : Boolean.valueOf(getProperty("HIDE_SUMMARY_SECTION")); + return getProperty("HIDE_SUMMARY_SECTION") == null ? GlobalConfig.getInstance().getLayoutConfig().isHideSummarySection() : Boolean.valueOf(getProperty("HIDE_SUMMARY_SECTION")); } public static Boolean hideFeaturesSection(){ - return getProperty("HIDE_FEATURES_SECTION") == null ? GlobalConfig.getInstance().isHideFeaturesSection() : Boolean.valueOf(getProperty("HIDE_FEATURES_SECTION")); + return getProperty("HIDE_FEATURES_SECTION") == null ? GlobalConfig.getInstance().getLayoutConfig().isHideFeaturesSection() : Boolean.valueOf(getProperty("HIDE_FEATURES_SECTION")); } public static Boolean hideStepTime(){ - return getProperty("HIDE_STEP_TIME") == null ? GlobalConfig.getInstance().isHideStepTime() : Boolean.valueOf(getProperty("HIDE_STEP_TIME")); + return getProperty("HIDE_STEP_TIME") == null ? GlobalConfig.getInstance().getLayoutConfig().isHideStepTime() : Boolean.valueOf(getProperty("HIDE_STEP_TIME")); } public static Boolean hideScenarioKeyword(){ - return getProperty("HIDE_SCENARIO_KEYWORD") == null ? GlobalConfig.getInstance().isHideScenarioKeyword() : Boolean.valueOf(getProperty("HIDE_SCENARIO_KEYWORD")); + return getProperty("HIDE_SCENARIO_KEYWORD") == null ? GlobalConfig.getInstance().getLayoutConfig().isHideScenarioKeyword() : Boolean.valueOf(getProperty("HIDE_SCENARIO_KEYWORD")); } public static Boolean hideTags(){ - return getProperty("HIDE_TAGS") == null ? GlobalConfig.getInstance().isHideTags() : Boolean.valueOf(getProperty("HIDE_TAGS")); + return getProperty("HIDE_TAGS") == null ? GlobalConfig.getInstance().getLayoutConfig().isHideTags() : Boolean.valueOf(getProperty("HIDE_TAGS")); } diff --git a/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/GlobalConfig.java b/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/GlobalConfig.java index 3b21f610..5438ade8 100644 --- a/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/GlobalConfig.java +++ b/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/GlobalConfig.java @@ -15,16 +15,7 @@ public class GlobalConfig { private DocumentAttributes documentAttributes; - private boolean hideFeaturesSection; - - private boolean hideSummarySection; - - private boolean hideStepTime; - - private boolean hideScenarioKeyword; - - private boolean hideTags; - + private LayoutConfig layoutConfig; private GlobalConfig() { @@ -59,23 +50,6 @@ private static GlobalConfig createInstance() { return globalConfig; } - - public boolean isHideSummarySection() { - return hideSummarySection; - } - - public void setHideSummarySection(boolean hideSummarySection) { - this.hideSummarySection = hideSummarySection; - } - - public boolean isHideFeaturesSection() { - return hideFeaturesSection; - } - - public void setHideFeaturesSection(boolean hideFeaturesSection) { - this.hideFeaturesSection = hideFeaturesSection; - } - public DocumentAttributes getDocumentAttributes() { return documentAttributes; } @@ -84,27 +58,11 @@ public void setDocumentAttributes(DocumentAttributes documentAttributes) { this.documentAttributes = documentAttributes; } - public boolean isHideStepTime() { - return hideStepTime; - } - - public void setHideStepTime(boolean hideStepTime) { - this.hideStepTime = hideStepTime; - } - - public boolean isHideScenarioKeyword() { - return hideScenarioKeyword; - } - - public void setHideScenarioKeyword(boolean hideScenarioKeyword) { - this.hideScenarioKeyword = hideScenarioKeyword; - } - - public boolean isHideTags() { - return hideTags; + public LayoutConfig getLayoutConfig() { + return layoutConfig; } - public void setHideTags(boolean hideTags) { - this.hideTags = hideTags; + public void setLayoutConfig(LayoutConfig layoutConfig) { + this.layoutConfig = layoutConfig; } } diff --git a/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/LayoutConfig.java b/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/LayoutConfig.java new file mode 100644 index 00000000..06071338 --- /dev/null +++ b/cukedoctor-converter/src/main/java/com/github/cukedoctor/config/LayoutConfig.java @@ -0,0 +1,59 @@ +package com.github.cukedoctor.config; + +/** + * Created by pestano on 23/10/16. + * + * Documentation layout configuration + */ +public class LayoutConfig { + + private boolean hideFeaturesSection; + + private boolean hideSummarySection; + + private boolean hideStepTime; + + private boolean hideScenarioKeyword; + + private boolean hideTags; + + public boolean isHideFeaturesSection() { + return hideFeaturesSection; + } + + public void setHideFeaturesSection(boolean hideFeaturesSection) { + this.hideFeaturesSection = hideFeaturesSection; + } + + public boolean isHideSummarySection() { + return hideSummarySection; + } + + public void setHideSummarySection(boolean hideSummarySection) { + this.hideSummarySection = hideSummarySection; + } + + public boolean isHideStepTime() { + return hideStepTime; + } + + public void setHideStepTime(boolean hideStepTime) { + this.hideStepTime = hideStepTime; + } + + public boolean isHideScenarioKeyword() { + return hideScenarioKeyword; + } + + public void setHideScenarioKeyword(boolean hideScenarioKeyword) { + this.hideScenarioKeyword = hideScenarioKeyword; + } + + public boolean isHideTags() { + return hideTags; + } + + public void setHideTags(boolean hideTags) { + this.hideTags = hideTags; + } +} diff --git a/cukedoctor-converter/src/main/resources/config/cukedoctor.yml b/cukedoctor-converter/src/main/resources/config/cukedoctor.yml index 5d7af6ad..75a745d0 100644 --- a/cukedoctor-converter/src/main/resources/config/cukedoctor.yml +++ b/cukedoctor-converter/src/main/resources/config/cukedoctor.yml @@ -1,8 +1,9 @@ -hideFeaturesSection: false -hideSummarySection: false -hideStepTime: false -hideScenarioKeyword: false -hideTags: false +layoutConfig: + hideFeaturesSection: false + hideSummarySection: false + hideStepTime: false + hideScenarioKeyword: false + hideTags: false documentAttributes: docTitle: "Living Documentation" backend: "html5" diff --git a/cukedoctor-converter/src/test/java/com/github/cukedoctor/converter/CukedoctorConverterTest.java b/cukedoctor-converter/src/test/java/com/github/cukedoctor/converter/CukedoctorConverterTest.java index 406e8d6d..4938fbb4 100644 --- a/cukedoctor-converter/src/test/java/com/github/cukedoctor/converter/CukedoctorConverterTest.java +++ b/cukedoctor-converter/src/test/java/com/github/cukedoctor/converter/CukedoctorConverterTest.java @@ -49,11 +49,11 @@ public static void loadFeatures() { @Before public void initProperties() { - System.setProperty("HIDE_STEP_TIME", GlobalConfig.getInstance().isHideStepTime() + ""); - System.setProperty("HIDE_FEATURES_SECTION", GlobalConfig.getInstance().isHideFeaturesSection() + ""); - System.setProperty("HIDE_SUMMARY_SECTION", GlobalConfig.getInstance().isHideSummarySection() + ""); - System.setProperty("HIDE_SCENARIO_KEYWORD", GlobalConfig.getInstance().isHideScenarioKeyword() + ""); - System.setProperty("HIDE_TAGS", GlobalConfig.getInstance().isHideTags() + ""); + System.setProperty("HIDE_STEP_TIME", GlobalConfig.getInstance().getLayoutConfig().isHideStepTime() + ""); + System.setProperty("HIDE_FEATURES_SECTION", GlobalConfig.getInstance().getLayoutConfig().isHideFeaturesSection() + ""); + System.setProperty("HIDE_SUMMARY_SECTION", GlobalConfig.getInstance().getLayoutConfig().isHideSummarySection() + ""); + System.setProperty("HIDE_SCENARIO_KEYWORD", GlobalConfig.getInstance().getLayoutConfig().isHideScenarioKeyword() + ""); + System.setProperty("HIDE_TAGS", GlobalConfig.getInstance().getLayoutConfig().isHideTags() + ""); } diff --git a/cukedoctor-main/README.adoc b/cukedoctor-main/README.adoc index d7d456c0..43984248 100644 --- a/cukedoctor-main/README.adoc +++ b/cukedoctor-main/README.adoc @@ -19,7 +19,8 @@ public void shouldRenderHtmlForOneFeature(){ "-t", "Living Documentation", <3> "-f", "html", <4> "-toc", "left", <5> - "-numbering", "true" <6> + "-numbering", "true", <6> + "-sourceHighlighter" }); File generatedFile = FileUtil.loadFile("target/document-one.html"); @@ -42,6 +43,8 @@ java -jar cukedoctor-main.jar -o "target/document-one" -p "target/test-classes/json-output/one_passing_one_failing.json" -t "Living Documentation" -f html + -hideSummarySection + -hideScenarioKeyword ---- === Maven exec plugin @@ -81,12 +84,30 @@ You can disable https://github.com/rmpestano/cukedoctor/tree/master/cukedoctor-e ---- java -jar -Dcukedoctor.disable.filter=123 -Dcukedoctor.disable.theme=abc - cukedoctor-main-1.0.2.jar + cukedoctor-main-1.0.6.jar -p cucumber-output.json ---- -You can download Cukedoctor main https://bintray.com/artifact/download/rmpestano/cukedoctor/com/github/cukedoctor/cukedoctor-main/1.0.2/cukedoctor-main-1.0.2.jar[jar here^] +You can download Cukedoctor main https://bintray.com/artifact/download/rmpestano/cukedoctor/com/github/cukedoctor/cukedoctor-main/1.0.6/cukedoctor-main-1.0.6.jar[jar here^] -== Hide Features and Summary +== Layout configuration -You can hide 'Features' and 'Summary' sections, to do so just specify `-hideFeaturesSection` or `-hideSummarySection` parameters. \ No newline at end of file +Some pieces of documentation can be hidden via configuration. + +You can hide `Features` and `Summary` sections, as well as `scenario keyword` which prefixes each scenario and hide `tags` or `step time`. To do so just specify the following arg parameters respectively: + +---- +java -jar -Dcukedoctor.disable.filter=123 -Dcukedoctor.disable.theme=abc + cukedoctor-main-1.0.6.jar + -p cucumber-output.json + -hideFeaturesSection <1> + -hideSummarySection <2> + -hideScenarioKeyword <3> + -hideStepTime <4> + -hideTags <5> +---- +<1> Removes `Features` section so each feature is a section instead of a sub section of `Features`; +<2> Removes summary section +<3> Removes `scenario` keyword which prefixes each scenario; +<4> Removes step time calculation on each step; +<5> Removes tags rendering; diff --git a/cukedoctor-main/src/test/java/com/github/cukedoctor/CukedoctorMainTest.java b/cukedoctor-main/src/test/java/com/github/cukedoctor/CukedoctorMainTest.java index 0ba2d2e2..9f71edfa 100644 --- a/cukedoctor-main/src/test/java/com/github/cukedoctor/CukedoctorMainTest.java +++ b/cukedoctor-main/src/test/java/com/github/cukedoctor/CukedoctorMainTest.java @@ -34,11 +34,11 @@ public void setup() { newOut = new PrintStream(baos); defaultOut = System.out; System.setOut(newOut); - System.setProperty("HIDE_FEATURES_SECTION", Boolean.toString(GlobalConfig.getInstance().isHideFeaturesSection())); - System.setProperty("HIDE_SUMMARY_SECTION", Boolean.toString(GlobalConfig.getInstance().isHideSummarySection())); - System.setProperty("HIDE_SCENARIO_KEYWORD", Boolean.toString(GlobalConfig.getInstance().isHideScenarioKeyword())); - System.setProperty("HIDE_STEP_TIME", Boolean.toString(GlobalConfig.getInstance().isHideStepTime())); - System.setProperty("HIDE_TAGS", Boolean.toString(GlobalConfig.getInstance().isHideTags())); + System.setProperty("HIDE_FEATURES_SECTION", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideFeaturesSection())); + System.setProperty("HIDE_SUMMARY_SECTION", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideSummarySection())); + System.setProperty("HIDE_SCENARIO_KEYWORD", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideScenarioKeyword())); + System.setProperty("HIDE_STEP_TIME", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideStepTime())); + System.setProperty("HIDE_TAGS", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideTags())); } diff --git a/cukedoctor-maven-plugin/README.adoc b/cukedoctor-maven-plugin/README.adoc index b8582e12..93b72421 100644 --- a/cukedoctor-maven-plugin/README.adoc +++ b/cukedoctor-maven-plugin/README.adoc @@ -18,7 +18,7 @@ Just declare the plugin in your _pom.xml_: com.github.cukedoctor cukedoctor-maven-plugin - 1.0.2 + 1.0.6 @@ -51,7 +51,7 @@ NOTE: *plugin* option replaced *format* option which was deprecated in newer cuc com.github.cukedoctor cukedoctor-maven-plugin - 1.0.2 + 1.0.6 documentation <1> docs <2> @@ -130,11 +130,23 @@ mvn cukedoctor:execute | |hideSummarySection -|When present, this flag hides 'Summary' section +|When present, this flag hides `Summary` section | |hideFeaturesSection -|When present, this flag hides 'Features' section +|When present, this flag hides `Features` section +| + +|hideScenarioKeyword +|When present, this flag `Scenario` (and `scenario outline`) keyword which prefixes each scenario; +| + +|hideStepTime +|When present, this flag hides `step time` calculation on each step; +| + +|hideTags +|When present, this flag hides `tags` rendering | |=== diff --git a/cukedoctor-maven-plugin/src/test/java/com/github/cukedoctor/mojo/CukedoctorMojoTest.java b/cukedoctor-maven-plugin/src/test/java/com/github/cukedoctor/mojo/CukedoctorMojoTest.java index 391d0b2c..35deca46 100644 --- a/cukedoctor-maven-plugin/src/test/java/com/github/cukedoctor/mojo/CukedoctorMojoTest.java +++ b/cukedoctor-maven-plugin/src/test/java/com/github/cukedoctor/mojo/CukedoctorMojoTest.java @@ -133,7 +133,7 @@ public void testGenerateHtmlDocsWithoutFeaturesSection() throws Exception { contains("== *Summary*"). doesNotContain("== *Features*"); }finally { - System.setProperty("HIDE_FEATURES_SECTION", Boolean.toString(GlobalConfig.getInstance().isHideFeaturesSection())); + System.setProperty("HIDE_FEATURES_SECTION", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideFeaturesSection())); } } @@ -156,7 +156,7 @@ public void testGenerateHtmlDocsWithoutSummarySection() throws Exception { contains("== *Features*"). doesNotContain("== *Summary*"); }finally { - System.setProperty("HIDE_SUMMARY_SECTION", Boolean.toString(GlobalConfig.getInstance().isHideSummarySection())); + System.setProperty("HIDE_SUMMARY_SECTION", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideSummarySection())); } } @@ -181,7 +181,7 @@ public void testGenerateHtmlDocsWithoutScenarioKeyword() throws Exception { contains("==== Passing"); //[small]#tags: @a,@b#) }finally { - System.setProperty("HIDE_SCENARIO_KEYWORD", Boolean.toString(GlobalConfig.getInstance().isHideScenarioKeyword())); + System.setProperty("HIDE_SCENARIO_KEYWORD", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideScenarioKeyword())); } } @@ -205,7 +205,7 @@ public void testGenerateHtmlDocsWithoutTags() throws Exception { contains("== *Features*"). doesNotContain("[small]#tags:"); }finally { - System.setProperty("HIDE_TAGS", Boolean.toString(GlobalConfig.getInstance().isHideTags())); + System.setProperty("HIDE_TAGS", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideTags())); } } @@ -228,7 +228,7 @@ public void testGenerateHtmlDocsWithoutStepTime() throws Exception { contains("== *Features*"). doesNotContain("[small right]#(001ms)#"); }finally { - System.setProperty("HIDE_STEP_TIME", Boolean.toString(GlobalConfig.getInstance().isHideStepTime())); + System.setProperty("HIDE_STEP_TIME", Boolean.toString(GlobalConfig.getInstance().getLayoutConfig().isHideStepTime())); } }