From 42d70e15ad2932069aca9434ca3831cc6f210aa0 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 21 Dec 2021 15:45:58 +0100 Subject: [PATCH 1/2] [doc] engine-table: rename Engine column to Module & link --- docs/admin/engines/configured_engines.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/admin/engines/configured_engines.rst b/docs/admin/engines/configured_engines.rst index 4898cd5e..dabd3501 100644 --- a/docs/admin/engines/configured_engines.rst +++ b/docs/admin/engines/configured_engines.rst @@ -30,7 +30,7 @@ Explanation of the :ref:`general engine configuration` shown in the table * - Name - Shortcut - - Engine + - Module - Disabled - Timeout - Weight @@ -43,7 +43,7 @@ Explanation of the :ref:`general engine configuration` shown in the table * - `{{name}} <{{mod.about and mod.about.website}}>`_ - ``!{{mod.shortcut}}`` - - {{mod.__name__}} + - :origin:`{{mod.__name__}} ` - {{(mod.disabled and "y") or ""}} {%- if mod.about and mod.about.language %} ({{mod.about.language | upper}}) From ca7f1a2da6e09a81a8823b1f146b186132ef0e92 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 21 Dec 2021 17:44:05 +0100 Subject: [PATCH 2/2] [doc] engine-table: link module documentation if it exists --- docs/admin/engines/configured_engines.rst | 6 +++++- docs/conf.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/admin/engines/configured_engines.rst b/docs/admin/engines/configured_engines.rst index dabd3501..0060d1b7 100644 --- a/docs/admin/engines/configured_engines.rst +++ b/docs/admin/engines/configured_engines.rst @@ -43,7 +43,11 @@ Explanation of the :ref:`general engine configuration` shown in the table * - `{{name}} <{{mod.about and mod.about.website}}>`_ - ``!{{mod.shortcut}}`` - - :origin:`{{mod.__name__}} ` + - {%- if 'searx.engines.' + mod.__name__ in documented_modules %} + :py:mod:`~searx.engines.{{mod.__name__}}` + {%- else %} + :origin:`{{mod.__name__}} ` + {%- endif %} - {{(mod.disabled and "y") or ""}} {%- if mod.about and mod.about.language %} ({{mod.about.language | upper}}) diff --git a/docs/conf.py b/docs/conf.py index a319762e..560e3daf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -58,6 +58,25 @@ jinja_filters = { ) } +# Let the Jinja template in configured_engines.rst access documented_modules +# to automatically link documentation for modules if it exists. +def setup(app): + ENGINES_DOCNAME = 'admin/engines/configured_engines' + + def before_read_docs(app, env, docnames): + assert ENGINES_DOCNAME in docnames + docnames.remove(ENGINES_DOCNAME) + docnames.append(ENGINES_DOCNAME) + # configured_engines must come last so that sphinx already has + # discovered the python module documentations + + def source_read(app, docname, source): + if docname == ENGINES_DOCNAME: + jinja_contexts['searx']['documented_modules'] = app.env.domains['py'].modules + + app.connect('env-before-read-docs', before_read_docs) + app.connect('source-read', source_read) + # usage:: lorem :patch:`f373169` ipsum extlinks = {}