diff --git a/docs-extensions/pom.xml b/docs-extensions/pom.xml deleted file mode 100644 index 1d40743c79..0000000000 --- a/docs-extensions/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-contract-parent - 1.0.2.BUILD-SNAPSHOT - .. - - spring-cloud-contract-docs-extensions - jar - Spring Cloud Contract Docs Extensions - Spring Cloud Docs Extensions - - 1.5.2 - - - - - maven-deploy-plugin - - true - - - - - - - org.asciidoctor - asciidoctorj - ${asciidoctorj.version} - - - junit - junit - - - org.assertj - assertj-core - test - - - diff --git a/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/CodeBlockSwitchExtension.java b/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/CodeBlockSwitchExtension.java deleted file mode 100644 index 7ff31e4065..0000000000 --- a/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/CodeBlockSwitchExtension.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.asciidoctor; - -import org.asciidoctor.Asciidoctor; -import org.asciidoctor.extension.spi.ExtensionRegistry; - -public class CodeBlockSwitchExtension implements ExtensionRegistry { - - @Override - public void register(Asciidoctor asciidoctor) { - asciidoctor.javaExtensionRegistry().postprocessor(new CodeBlockSwitchPostProcessor()); - } -} \ No newline at end of file diff --git a/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/CodeBlockSwitchPostProcessor.java b/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/CodeBlockSwitchPostProcessor.java deleted file mode 100644 index 75d1c1d7c9..0000000000 --- a/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/CodeBlockSwitchPostProcessor.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.asciidoctor; - -import org.asciidoctor.ast.Document; -import org.asciidoctor.extension.Postprocessor; - -class CodeBlockSwitchPostProcessor extends Postprocessor { - - private final ResourceReplacer resourceReplacer = new ResourceReplacer(); - - @Override - public String process(Document document, String output) { - return this.resourceReplacer.replaceOutput(output); - } - -} \ No newline at end of file diff --git a/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/ResourceReplacer.java b/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/ResourceReplacer.java deleted file mode 100644 index 94b159d1cc..0000000000 --- a/docs-extensions/src/main/java/org/springframework/cloud/asciidoctor/ResourceReplacer.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.springframework.cloud.asciidoctor; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -/** - * @author Marcin Grzejszczak - */ -class ResourceReplacer { - - String replaceOutput(String output) { - String css = resourceToText("/codeBlockSwitch.css"); - String javascript = resourceToText("/codeBlockSwitch.js"); - String replacement = "\n" - + "\n\n" - + "\n" - + ""; - return output.replace("", replacement); - } - - private String resourceToText(String name) { - return getStringFromInputStream(getClass().getResourceAsStream(name)); - } - - private static String getStringFromInputStream(InputStream is) { - BufferedReader br = null; - StringBuilder sb = new StringBuilder(); - String line; - try { - br = new BufferedReader(new InputStreamReader(is)); - while ((line = br.readLine()) != null) { - sb.append(line); - } - } catch (IOException e) { - return ""; - } - finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - return ""; - } - } - } - return sb.toString(); - } -} diff --git a/docs-extensions/src/main/resources/META-INF/services/org.asciidoctor.extension.spi.ExtensionRegistry b/docs-extensions/src/main/resources/META-INF/services/org.asciidoctor.extension.spi.ExtensionRegistry deleted file mode 100644 index 15b58b59ad..0000000000 --- a/docs-extensions/src/main/resources/META-INF/services/org.asciidoctor.extension.spi.ExtensionRegistry +++ /dev/null @@ -1 +0,0 @@ -org.springframework.cloud.asciidoctor.CodeBlockSwitchExtension \ No newline at end of file diff --git a/docs-extensions/src/main/resources/codeBlockSwitch.css b/docs-extensions/src/main/resources/codeBlockSwitch.css deleted file mode 100644 index 6fb1947b1c..0000000000 --- a/docs-extensions/src/main/resources/codeBlockSwitch.css +++ /dev/null @@ -1,23 +0,0 @@ -.hidden { - display: none; -} - -.switch { - border-width: 1px 1px 0 1px; - border-style: solid; - border-color: #7a2518; - display: inline-block; -} - -.switch--item { - padding: 10px; - background-color: #ffffff; - color: #7a2518; - display: inline-block; - cursor: pointer; -} - -.switch--item.selected { - background-color: #7a2519; - color: #ffffff; -} \ No newline at end of file diff --git a/docs-extensions/src/main/resources/codeBlockSwitch.js b/docs-extensions/src/main/resources/codeBlockSwitch.js deleted file mode 100644 index 13ac0fc1e5..0000000000 --- a/docs-extensions/src/main/resources/codeBlockSwitch.js +++ /dev/null @@ -1,45 +0,0 @@ -function addBlockSwitches() { - $('.primary').each(function() { - primary = $(this); - createSwitchItem(primary, createBlockSwitch(primary)).item.addClass("selected"); - primary.children('.title').remove(); - }); - $('.secondary').each(function(idx, node) { - secondary = $(node); - primary = findPrimary(secondary); - switchItem = createSwitchItem(secondary, primary.children('.switch')); - switchItem.content.addClass('hidden'); - findPrimary(secondary).append(switchItem.content); - secondary.remove(); - }); -} - -function createBlockSwitch(primary) { - blockSwitch = $('
'); - primary.prepend(blockSwitch); - return blockSwitch; -} - -function findPrimary(secondary) { - candidate = secondary.prev(); - while (!candidate.is('.primary')) { - candidate = candidate.prev(); - } - return candidate; -} - -function createSwitchItem(block, blockSwitch) { - blockName = block.children('.title').text(); - content = block.children('.content').first().append(block.next('.colist')); - item = $('
' + blockName + '
'); - item.on('click', '', content, function(e) { - $(this).addClass('selected'); - $(this).siblings().removeClass('selected'); - e.data.siblings('.content').addClass('hidden'); - e.data.removeClass('hidden'); - }); - blockSwitch.append(item); - return {'item': item, 'content': content}; -} - -$(addBlockSwitches); \ No newline at end of file diff --git a/docs-extensions/src/test/java/org/springframework/cloud/asciidoctor/ResourceReplacerTests.java b/docs-extensions/src/test/java/org/springframework/cloud/asciidoctor/ResourceReplacerTests.java deleted file mode 100644 index 4857524769..0000000000 --- a/docs-extensions/src/test/java/org/springframework/cloud/asciidoctor/ResourceReplacerTests.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.springframework.cloud.asciidoctor; - -import org.junit.Test; - -import static org.assertj.core.api.BDDAssertions.then; - -/** - * @author Marcin Grzejszczak - */ -public class ResourceReplacerTests { - - @Test - public void should_process_the_resources() throws Exception { - ResourceReplacer replacer = new ResourceReplacer(); - - String output = replacer.replaceOutput(""); - - then(output).contains("http://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.6/zepto.min.js"); - } - -} \ No newline at end of file diff --git a/docs/pom.xml b/docs/pom.xml index 7189068602..68e0b35957 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -39,9 +39,9 @@ false - org.springframework.cloud - spring-cloud-contract-docs-extensions - ${project.version} + io.spring.asciidoctor + spring-asciidoctor-extensions + 0.1.0.BUILD-SNAPSHOT diff --git a/pom.xml b/pom.xml index 5520d4adaf..0546ec670b 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,6 @@ spring-cloud-contract-dependencies - docs-extensions docs spring-cloud-contract-wiremock spring-cloud-contract-verifier diff --git a/scripts/generateDocs.sh b/scripts/generateDocs.sh index 77ee034333..c730dd17c3 100755 --- a/scripts/generateDocs.sh +++ b/scripts/generateDocs.sh @@ -7,7 +7,7 @@ set -e echo "Generating docs for Spring Cloud Contract" echo "Building main docs" -./mvnw clean install -P docs -DskipTests=true --pl docs-extensions,docs +./mvnw clean install -P docs -DskipTests=true --pl docs echo "Building maven plugin docs" ./mvnw site -DskipTests=true --pl spring-cloud-contract-tools/spring-cloud-contract-maven-plugin