Skip to content

Commit 5aeff72

Browse files
authored
Merge pull request #140 from scijava/scijava-ops-docs/fijigroovy-lexer
Add custom Groovy lexer to sphinx/rtd
2 parents a85a5b3 + d116072 commit 5aeff72

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

docs/conf.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

77
# -- General configuration ---------------------------------------------------
8-
8+
import sys
9+
import os
910
from multiproject.utils import get_project
1011

12+
sys.path.insert(0, os.path.abspath('.'))
13+
1114
# Add any Sphinx extension module names here, as strings. They can be
1215
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1316
# ones.
@@ -56,6 +59,13 @@
5659
myst_heading_anchors = 4
5760
nb_execution_mode = "off"
5861

62+
# -- Custom Lexers -----------------------------------------------------------
63+
64+
from lexers import SciJavaGroovyLexer
65+
66+
def setup(app):
67+
app.add_lexer('scijava-groovy', SciJavaGroovyLexer)
68+
5969
# -- Options for HTML output -------------------------------------------------
6070

6171
# The theme to use for HTML and HTML Help pages. See the documentation for

docs/lexers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pygments.lexer import inherit
2+
from pygments.lexers.jvm import GroovyLexer
3+
from pygments.token import Comment
4+
5+
class SciJavaGroovyLexer(GroovyLexer):
6+
tokens = {
7+
'base': [
8+
(r'#@.*?$', Comment.Single),
9+
inherit,
10+
]
11+
}

docs/ops/doc/examples/example_gaussian_subtraction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SciJava Ops via Fiji's sripting engine with `script parameters`_:
99

1010
.. tabs::
1111

12-
.. code-tab:: groovy
12+
.. code-tab:: scijava-groovy
1313

1414
#@ ImgPlus img
1515
#@ Double (label="Sigma:", value=5.0) sigma

0 commit comments

Comments
 (0)