summaryrefslogtreecommitdiff
path: root/doc/conf.py
diff options
context:
space:
mode:
authorMatthäus G. Chajdas <dev@anteru.net>2022-03-20 10:29:30 +0100
committerMatthäus G. Chajdas <dev@anteru.net>2022-03-20 10:29:30 +0100
commit64e8e05307689fe726ce9df2d5907e9c2fb67405 (patch)
tree1d2f1eb768972ac49933367b9ec127e638cb7466 /doc/conf.py
parent96eaebafc848c989e9fc081768e3156add3128fd (diff)
downloadpygments-git-64e8e05307689fe726ce9df2d5907e9c2fb67405.tar.gz
Rework URL information in lexers.
This commit adds a new url field to a lexer, which can be used to link to the language website, instead of relying on having the link in either languages.rst or the docstring of the lexer. Additionally, it changes the languages.rst file to auto-generate the list of lexers from the actual source code, using the provided URL.
Diffstat (limited to 'doc/conf.py')
-rw-r--r--doc/conf.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/doc/conf.py b/doc/conf.py
index cda21dc5..7af43e37 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -132,7 +132,10 @@ html_sidebars = {'index': ['indexsidebar.html', 'searchbox.html']}
# Additional templates that should be rendered to pages, maps page names to
# template names.
-html_additional_pages = {'styles': 'styles.html'}
+html_additional_pages = {
+ 'styles': 'styles.html',
+ 'languages': 'languages.html'
+ }
if os.environ.get('WEBSITE_BUILD'):
html_additional_pages['demo'] = 'demo.html'
@@ -232,6 +235,14 @@ def pg_context(app, pagename, templatename, ctx, event_arg):
if pagename == 'demo':
ctx['lexers'] = sorted(pygments.lexers.get_all_lexers(), key=lambda x: x[0].lower())
+ if pagename == 'languages':
+ lexer_name_url = []
+
+ for entry in sorted(pygments.lexers.LEXERS.values(), key=lambda x: x[1].lower()):
+ lexer_cls = pygments.lexers.find_lexer_class(entry[1])
+ lexer_name_url.append({'name': entry[1], 'url': lexer_cls.url})
+ ctx['languages'] = lexer_name_url
+
if pagename in ('styles', 'demo'):
with open('examples/example.py') as f:
html = f.read()