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

amolina pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-cookbook.git


The following commit(s) were added to refs/heads/main by this push:
     new 37ac343  Add highlighting to testcode nodes (#164)
37ac343 is described below

commit 37ac343cd58d42d43ad2d6a23c414d48581f91c6
Author: Alessandro Molina <[email protected]>
AuthorDate: Fri Mar 18 15:15:26 2022 +0100

    Add highlighting to testcode nodes (#164)
---
 java/ext/javadoctest.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/java/ext/javadoctest.py b/java/ext/javadoctest.py
index 1a55dd5..7a1604b 100644
--- a/java/ext/javadoctest.py
+++ b/java/ext/javadoctest.py
@@ -7,6 +7,13 @@ from sphinx.ext.doctest import (Any, Dict, DocTestBuilder, 
TestcodeDirective,
 from sphinx.locale import __
 
 
+class JavaTestcodeDirective(TestcodeDirective):
+    def run(self):
+        node_list = super().run()
+        node_list[0]["language"] = "java"
+        return node_list
+
+
 class JavaDocTestBuilder(DocTestBuilder):
     """
     Runs java test snippets in the documentation.
@@ -76,7 +83,7 @@ class JavaDocTestBuilder(DocTestBuilder):
         return output
 
 def setup(app) -> Dict[str, Any]:
-    app.add_directive("testcode", TestcodeDirective)
+    app.add_directive("testcode", JavaTestcodeDirective)
     app.add_directive("testoutput", TestoutputDirective)
     app.add_builder(JavaDocTestBuilder)
     # this config value adds to sys.path

Reply via email to