conf.py 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. # -*- coding: utf-8 -*-
  2. # SPDX-License-Identifier: AGPL-3.0-or-later
  3. import sys, os
  4. from pallets_sphinx_themes import ProjectLink
  5. from searx import get_setting
  6. from searx.version import VERSION_STRING, GIT_URL, GIT_BRANCH
  7. # Project --------------------------------------------------------------
  8. project = 'SearXNG'
  9. copyright = '2021 SearXNG team, 2015-2021 Adam Tauber, Noémi Ványi'
  10. author = '2021 SearXNG team, 2015-2021 Adam Tauber'
  11. release, version = VERSION_STRING, VERSION_STRING
  12. SEARXNG_URL = get_setting('server.base_url') or 'https://example.org/searxng'
  13. ISSUE_URL = get_setting('brand.issue_url')
  14. DOCS_URL = get_setting('brand.docs_url')
  15. PUBLIC_INSTANCES = get_setting('brand.public_instances')
  16. PRIVACYPOLICY_URL = get_setting('general.privacypolicy_url')
  17. CONTACT_URL = get_setting('general.contact_url')
  18. WIKI_URL = get_setting('brand.wiki_url')
  19. # hint: sphinx.ext.viewcode won't highlight when 'highlight_language' [1] is set
  20. # to string 'none' [2]
  21. #
  22. # [1] https://www.sphinx-doc.org/en/master/usage/extensions/viewcode.html
  23. # [2] https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-highlight_language
  24. highlight_language = 'default'
  25. # General --------------------------------------------------------------
  26. master_doc = "index"
  27. source_suffix = '.rst'
  28. numfig = True
  29. exclude_patterns = ['build-templates/*.rst', 'user/*.md']
  30. import searx.engines
  31. import searx.plugins
  32. import searx.webutils
  33. # import searx.webapp is needed to init the engines & plugins, to init a
  34. # (empty) secret_key is needed.
  35. searx.settings['server']['secret_key'] = ''
  36. import searx.webapp
  37. searx.engines.load_engines(searx.settings['engines'])
  38. jinja_contexts = {
  39. 'searx': {
  40. 'engines': searx.engines.engines,
  41. 'plugins': searx.plugins.plugins,
  42. 'version': {
  43. 'node': os.getenv('NODE_MINIMUM_VERSION')
  44. },
  45. 'enabled_engine_count': sum(not x.disabled for x in searx.engines.engines.values()),
  46. 'categories': searx.engines.categories,
  47. 'categories_as_tabs': {c: searx.engines.categories[c] for c in searx.settings['categories_as_tabs']},
  48. },
  49. }
  50. jinja_filters = {
  51. 'group_engines_in_tab': searx.webutils.group_engines_in_tab,
  52. }
  53. # Let the Jinja template in configured_engines.rst access documented_modules
  54. # to automatically link documentation for modules if it exists.
  55. def setup(app):
  56. ENGINES_DOCNAME = 'admin/engines/configured_engines'
  57. def before_read_docs(app, env, docnames):
  58. assert ENGINES_DOCNAME in docnames
  59. docnames.remove(ENGINES_DOCNAME)
  60. docnames.append(ENGINES_DOCNAME)
  61. # configured_engines must come last so that sphinx already has
  62. # discovered the python module documentations
  63. def source_read(app, docname, source):
  64. if docname == ENGINES_DOCNAME:
  65. jinja_contexts['searx']['documented_modules'] = app.env.domains['py'].modules
  66. app.connect('env-before-read-docs', before_read_docs)
  67. app.connect('source-read', source_read)
  68. # usage:: lorem :patch:`f373169` ipsum
  69. extlinks = {}
  70. # upstream links
  71. extlinks['wiki'] = ('https://github.com/searxng/searxng/wiki/%s', ' ')
  72. extlinks['pull'] = ('https://github.com/searxng/searxng/pull/%s', 'PR ')
  73. extlinks['pull-searx'] = ('https://github.com/searx/searx/pull/%s', 'PR ')
  74. # links to custom brand
  75. extlinks['origin'] = (GIT_URL + '/blob/' + GIT_BRANCH + '/%s', 'git://')
  76. extlinks['patch'] = (GIT_URL + '/commit/%s', '#')
  77. extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ')
  78. extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ')
  79. extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '')
  80. #extlinks['role'] = (
  81. # 'https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-%s', '')
  82. extlinks['duref'] = (
  83. 'https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#%s', '')
  84. extlinks['durole'] = (
  85. 'https://docutils.sourceforge.io/docs/ref/rst/roles.html#%s', '')
  86. extlinks['dudir'] = (
  87. 'https://docutils.sourceforge.io/docs/ref/rst/directives.html#%s', '')
  88. extlinks['ctan'] = (
  89. 'https://ctan.org/pkg/%s', 'CTAN: ')
  90. extensions = [
  91. 'sphinx.ext.imgmath',
  92. 'sphinx.ext.extlinks',
  93. 'sphinx.ext.viewcode',
  94. "sphinx.ext.autodoc",
  95. "sphinx.ext.intersphinx",
  96. "pallets_sphinx_themes",
  97. "sphinx_issues", # https://github.com/sloria/sphinx-issues/blob/master/README.rst
  98. "sphinx_jinja", # https://github.com/tardyp/sphinx-jinja
  99. "sphinxcontrib.programoutput", # https://github.com/NextThought/sphinxcontrib-programoutput
  100. 'linuxdoc.kernel_include', # Implementation of the 'kernel-include' reST-directive.
  101. 'linuxdoc.rstFlatTable', # Implementation of the 'flat-table' reST-directive.
  102. 'linuxdoc.kfigure', # Sphinx extension which implements scalable image handling.
  103. "sphinx_tabs.tabs", # https://github.com/djungelorm/sphinx-tabs
  104. 'myst_parser', # https://www.sphinx-doc.org/en/master/usage/markdown.html
  105. 'notfound.extension', # https://github.com/readthedocs/sphinx-notfound-page
  106. ]
  107. myst_enable_extensions = [
  108. "replacements", "smartquotes"
  109. ]
  110. suppress_warnings = ['myst.domains']
  111. intersphinx_mapping = {
  112. "python": ("https://docs.python.org/3/", None),
  113. "flask": ("https://flask.palletsprojects.com/", None),
  114. "flask_babel": ("https://flask-babel.tkte.ch/", None),
  115. # "werkzeug": ("https://werkzeug.palletsprojects.com/", None),
  116. "jinja": ("https://jinja.palletsprojects.com/", None),
  117. "linuxdoc" : ("https://return42.github.io/linuxdoc/", None),
  118. "sphinx" : ("https://www.sphinx-doc.org/en/master/", None),
  119. "redis": ('https://redis.readthedocs.io/en/stable/', None),
  120. }
  121. issues_github_path = "searxng/searxng"
  122. # HTML -----------------------------------------------------------------
  123. # https://searxng.github.io/searxng --> '/searxng/'
  124. # https://docs.searxng.org --> '/'
  125. notfound_urls_prefix = '/'
  126. sys.path.append(os.path.abspath('_themes'))
  127. sys.path.insert(0, os.path.abspath("../utils/"))
  128. html_theme_path = ['_themes']
  129. html_theme = "searxng"
  130. # sphinx.ext.imgmath setup
  131. html_math_renderer = 'imgmath'
  132. imgmath_image_format = 'svg'
  133. imgmath_font_size = 14
  134. # sphinx.ext.imgmath setup END
  135. html_theme_options = {"index_sidebar_logo": True}
  136. html_context = {"project_links": [] }
  137. html_context["project_links"].append(ProjectLink("Source", GIT_URL + '/tree/' + GIT_BRANCH))
  138. if WIKI_URL:
  139. html_context["project_links"].append(ProjectLink("Wiki", WIKI_URL))
  140. if PUBLIC_INSTANCES:
  141. html_context["project_links"].append(ProjectLink("Public instances", PUBLIC_INSTANCES))
  142. if ISSUE_URL:
  143. html_context["project_links"].append(ProjectLink("Issue Tracker", ISSUE_URL))
  144. if PRIVACYPOLICY_URL:
  145. html_context["project_links"].append(ProjectLink("Privacy Policy", PRIVACYPOLICY_URL))
  146. if CONTACT_URL:
  147. html_context["project_links"].append(ProjectLink("Contact", CONTACT_URL))
  148. html_sidebars = {
  149. "**": [
  150. "globaltoc.html",
  151. "project.html",
  152. "relations.html",
  153. "searchbox.html",
  154. "sourcelink.html"
  155. ],
  156. }
  157. singlehtml_sidebars = {"index": ["project.html", "localtoc.html"]}
  158. html_logo = "../src/brand/searxng-wordmark.svg"
  159. html_title = "SearXNG Documentation ({})".format(VERSION_STRING)
  160. html_show_sourcelink = True
  161. # LaTeX ----------------------------------------------------------------
  162. latex_documents = [
  163. (master_doc, "searx-{}.tex".format(VERSION_STRING), html_title, author, "manual")
  164. ]