docs: load custom lexer with plain Python import

The next commit will load another of our Python extensions from a
separate file. That extension will contain more than just a Pygments
lexer, so instead of using a function that can only load a lexer,
just import from the module to keep things consistent.
This commit is contained in:
Johannes Altmanninger 2022-01-16 13:23:09 +01:00 committed by David Adam
parent 89e85e05e0
commit 1c21e26d08

View file

@ -8,8 +8,8 @@
import glob import glob
import os.path import os.path
import pygments
import subprocess import subprocess
import sys
from sphinx.errors import SphinxWarning from sphinx.errors import SphinxWarning
from docutils import nodes from docutils import nodes
@ -41,10 +41,10 @@ def setup(app):
from sphinx.highlighting import lexers from sphinx.highlighting import lexers
this_dir = os.path.dirname(os.path.realpath(__file__)) this_dir = os.path.dirname(os.path.realpath(__file__))
fish_indent_lexer = pygments.lexers.load_lexer_from_file( sys.path.insert(0, this_dir)
os.path.join(this_dir, "fish_indent_lexer.py"), lexername="FishIndentLexer" from fish_indent_lexer import FishIndentLexer
)
lexers["fish-docs-samples"] = fish_indent_lexer lexers["fish-docs-samples"] = FishIndentLexer()
app.add_config_value("issue_url", default=None, rebuild="html") app.add_config_value("issue_url", default=None, rebuild="html")
app.add_role("issue", issue_role) app.add_role("issue", issue_role)
@ -53,17 +53,6 @@ def setup(app):
# The default language to assume # The default language to assume
highlight_language = "fish-docs-samples" highlight_language = "fish-docs-samples"
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
project = "fish-shell" project = "fish-shell"