Skip to content

Commit

Permalink
Merge pull request #140 from scijava/scijava-ops-docs/fijigroovy-lexer
Browse files Browse the repository at this point in the history
Add custom Groovy lexer to sphinx/rtd
  • Loading branch information
ctrueden authored Mar 27, 2024
2 parents a85a5b3 + d116072 commit 5aeff72
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
12 changes: 11 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- General configuration ---------------------------------------------------

import sys
import os
from multiproject.utils import get_project

sys.path.insert(0, os.path.abspath('.'))

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
Expand Down Expand Up @@ -56,6 +59,13 @@
myst_heading_anchors = 4
nb_execution_mode = "off"

# -- Custom Lexers -----------------------------------------------------------

from lexers import SciJavaGroovyLexer

def setup(app):
app.add_lexer('scijava-groovy', SciJavaGroovyLexer)

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down
11 changes: 11 additions & 0 deletions docs/lexers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pygments.lexer import inherit
from pygments.lexers.jvm import GroovyLexer
from pygments.token import Comment

class SciJavaGroovyLexer(GroovyLexer):
tokens = {
'base': [
(r'#@.*?$', Comment.Single),
inherit,
]
}
2 changes: 1 addition & 1 deletion docs/ops/doc/examples/example_gaussian_subtraction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SciJava Ops via Fiji's sripting engine with `script parameters`_:

.. tabs::

.. code-tab:: groovy
.. code-tab:: scijava-groovy

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

0 comments on commit 5aeff72

Please sign in to comment.