This is an automated email from the ASF dual-hosted git repository.

xiazcy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 70cd4293c5d158d2ef1d6f384c485f79d6275a32
Merge: 8bdc4ef7d6 2718dbbbf5
Author: Yang Xia <[email protected]>
AuthorDate: Tue Sep 1 13:46:24 2026 -0700

    Merge branch '3.8-dev'
    
    # Conflicts:
    #       
docs/tinkeradoc-extension/src/main/java/org/apache/tinkerpop/tinkeradoc/GremlinTreeprocessor.java

 docs/sass/tabs.scss                                | 53 +++++++++++-
 docs/stylesheets/tinkerpop.css                     |  6 +-
 .../apache/tinkerpop/tinkeradoc/GraphCatalog.java  | 96 ++++++++++++++++++++++
 .../tinkerpop/tinkeradoc/GremlinTreeprocessor.java | 52 ++++++------
 .../tinkerpop/tinkeradoc/HtmlTabRenderer.java      | 16 +++-
 .../tinkerpop/tinkeradoc/MarkdownTabRenderer.java  | 15 ++++
 .../apache/tinkerpop/tinkeradoc/NeutralTab.java    |  6 +-
 .../tinkerpop/tinkeradoc/TabbedHtmlBuilder.java    | 47 ++++++++++-
 .../tinkeradoc/DualBackendIntegrationTest.java     |  2 +-
 .../tinkerpop/tinkeradoc/GraphCatalogTest.java     | 65 +++++++++++++++
 .../tinkeradoc/GremlinTreeprocessorTest.java       | 66 ++++++++++++++-
 .../tinkerpop/tinkeradoc/HtmlTabRendererTest.java  |  4 +-
 .../tinkerpop/tinkeradoc/IntegrationTest.java      |  2 +-
 .../tinkeradoc/MarkdownTabRendererTest.java        | 18 +++-
 .../tinkeradoc/TabbedHtmlBuilderTest.java          | 33 +++++++-
 15 files changed, 432 insertions(+), 49 deletions(-)

diff --cc 
docs/tinkeradoc-extension/src/main/java/org/apache/tinkerpop/tinkeradoc/GraphCatalog.java
index 0000000000,4aa1011406..9543146e59
mode 000000,100644..100644
--- 
a/docs/tinkeradoc-extension/src/main/java/org/apache/tinkerpop/tinkeradoc/GraphCatalog.java
+++ 
b/docs/tinkeradoc-extension/src/main/java/org/apache/tinkerpop/tinkeradoc/GraphCatalog.java
@@@ -1,0 -1,95 +1,96 @@@
+ /*
+  * 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.
+  */
+ package org.apache.tinkerpop.tinkeradoc;
+ 
+ import java.util.Collections;
+ import java.util.HashMap;
+ import java.util.Map;
+ 
+ /**
+  * Canonical registry of the toy graph datasets referenced by Gremlin 
documentation examples.
+  * <p>
+  * This is the single source of truth shared by two concerns that must never 
disagree about the set
+  * of datasets:
+  * <ul>
+  *   <li><b>execution</b> — the Gremlin statement run to build the graph 
before an example
+  *       ({@link GremlinTreeprocessor}); and</li>
+  *   <li><b>rendering</b> — the dataset caption shown beneath an example and 
its link to the
+  *       Sample Data book section ({@link TabbedHtmlBuilder}).</li>
+  * </ul>
+  * Adding a graph is therefore a one-line change here that feeds both, so a 
new dataset can never be
+  * executable-but-unlabeled (or vice versa).
+  */
+ final class GraphCatalog {
+ 
+     /** A dataset entry: how to construct it, how to name it, and where its 
Sample Data book section lives. */
+     static final class Entry {
+         /** Gremlin statement that constructs the graph into the {@code 
graph} binding. */
+         final String initStatement;
+         /** Human-readable name used in the rendered dataset caption. */
+         final String displayName;
+         /** Sample Data book section anchor, or {@code null} if the graph has 
no dedicated section. */
+         final String docAnchor;
+ 
+         Entry(final String initStatement, final String displayName, final 
String docAnchor) {
+             this.initStatement = initStatement;
+             this.displayName = displayName;
+             this.docAnchor = docAnchor;
+         }
+     }
+ 
+     /** Init statement for a bare block or any unrecognized token: a fresh, 
empty graph. */
+     static final String DEFAULT_INIT = "graph = TinkerGraph.open()";
+ 
+     private static final Map<String, Entry> BY_TOKEN;
+ 
+     static {
+         final Map<String, Entry> m = new HashMap<>();
+         // "crew" and "theCrew" are aliases for the same dataset.
+         final Entry crew = new Entry("graph = TinkerFactory.createTheCrew()", 
"crew", "the-crew");
+         m.put("modern", new Entry("graph = TinkerFactory.createModern()", 
"modern", "modern"));
+         m.put("classic", new Entry("graph = TinkerFactory.createClassic()", 
"classic", null));
+         m.put("crew", crew);
+         m.put("theCrew", crew);
+         m.put("grateful", new Entry("graph = 
TinkerFactory.createGratefulDead()", "Grateful Dead", "grateful-dead"));
+         m.put("airroutes", new Entry("graph = 
TinkerFactory.createAirRoutes()", "Air Routes", "air-routes"));
++        m.put("theZoo", new Entry("graph = TinkerFactory.createTheZoo()", 
"Zoo", "the-zoo"));
+         m.put("sink", new Entry("graph = TinkerFactory.createKitchenSink()", 
"kitchen sink", null));
+         BY_TOKEN = Collections.unmodifiableMap(m);
+     }
+ 
+     private GraphCatalog() {
+     }
+ 
+     /**
+      * Returns the catalog entry for a dataset token, or {@code null} if the 
token is not a known
+      * dataset (including {@code null}, a bare block, or a misspelling).
+      */
+     static Entry entry(final String token) {
+         return token == null ? null : BY_TOKEN.get(token);
+     }
+ 
+     /**
+      * Returns the Gremlin init statement for a token, falling back to {@link 
#DEFAULT_INIT} (a fresh
+      * empty graph) for {@code null} or unrecognized tokens.
+      */
+     static String initStatement(final String token) {
+         final Entry e = entry(token);
+         return e != null ? e.initStatement : DEFAULT_INIT;
+     }
+ }
diff --cc 
docs/tinkeradoc-extension/src/main/java/org/apache/tinkerpop/tinkeradoc/GremlinTreeprocessor.java
index a8ee92ef83,a39d2f4104..d558414105
--- 
a/docs/tinkeradoc-extension/src/main/java/org/apache/tinkerpop/tinkeradoc/GremlinTreeprocessor.java
+++ 
b/docs/tinkeradoc-extension/src/main/java/org/apache/tinkerpop/tinkeradoc/GremlinTreeprocessor.java
@@@ -677,19 -682,16 +682,14 @@@ public class GremlinTreeprocessor exten
              return;
          }
  
 -        // Clear file-backed graph stores reused across blocks. Neo4j holds 
an exclusive
 -        // store lock, so a stale '/tmp/neo4j' left by a prior block (or 
prior build run)
 -        // makes the next Neo4jGraph.open('/tmp/neo4j') hang acquiring the 
lock. Close any
 -        // prior graph to release its lock, then delete the dirs -- mirroring 
the old
 -        // preprocessor which cleared these before every graph-init block.
 +        // Close any prior graph to release resources, then delete 
file-backed stores reused
 +        // across blocks so stale state from a prior block (or prior build 
run) doesn't leak
 +        // into the next graph-init -- mirroring the old preprocessor which 
cleared these
 +        // before every graph-init block.
          executeSafely("try { if (binding.hasVariable('graph') && graph != 
null) graph.close() } catch (e) {}");
 -        executeSafely("['/tmp/neo4j', '/tmp/tinkergraph.kryo'].each { p -> "
 -                + "def f = new File(p); if (f.exists()) f.deleteDir() }");
 +        executeSafely("def f = new File('/tmp/tinkergraph.kryo'); if 
(f.exists()) f.deleteDir()");
  
-         final String initStatement;
-         if (graphName == null) {
-             initStatement = "graph = TinkerGraph.open()";
-         } else {
-             initStatement = GRAPH_INIT.getOrDefault(graphName, "graph = 
TinkerGraph.open()");
-         }
+         final String initStatement = GraphCatalog.initStatement(graphName);
  
          executeSafely(initStatement);
          executeSafely("g = graph.traversal()");

Reply via email to