2015-11-17 22:13:30 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-04-17 16:20:29 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
import sys, os
|
|
|
|
from pallets_sphinx_themes import ProjectLink
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2021-07-17 17:03:54 +00:00
|
|
|
from searx import get_setting
|
2021-07-27 16:37:46 +00:00
|
|
|
from searx.version import VERSION_STRING, GIT_URL, GIT_BRANCH
|
2020-09-29 10:30:10 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
# Project --------------------------------------------------------------
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2021-09-10 09:49:57 +00:00
|
|
|
project = 'SearXNG'
|
|
|
|
copyright = '2021 SearXNG team, 2015-2021 Adam Tauber, Noémi Ványi'
|
|
|
|
author = '2021 SearXNG team, 2015-2021 Adam Tauber'
|
2019-12-04 14:27:27 +00:00
|
|
|
release, version = VERSION_STRING, VERSION_STRING
|
2021-06-01 13:09:24 +00:00
|
|
|
|
2021-10-11 17:59:34 +00:00
|
|
|
SEARXNG_URL = get_setting('server.base_url') or 'https://example.org/searxng'
|
2021-07-17 17:03:54 +00:00
|
|
|
ISSUE_URL = get_setting('brand.issue_url')
|
|
|
|
DOCS_URL = get_setting('brand.docs_url')
|
|
|
|
PUBLIC_INSTANCES = get_setting('brand.public_instances')
|
|
|
|
CONTACT_URL = get_setting('general.contact_url')
|
|
|
|
WIKI_URL = get_setting('brand.wiki_url')
|
|
|
|
|
2021-06-01 13:09:24 +00:00
|
|
|
# hint: sphinx.ext.viewcode won't highlight when 'highlight_language' [1] is set
|
|
|
|
# to string 'none' [2]
|
|
|
|
#
|
|
|
|
# [1] https://www.sphinx-doc.org/en/master/usage/extensions/viewcode.html
|
|
|
|
# [2] https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-highlight_language
|
|
|
|
|
|
|
|
highlight_language = 'default'
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
# General --------------------------------------------------------------
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
master_doc = "index"
|
|
|
|
source_suffix = '.rst'
|
2019-12-19 22:36:53 +00:00
|
|
|
numfig = True
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2020-03-03 15:26:02 +00:00
|
|
|
exclude_patterns = ['build-templates/*.rst']
|
|
|
|
|
2020-12-21 08:53:41 +00:00
|
|
|
import searx.engines
|
|
|
|
import searx.plugins
|
2021-06-04 09:26:37 +00:00
|
|
|
searx.engines.load_engines(searx.settings['engines'])
|
2021-12-28 11:51:29 +00:00
|
|
|
|
2019-12-21 16:13:38 +00:00
|
|
|
jinja_contexts = {
|
2020-12-21 08:53:41 +00:00
|
|
|
'searx': {
|
|
|
|
'engines': searx.engines.engines,
|
2021-11-14 17:10:14 +00:00
|
|
|
'plugins': searx.plugins.plugins,
|
|
|
|
'version': {
|
|
|
|
'node': os.getenv('NODE_MINIMUM_VERSION')
|
|
|
|
},
|
2021-12-21 11:54:01 +00:00
|
|
|
'enabled_engine_count': sum(not x.disabled for x in searx.engines.engines.values()),
|
2021-12-28 11:51:29 +00:00
|
|
|
'categories': searx.engines.categories,
|
2020-12-21 08:53:41 +00:00
|
|
|
},
|
2019-12-21 16:13:38 +00:00
|
|
|
}
|
2021-12-20 22:57:06 +00:00
|
|
|
jinja_filters = {
|
2021-12-21 08:39:03 +00:00
|
|
|
'sort_engines':
|
|
|
|
lambda engines: sorted(
|
|
|
|
engines,
|
2021-12-28 11:51:29 +00:00
|
|
|
key=lambda engine: (engine.about.get('language', ''), engine.name)
|
2021-12-21 08:39:03 +00:00
|
|
|
)
|
2021-12-20 22:57:06 +00:00
|
|
|
}
|
2019-12-21 16:13:38 +00:00
|
|
|
|
2021-12-21 16:44:05 +00:00
|
|
|
# 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)
|
|
|
|
|
2019-12-04 15:48:36 +00:00
|
|
|
# usage:: lorem :patch:`f373169` ipsum
|
|
|
|
extlinks = {}
|
2019-12-12 18:20:56 +00:00
|
|
|
|
|
|
|
# upstream links
|
2021-04-25 10:03:54 +00:00
|
|
|
extlinks['wiki'] = ('https://github.com/searxng/searxng/wiki/%s', ' ')
|
|
|
|
extlinks['pull'] = ('https://github.com/searxng/searxng/pull/%s', 'PR ')
|
|
|
|
extlinks['pull-searx'] = ('https://github.com/searx/searx/pull/%s', 'PR ')
|
2019-12-12 18:20:56 +00:00
|
|
|
|
|
|
|
# links to custom brand
|
2021-07-17 17:03:54 +00:00
|
|
|
extlinks['origin'] = (GIT_URL + '/blob/' + GIT_BRANCH + '/%s', 'git://')
|
|
|
|
extlinks['patch'] = (GIT_URL + '/commit/%s', '#')
|
2021-10-11 17:59:34 +00:00
|
|
|
extlinks['search'] = (SEARXNG_URL + '/%s', '#')
|
2021-07-17 17:03:54 +00:00
|
|
|
extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ')
|
2019-12-18 15:11:05 +00:00
|
|
|
extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ')
|
2019-12-18 17:32:42 +00:00
|
|
|
extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '')
|
2019-12-19 22:36:53 +00:00
|
|
|
#extlinks['role'] = (
|
|
|
|
# 'https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-%s', '')
|
2019-12-19 16:05:50 +00:00
|
|
|
extlinks['duref'] = (
|
2021-06-03 16:00:09 +00:00
|
|
|
'https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#%s', '')
|
2019-12-19 16:05:50 +00:00
|
|
|
extlinks['durole'] = (
|
2021-06-03 16:00:09 +00:00
|
|
|
'https://docutils.sourceforge.io/docs/ref/rst/roles.html#%s', '')
|
2019-12-19 16:05:50 +00:00
|
|
|
extlinks['dudir'] = (
|
2021-06-03 16:00:09 +00:00
|
|
|
'https://docutils.sourceforge.io/docs/ref/rst/directives.html#%s', '')
|
2019-12-28 00:01:11 +00:00
|
|
|
extlinks['ctan'] = (
|
|
|
|
'https://ctan.org/pkg/%s', 'CTAN: ')
|
2019-12-04 15:48:36 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
extensions = [
|
2019-12-28 00:25:16 +00:00
|
|
|
'sphinx.ext.imgmath',
|
2019-12-04 15:48:36 +00:00
|
|
|
'sphinx.ext.extlinks',
|
2019-12-04 14:27:27 +00:00
|
|
|
'sphinx.ext.viewcode',
|
|
|
|
"sphinx.ext.autodoc",
|
|
|
|
"sphinx.ext.intersphinx",
|
|
|
|
"pallets_sphinx_themes",
|
|
|
|
"sphinx_issues", # https://github.com/sloria/sphinx-issues/blob/master/README.rst
|
2019-12-21 16:13:38 +00:00
|
|
|
"sphinxcontrib.jinja", # https://github.com/tardyp/sphinx-jinja
|
2020-01-11 11:49:02 +00:00
|
|
|
"sphinxcontrib.programoutput", # https://github.com/NextThought/sphinxcontrib-programoutput
|
2020-06-18 16:51:31 +00:00
|
|
|
'linuxdoc.kernel_include', # Implementation of the 'kernel-include' reST-directive.
|
2019-12-19 22:36:53 +00:00
|
|
|
'linuxdoc.rstFlatTable', # Implementation of the 'flat-table' reST-directive.
|
|
|
|
'linuxdoc.kfigure', # Sphinx extension which implements scalable image handling.
|
2019-12-26 09:26:12 +00:00
|
|
|
"sphinx_tabs.tabs", # https://github.com/djungelorm/sphinx-tabs
|
2019-12-04 14:27:27 +00:00
|
|
|
]
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
intersphinx_mapping = {
|
|
|
|
"python": ("https://docs.python.org/3/", None),
|
2019-12-19 16:05:50 +00:00
|
|
|
"flask": ("https://flask.palletsprojects.com/", None),
|
2019-12-04 14:27:27 +00:00
|
|
|
# "werkzeug": ("https://werkzeug.palletsprojects.com/", None),
|
2019-12-19 16:05:50 +00:00
|
|
|
"jinja": ("https://jinja.palletsprojects.com/", None),
|
2019-12-19 22:36:53 +00:00
|
|
|
"linuxdoc" : ("https://return42.github.io/linuxdoc/", None),
|
|
|
|
"sphinx" : ("https://www.sphinx-doc.org/en/master/", None),
|
2019-12-04 14:27:27 +00:00
|
|
|
}
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2021-04-25 10:03:54 +00:00
|
|
|
issues_github_path = "searxng/searxng"
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
# HTML -----------------------------------------------------------------
|
2015-11-17 22:13:30 +00:00
|
|
|
|
|
|
|
sys.path.append(os.path.abspath('_themes'))
|
2020-11-04 12:38:54 +00:00
|
|
|
sys.path.insert(0, os.path.abspath("../utils/"))
|
2019-12-04 14:27:27 +00:00
|
|
|
html_theme_path = ['_themes']
|
2021-11-18 16:33:48 +00:00
|
|
|
html_theme = "searxng"
|
2019-12-04 14:27:27 +00:00
|
|
|
|
2019-12-28 00:25:16 +00:00
|
|
|
# sphinx.ext.imgmath setup
|
|
|
|
html_math_renderer = 'imgmath'
|
|
|
|
imgmath_image_format = 'svg'
|
|
|
|
imgmath_font_size = 14
|
|
|
|
# sphinx.ext.imgmath setup END
|
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
html_theme_options = {"index_sidebar_logo": True}
|
2020-12-20 23:37:45 +00:00
|
|
|
html_context = {"project_links": [] }
|
2021-07-17 17:03:54 +00:00
|
|
|
html_context["project_links"].append(ProjectLink("Source", GIT_URL + '/tree/' + GIT_BRANCH))
|
|
|
|
|
|
|
|
if WIKI_URL:
|
|
|
|
html_context["project_links"].append(ProjectLink("Wiki", WIKI_URL))
|
|
|
|
if PUBLIC_INSTANCES:
|
|
|
|
html_context["project_links"].append(ProjectLink("Public instances", PUBLIC_INSTANCES))
|
|
|
|
if ISSUE_URL:
|
|
|
|
html_context["project_links"].append(ProjectLink("Issue Tracker", ISSUE_URL))
|
|
|
|
if CONTACT_URL:
|
|
|
|
html_context["project_links"].append(ProjectLink("Contact", CONTACT_URL))
|
2020-12-20 23:37:45 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
html_sidebars = {
|
2021-12-23 18:39:29 +00:00
|
|
|
"**": [
|
|
|
|
"globaltoc.html",
|
|
|
|
"project.html",
|
|
|
|
"relations.html",
|
|
|
|
"searchbox.html",
|
|
|
|
"sourcelink.html"
|
|
|
|
],
|
2019-12-04 14:27:27 +00:00
|
|
|
}
|
|
|
|
singlehtml_sidebars = {"index": ["project.html", "localtoc.html"]}
|
2021-11-29 18:38:23 +00:00
|
|
|
html_logo = "../src/brand/searxng-wordmark.svg"
|
2021-09-12 06:36:56 +00:00
|
|
|
html_title = "SearXNG Documentation ({})".format(VERSION_STRING)
|
2021-11-18 16:27:49 +00:00
|
|
|
html_show_sourcelink = True
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
# LaTeX ----------------------------------------------------------------
|
2015-11-17 22:13:30 +00:00
|
|
|
|
2019-12-04 14:27:27 +00:00
|
|
|
latex_documents = [
|
|
|
|
(master_doc, "searx-{}.tex".format(VERSION_STRING), html_title, author, "manual")
|
2015-11-17 22:13:30 +00:00
|
|
|
]
|