This is an automated email from the ASF dual-hosted git repository. Cole-Greer pushed a commit to branch docs-3.7 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit f52ce77de193a6742995d17258448bb29565fbdf Author: Cole Greer <[email protected]> AuthorDate: Thu May 21 14:06:29 2026 -0700 Fix console echo, add groovy tab, wire version substitution - Strip command echo (first line) from console results so output matches published format: gremlin> stmt / ==>result - Add second 'groovy' tab with clean source code (no prompts/output) to match the published two-tab format - Pass tinkerpop-version attribute to all asciidoctor executions so the GremlinPostprocessor can substitute x.y.z with actual version - Update tests for new tab count and graph.traversal() init --- pom.xml | 12 ++++++++++++ tools/tinkerpop-docs/REQUIREMENTS.md | 19 +++++++++++++++++++ .../tinkerpop/gremlin/docs/GremlinTreeprocessor.java | 8 ++++++-- .../gremlin/docs/GremlinTreeprocessorTest.java | 14 +++++++------- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 20ca0d968f..039e7a6a0c 100644 --- a/pom.xml +++ b/pom.xml @@ -1087,6 +1087,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1117,6 +1118,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1147,6 +1149,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1177,6 +1180,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1207,6 +1211,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1237,6 +1242,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1267,6 +1273,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1297,6 +1304,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1325,6 +1333,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1354,6 +1363,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1383,6 +1393,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> @@ -1411,6 +1422,7 @@ limitations under the License. <gremlin-docs-console-home>${gremlin.docs.console.home}</gremlin-docs-console-home> <gremlin-docs-hadoop-libs>${gremlin.docs.hadoop.libs}</gremlin-docs-hadoop-libs> <gremlin-docs-dryrun>${gremlin.docs.dryrun}</gremlin-docs-dryrun> + <tinkerpop-version>${project.version}</tinkerpop-version> </attributes> </configuration> </execution> diff --git a/tools/tinkerpop-docs/REQUIREMENTS.md b/tools/tinkerpop-docs/REQUIREMENTS.md index 382e7e74bb..0c7d444a04 100644 --- a/tools/tinkerpop-docs/REQUIREMENTS.md +++ b/tools/tinkerpop-docs/REQUIREMENTS.md @@ -1,3 +1,22 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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. +--> + # TinkerPop Documentation Build - Requirements ## Overview diff --git a/tools/tinkerpop-docs/src/main/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessor.java b/tools/tinkerpop-docs/src/main/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessor.java index 3c731ea454..e59ccb181d 100644 --- a/tools/tinkerpop-docs/src/main/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessor.java +++ b/tools/tinkerpop-docs/src/main/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessor.java @@ -243,6 +243,8 @@ public class GremlinTreeprocessor extends Treeprocessor { final String consoleOutput = buildConsoleOutput(gremlinBlock, dryRun); final List<TabbedHtmlBuilder.Tab> tabs = new ArrayList<>(); tabs.add(TabbedHtmlBuilder.consoleTab("groovy", consoleOutput)); + // Add second tab with clean source code (no prompts/output) + tabs.add(TabbedHtmlBuilder.codeTab("groovy", gremlinBlock.getSource())); // Consume consecutive [source,<lang>] sibling blocks as manual tabs (FR-5) int lastIndex = startIndex; @@ -394,8 +396,10 @@ public class GremlinTreeprocessor extends Treeprocessor { if (!dryRun && getActiveExecutor() != null) { final String result = executeSafely(statement); if (result != null && !result.isEmpty()) { - for (final String resultLine : result.split("\\r?\\n")) { - output.append("\t").append(resultLine).append("\n"); + final String[] resultLines = result.split("\\r?\\n"); + // Skip the first line which is the echo of the command + for (int idx = 1; idx < resultLines.length; idx++) { + output.append(resultLines[idx]).append("\n"); } } } diff --git a/tools/tinkerpop-docs/src/test/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessorTest.java b/tools/tinkerpop-docs/src/test/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessorTest.java index bf51dbe110..5da5a3f8f0 100644 --- a/tools/tinkerpop-docs/src/test/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessorTest.java +++ b/tools/tinkerpop-docs/src/test/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessorTest.java @@ -51,7 +51,7 @@ public class GremlinTreeprocessorTest { assertThat(result, is(notNullValue())); assertThat(processor.getGremlinBlockCount(), is(1)); assertThat(executor.statements.contains("graph = TinkerFactory.createModern()"), is(true)); - assertThat(executor.statements.contains("g = traversal().with(graph)"), is(true)); + assertThat(executor.statements.contains("g = graph.traversal()"), is(true)); assertThat(executor.statements.contains("g.V(1)"), is(true)); } } @@ -68,7 +68,7 @@ public class GremlinTreeprocessorTest { final String result = asciidoctor.convert(input, Options.builder().build()); assertThat(result, is(notNullValue())); assertThat(executor.statements.contains("graph = TinkerGraph.open()"), is(true)); - assertThat(executor.statements.contains("g = traversal().with(graph)"), is(true)); + assertThat(executor.statements.contains("g = graph.traversal()"), is(true)); } } @@ -282,7 +282,7 @@ public class GremlinTreeprocessorTest { asciidoctor.javaExtensionRegistry().treeprocessor(processor); final String input = "= Test\n\n[gremlin-groovy,modern]\n----\ng.V(1)\n----\n"; final String result = asciidoctor.convert(input, Options.builder().build()); - assertThat(result, containsString("section class=\"tabs tabs-1\"")); + assertThat(result, containsString("section class=\"tabs tabs-2\"")); assertThat(result, containsString("console (groovy)")); assertThat(result, containsString("tab-group-1")); } @@ -301,10 +301,10 @@ public class GremlinTreeprocessorTest { "[source,java]\n----\ng.V(1)\n----\n" + "[source,python]\n----\ng.V(1)\n----\n"; final String result = asciidoctor.convert(input, Options.builder().build()); - assertThat(result, containsString("tabs tabs-3")); + assertThat(result, containsString("tabs tabs-4")); assertThat(result, containsString("console (groovy)")); - assertThat(result, containsString("tab-label-2\">java")); - assertThat(result, containsString("tab-label-3\">python")); + assertThat(result, containsString("tab-label-3\">java")); + assertThat(result, containsString("tab-label-4\">python")); } } @@ -321,7 +321,7 @@ public class GremlinTreeprocessorTest { "[source,ruby]\n----\ng.V(1)\n----\n"; final String result = asciidoctor.convert(input, Options.builder().build()); // Only the console tab, ruby is not consumed - assertThat(result, containsString("tabs tabs-1")); + assertThat(result, containsString("tabs tabs-2")); } }
