From f09459b98ae877d7dfd40d85c0edf058c65913d5 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 18 Dec 2019 16:11:05 +0100 Subject: [PATCH 01/21] doc: describe Makefile targets With the aim to simplify development cycles, started with PR #1756 a Makefile based boilerplate was added. This patch adds the missing developer documentation. Signed-off-by: Markus Heiser --- Makefile | 4 + docs/conf.py | 1 + docs/dev/contribution_guide.rst | 15 ++- docs/dev/index.rst | 1 + docs/dev/makefile.rst | 217 ++++++++++++++++++++++++++++++++ docs/dev/quickstart.rst | 26 +++- 6 files changed, 257 insertions(+), 7 deletions(-) create mode 100644 docs/dev/makefile.rst diff --git a/Makefile b/Makefile index b69202ba2..f35b86c41 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ PYOBJECTS = searx DOC = docs PY_SETUP_EXTRAS ?= \[test\] +PYDIST=./dist/py +PYBUILD=./build/py + include utils/makefile.include include utils/makefile.python include utils/makefile.sphinx @@ -23,6 +26,7 @@ help: @echo ' install - developer install (./local)' @echo ' uninstall - uninstall (./local)' @echo ' gh-pages - build docs & deploy on gh-pages branch' + @echo ' clean - drop builds and environments' @echo '' @$(MAKE) -s -f utils/makefile.include make-help @echo '' diff --git a/docs/conf.py b/docs/conf.py index c0bd246ac..64c7a715f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -32,6 +32,7 @@ extlinks['origin'] = (GIT_URL + '/blob/master/%s', 'git://') extlinks['patch'] = (GIT_URL + '/commit/%s', '#') extlinks['search'] = (SEARX_URL + '/%s', '#') extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ') +extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ') extensions = [ 'sphinx.ext.extlinks', diff --git a/docs/dev/contribution_guide.rst b/docs/dev/contribution_guide.rst index 064f28e63..6d8d3924d 100644 --- a/docs/dev/contribution_guide.rst +++ b/docs/dev/contribution_guide.rst @@ -79,6 +79,8 @@ Translation currently takes place on :ref:`transifex `. Please, do not update translation files in the repo. +.. _contrib docs: + Documentation ============= @@ -91,7 +93,7 @@ Documentation The documentation is built using Sphinx_. So in order to be able to generate the required files, you have to install it on your system. Much easier, use -Makefile our targets. +our :ref:`makefile`. Here is an example which makes a complete rebuild: @@ -101,6 +103,7 @@ Here is an example which makes a complete rebuild: ... The HTML pages are in dist/docs. +.. _make docs-live: live build ---------- @@ -110,9 +113,10 @@ live build It is recommended to assert a complete rebuild before deploying (use ``docs-clean``). -Live build is like WYSIWYG, If you want to edit the documentation, its -recommended to use. The Makefile target ``docs-live`` builds the docs, opens URL -in your favorite browser and rebuilds every time a reST file has been changed. +Live build is like WYSIWYG. If you want to edit the documentation, its +recommended to use. The Makefile target ``docs-live`` builds the docs, opens +URL in your favorite browser and rebuilds every time a reST file has been +changed. .. code:: sh @@ -123,12 +127,13 @@ in your favorite browser and rebuilds every time a reST file has been changed. ... Start watching changes +.. _deploy on github.io: deploy on github.io ------------------- To deploy documentation at :docs:`github.io <.>` use Makefile target -``gh-pages``, which will builds the documentation, clones searx into a sub +:ref:`make gh-pages`, which will builds the documentation, clones searx into a sub folder ``gh-pages``, cleans it, copies the doc build into and runs all the needed git add, commit and push: diff --git a/docs/dev/index.rst b/docs/dev/index.rst index 8e18066ca..93340c1db 100644 --- a/docs/dev/index.rst +++ b/docs/dev/index.rst @@ -11,3 +11,4 @@ Developer documentation search_api plugins translation + makefile diff --git a/docs/dev/makefile.rst b/docs/dev/makefile.rst new file mode 100644 index 000000000..65cddd3ee --- /dev/null +++ b/docs/dev/makefile.rst @@ -0,0 +1,217 @@ +.. _makefile: + +================ +Makefile Targets +================ + +.. sidebar:: build environment + + Before looking deeper at the targets, first read about :ref:`makefile setup` + and :ref:`make pyenv`. + +With the aim to simplify development cycles, started with :pull:`1756` a +``Makefile`` based boilerplate was added. + +The usage is simple, just type ``make {target-name}`` to *build* a target. +Calling the ``help`` target gives a first overview:: + + $ make help + test - run developer tests + docs - build documentation + docs-live - autobuild HTML documentation while editing + run - run developer instance + install - developer install (./local) + uninstall - uninstall (./local) + gh-pages - build docs & deploy on gh-pages branch + clean - drop builds and environments + ... + +.. contents:: Contents + :depth: 2 + :local: + :backlinks: entry + + +.. _makefile setup: + +Setup +===== + +.. _git stash: https://git-scm.com/docs/git-stash + +The main setup is done in the :origin:`Makefile`:: + + export GIT_URL=https://github.com/asciimoo/searx + export SEARX_URL=https://searx.me + export DOCS_URL=https://asciimoo.github.io/searx + +.. sidebar:: fork & upstream + + Commit changes in your (local) branch, fork or whatever, but do not push them + upstream / `git stash`_ is your friend. + +:GIT_URL: Changes this, to point to your searx fork. + +:SEARX_URL: Changes this, to point to your searx instance. + +:DOCS_URL: If you host your own (branded) documentation, change this URL. + +.. _make pyenv: + +Python environment +================== + +.. sidebar:: activate environment + + ``source ./local/py3/bin/activate`` + +With Makefile we do no longer need to build up the virualenv manually (as +described in the :ref:`devquickstart` guide). Jump into your git working tree +and release a ``make pyenv``: + +.. code:: sh + + $ cd ~/searx-clone + $ make pyenv + PYENV usage: source ./local/py3/bin/activate + ... + +With target ``pyenv`` a development environment (aka virtualenv) was build up in +``./local/py3/``. To make a *developer install** of searx (:origin:`setup.py`) +into this environment make target ``install`` + +.. code:: sh + + $ make install + PYENV usage: source ./local/py3/bin/activate + PYENV using virtualenv from ./local/py3 + PYENV install . + +You have never to think about intermediate targets like ``pyenv`` or +``install``, the ``Makefile`` chains them as requisites. Just run your main +target. + +.. sidebar:: drop environment + + To get rid of the existing environment before re-build use :ref:`clean target + ` first. + +If you think, something goes wrong with your ./local environment or you change +the :origin:`setup.py` file (or the requirements listed in +:origin:`requirements-dev.txt` and :origin:`requirements.txt`), you have to call +:ref:`make clean`. + + +.. _make run: + +``make run`` +============ + +To get up a running a developer instance simply call ``make run``. This enables +*debug* option in :origin:`searx/settings.yml`, starts ``./searx/webapp.py`` +instance, disables *debug* option and opens the site (xdg-open): + +.. code:: sh + + $ make run + PYENV usage: source ./local/py3/bin/activate + PYENV install . + ./local/py3/bin/python ./searx/webapp.py + ... + INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit) + ... + +.. _make clean: + +``make clean`` +============== + +Drop all intermediate files, all builds, but keep sources untouched. Includes +target ``pyclean`` which drops ./local environment. Before calling ``make +clean`` stop all processes using :ref:`make pyenv`. + +.. code:: sh + + $ make clean + CLEAN pyclean + CLEAN clean + +.. _make docs: + +``make docs docs-live docs-clean`` +================================== + +We describe the usage of the ``doc*`` targets in the :ref:`How to contribute / +Documentation ` section. If you want to edit the documentation +read our :ref:`make docs-live` section. If you are working in your own brand, +adjust your :ref:`Makefile setup `. + + +.. _make gh-pages: + +``make gh-pages`` +================= + +To deploy on github.io first adjust your :ref:`Makefile setup `. For any further read :ref:`deploy on github.io`. + +.. _make test: + +``make test`` +============= + +Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and does +additional :ref:`pylint checks `. You can run tests selective, +e.g.: + +.. code:: sh + + $ make test.pep8 test.unit + . ./local/py3/bin/activate; ./manage.sh pep8_check + [!] Running pep8 check + . ./local/py3/bin/activate; ./manage.sh unit_tests + [!] Running unit tests + +.. _make pylint: + +``make pylint`` +=============== + +.. _Pylint: https://www.pylint.org/ + +Before commiting its recommend to do some (more) linting. Pylint_ is known as +one of the best source-code, bug and quality checker for the Python programming +language. Pylint_ is not yet a quality gate within our searx project (like +:ref:`test.pep8 ` it is), but Pylint_ can help to improve code +quality anyway. The pylint profile we use at searx project is found in +project's root folder :origin:`.pylintrc`. + +Code quality is a ongoing process. Don't try to fix all messages from Pylint, +run Pylint and check if your changed lines are bringing up new messages. If so, +fix it. By this, code quality gets incremental better and if there comes the +day, the linting is balanced out, we might decide to add Pylint as a quality +gate. + + +``make pybuild`` +================ + +.. _PyPi: https://pypi.org/ +.. _twine: https://twine.readthedocs.io/en/latest/ + +Build Python packages in ``./dist/py``. + +.. code:: sh + + $ make pybuild + ... + BUILD pybuild + running sdist + running egg_info + ... + $ ls ./dist/py/ + searx-0.15.0-py3-none-any.whl searx-0.15.0.tar.gz + +To upload packages to PyPi_, there is also a ``upload-pypi`` target. It needs +twine_ to be installed. Since you are not the owner of :pypi:`searx` you will +never need the latter. diff --git a/docs/dev/quickstart.rst b/docs/dev/quickstart.rst index a4a37a266..e40772b3b 100644 --- a/docs/dev/quickstart.rst +++ b/docs/dev/quickstart.rst @@ -4,15 +4,23 @@ Development Quickstart ====================== +.. sidebar:: :ref:`makefile` + + For additional developer purpose there are :ref:`makefile`. + This quickstart guide gets your environment set up with searx. Furthermore, it gives a short introduction to the ``manage.sh`` script. How to setup your development environment ========================================= +.. sidebar:: :ref:`make pyenv ` + + Alternatively use the :ref:`make pyenv`. + First, clone the source code of searx to the desired folder. In this case the source is cloned to ``~/myprojects/searx``. Then create and activate the -searx-ve virtualenv and install the required packages using manage.sh. +searx-ve virtualenv and install the required packages using ``manage.sh``. .. code:: sh @@ -27,6 +35,10 @@ searx-ve virtualenv and install the required packages using manage.sh. How to run tests ================ +.. sidebar:: :ref:`make test.unit ` + + Alternatively use the ``test.pep8``, ``test.unit``, ``test.robot`` targets. + Tests can be run using the ``manage.sh`` script. Following tests and checks are available: @@ -41,7 +53,8 @@ For example unit tests are run with the command below: ./manage.sh unit_tests -For further test options, please consult the help of the ``manage.sh`` script. +For further test options, please consult the help of the ``manage.sh`` script or +read :ref:`make test`. How to compile styles and javascript @@ -97,6 +110,11 @@ After installing grunt, the files can be built using the following command: Tips for debugging/development ============================== +.. sidebar:: :ref:`make run` + + Makefile target ``run`` already enables debug option for your developer + session / see :ref:`make run`. + Turn on debug logging Whether you are working on a new engine or trying to eliminate a bug, it is always a good idea to turn on debug logging. When debug logging is enabled a @@ -104,6 +122,10 @@ Turn on debug logging message. It can be turned on by setting ``debug: False`` to ``debug: True`` in :origin:`settings.yml `. +.. sidebar:: :ref:`make test` + + Alternatively use the :ref:`make test` targets. + Run ``./manage.sh tests`` before creating a PR. Failing build on Travis is common because of PEP8 checks. So a new commit must be created containing these format fixes. This phase can be skipped if From 2b4526916dd8092191baa5b9387e8198e5072b83 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 18 Dec 2019 18:32:42 +0100 Subject: [PATCH 02/21] edoc: -- makefile.rst fix typo and add extlinks['man'] Signed-off-by: Markus Heiser --- docs/conf.py | 1 + docs/dev/makefile.rst | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 64c7a715f..9eba67cf6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,6 +33,7 @@ extlinks['patch'] = (GIT_URL + '/commit/%s', '#') extlinks['search'] = (SEARX_URL + '/%s', '#') extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ') extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ') +extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '') extensions = [ 'sphinx.ext.extlinks', diff --git a/docs/dev/makefile.rst b/docs/dev/makefile.rst index 65cddd3ee..00825623c 100644 --- a/docs/dev/makefile.rst +++ b/docs/dev/makefile.rst @@ -4,13 +4,16 @@ Makefile Targets ================ +.. _gnu-make: https://www.gnu.org/software/make/manual/make.html#Introduction + .. sidebar:: build environment Before looking deeper at the targets, first read about :ref:`makefile setup` and :ref:`make pyenv`. With the aim to simplify development cycles, started with :pull:`1756` a -``Makefile`` based boilerplate was added. +``Makefile`` based boilerplate was added. If you are not familiar with +Makefiles, we recommend to read gnu-make_ introduction. The usage is simple, just type ``make {target-name}`` to *build* a target. Calling the ``help`` target gives a first overview:: @@ -77,7 +80,7 @@ and release a ``make pyenv``: ... With target ``pyenv`` a development environment (aka virtualenv) was build up in -``./local/py3/``. To make a *developer install** of searx (:origin:`setup.py`) +``./local/py3/``. To make a *developer install* of searx (:origin:`setup.py`) into this environment make target ``install`` .. code:: sh @@ -108,8 +111,9 @@ the :origin:`setup.py` file (or the requirements listed in ============ To get up a running a developer instance simply call ``make run``. This enables -*debug* option in :origin:`searx/settings.yml`, starts ``./searx/webapp.py`` -instance, disables *debug* option and opens the site (xdg-open): +*debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py`` +instance, disables *debug* option again and opens the URL in your favorite WEB +browser (:man:`xdg-open`): .. code:: sh From bee19a76f7dc8b86af3ef342acd3f4db72f51543 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 19 Dec 2019 17:05:50 +0100 Subject: [PATCH 03/21] doc: add reST primer (inital / WIP) preview: https://return42.github.io/searx/dev/reST.html includes: - :class: rst-example // admonitions with (rendered) reST markup example - extlinks to docutils Signed-off-by: Markus Heiser --- docs/_themes/searx/static/searx.css | 42 +++ docs/conf.py | 11 +- docs/dev/index.rst | 1 + docs/dev/makefile.rst | 2 +- docs/dev/reST.rst | 491 ++++++++++++++++++++++++++++ 5 files changed, 544 insertions(+), 3 deletions(-) create mode 100644 docs/dev/reST.rst diff --git a/docs/_themes/searx/static/searx.css b/docs/_themes/searx/static/searx.css index 10f5b4eda..ee084d499 100644 --- a/docs/_themes/searx/static/searx.css +++ b/docs/_themes/searx/static/searx.css @@ -28,3 +28,45 @@ p.sidebar-title, .sidebar p { list-style-type: disclosure-closed; } + +/* admonitions with (rendered) reST markup examples (:class: rst-example) + * + * .. admonition:: title of the example + * :class: rst-example + * .... +/* navigation menu: use sans font and select light/dark colors for better +* contrast. +*/ + +div.rst-example { + padding-left: 12px; + padding-right: 12px; + background-color: white; + transform: scale(0.9); + transition: transform 1s; +} + +/* div.rst-example > .admonition-title { */ +/* background-color: inherit; */ +/* color: inherit; */ +/* } */ + +/* div.rst-example > .admonition-title:after{ */ +/* font-family: inherit; */ +/* font-style: italic; */ +/* content: " // hover mouse over .."; */ +/* } */ + +@media screen { + div.rst-example:hover { + transform: scale(1); + background-color: inherit; + padding-left: inherit; + padding-right: inherit; + border-left: inherit; + } + + div.rst-example:hover > .admonition-title { + display: none; + } +} diff --git a/docs/conf.py b/docs/conf.py index 9eba67cf6..33954cbd2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,6 +14,7 @@ project = u'searx' copyright = u'2015-2019, Adam Tauber, Noémi Ványi' author = u'Adam Tauber' release, version = VERSION_STRING, VERSION_STRING +highlight_language = 'none' # General -------------------------------------------------------------- @@ -34,6 +35,12 @@ extlinks['search'] = (SEARX_URL + '/%s', '#') extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ') extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ') extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '') +extlinks['duref'] = ( + 'http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#%s', '') +extlinks['durole'] = ( + 'http://docutils.sourceforge.net/docs/ref/rst/roles.html#%s', '') +extlinks['dudir'] = ( + 'http://docutils.sourceforge.net/docs/ref/rst/directives.html#%s', '') extensions = [ 'sphinx.ext.extlinks', @@ -46,9 +53,9 @@ extensions = [ intersphinx_mapping = { "python": ("https://docs.python.org/3/", None), - # "flask": ("https://flask.palletsprojects.com/", None), + "flask": ("https://flask.palletsprojects.com/", None), # "werkzeug": ("https://werkzeug.palletsprojects.com/", None), - # "jinja": ("https://jinja.palletsprojects.com/", None), + "jinja": ("https://jinja.palletsprojects.com/", None), } issues_github_path = "asciimoo/searx" diff --git a/docs/dev/index.rst b/docs/dev/index.rst index 93340c1db..cb913a82b 100644 --- a/docs/dev/index.rst +++ b/docs/dev/index.rst @@ -12,3 +12,4 @@ Developer documentation plugins translation makefile + reST diff --git a/docs/dev/makefile.rst b/docs/dev/makefile.rst index 00825623c..f5957001c 100644 --- a/docs/dev/makefile.rst +++ b/docs/dev/makefile.rst @@ -81,7 +81,7 @@ and release a ``make pyenv``: With target ``pyenv`` a development environment (aka virtualenv) was build up in ``./local/py3/``. To make a *developer install* of searx (:origin:`setup.py`) -into this environment make target ``install`` +into this environment, use make target ``install``: .. code:: sh diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst new file mode 100644 index 000000000..c8482e77d --- /dev/null +++ b/docs/dev/reST.rst @@ -0,0 +1,491 @@ +.. _reST primer: + +=========== +reST primer +=========== + +.. sidebar:: KISS_ and readability_ + + Instead of defining more and more roles, we at searx encourage our + contributors to follow principles like KISS_ and readability_. + +We at searx are using reStructuredText (aka reST_) markup for all kind of +documentation, with the builders from the Sphinx_ project a HTML output is +generated and deployed at :docs:`github.io <.>`. + +The sources of Searx's documentation are located at :origin:`docs`. Run +:ref:`make docs-live ` to build HTML while editing. + +------ + +.. contents:: Contents + :depth: 3 + :local: + :backlinks: entry + +Sphinx_ and reST_ have their place in the python ecosystem. Over that reST is +used in popular projects, e.g the Linux kernel documentation `[kernel doc]`_. + +.. _[kernel doc]: https://www.kernel.org/doc/html/latest/doc-guide/sphinx.html + +.. sidebar:: Content matters + + The readability_ of the reST sources has its value, therefore we recommend to + make sparse usage of reST markup / .. content matters! + +**reST** is a plaintext markup language, its markup is *mostly* intuitive and +you will not need to learn much to produce well formed articles with. I use the +word *mostly*: like everything in live, reST has its advantages and +disadvantages, some markups feel a bit grumpy (especially if you are used to +other plaintext markups). + +Soft skills +=========== + +Before going any deeper into the markup let's face on some **soft skills** a +trained author brings with, to reach a well feedback from readers: + +- Documentation is dedicated to an audience and answers questions from the + audience point of view. +- Don't detail things which are general knowledge from the audience point of + view. +- Limit the subject, use cross links for any further reading. + +To be more concrete what a *point of view* means. In the (:origin:`docs`) +folder we have three sections (and the *blog* folder), each dedicate to a +different group of audience. + +.. sidebar:: Further reading + + - Sphinx-Primer_ + - `Sphinx markup constructs`_ + - reST_, docutils_, `docutils FAQ`_ + - Sphinx_, `sphinx-doc FAQ`_ + - `sphinx config`_, doctree_ + - `sphinx cross references`_ + - intersphinx_ + - `Sphinx's autodoc`_ + - `Sphinx's Python domain`_, `Sphinx's C domain`_ + +User's POV: :origin:`docs/user` + A typical user knows about search engines and might have heard about + meta crawlers and privacy. + +Admin's POV: :origin:`docs/admin` + A typical Admin knows about setting up services on a linux system, but he does + not know all the pros and cons of a searx setup. + +Developer's POV: :origin:`docs/dev` + Depending on the readability_ of code, a typical developer is able to read and + understand source code. Describe what a item aims to do (e.g. a function), + describe chronological order matters, describe it. Name the *out-of-limits + condition* and all the side effects a external developer will not know. + +.. _reST inline markup: + +Basic inline markup +=================== + +``*italics*`` -- *italics* + one asterisk for emphasis + +``**boldface**`` -- **boldface** + two asterisks for strong emphasis and + +````foo()```` -- ``foo()`` + backquotes for code samples and literals. + +``\*foo is a pointer`` -- \*foo is a pointer + If asterisks or backquotes appear in running text and could be confused with + inline markup delimiters, they have to be escaped with a backslash (``\*foo is + a pointer``). + + +Roles +===== + +A *custom interpreted text role* (:duref:`ref `) is an inline piece of +explicit markup. It signifies that that the enclosed text should be interpreted +in a specific way. The general syntax is ``:rolename:`content```. + +Docutils supports the following roles: + +* :durole:`emphasis` -- equivalent of ``*emphasis*`` +* :durole:`strong` -- equivalent of ``**strong**`` +* :durole:`literal` -- equivalent of ````literal```` +* :durole:`subscript` -- subscript text +* :durole:`superscript` -- superscript text +* :durole:`title-reference` -- for titles of books, periodicals, and other + materials + +Refer to `Sphinx Roles`_ for roles added by Sphinx. + + +Anchors & Links +=============== + +.. _reST anchor: + +Anchors +------- + +.. _ref role: + https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref + +To refer a point in the documentation a anchor is needed. The :ref:`reST +template ` shows an example where a chapter titled *"Chapters"* +gets an anchor named ``chapter title``. Another example from *this* document, +where the anchor named ``reST anchor``: + +.. code:: reST + + .. _reST anchor: + + Anchors + ------- + + To refer a point in the documentation a anchor is needed ... + +To refer anchors use the `ref role`_ markup: + +.. code:: reST + + Visit chapter :ref:`reST anchor`. + Or set hyperlink text manualy :ref:`foo bar `. + +.. admonition:: ``:ref:`` role + :class: rst-example + + Visist chapter :ref:`reST anchor` + Or set hyperlink text manualy :ref:`foo bar `. + +.. _reST ordinary ref: + +link ordinary URL +----------------- + +If you need to reference external URLs use *named* hyperlinks to maintain +readability of reST sources. Here is a example taken from *this* article: + +.. code:: reST + + .. _Sphinx Field Lists: + https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html + + With the *named* hyperlink `Sphinx Field Lists`_, the raw text is much more + readable. + + And this shows the alternative (less readable) hyperlink markup `Sphinx Field + Lists + `__. + +.. admonition:: Named hyperlink + :class: rst-example + + With the *named* hyperlink `Sphinx Field Lists`_, the raw text is much more + readable. + + And this shows the alternative (less readable) hyperlink markup `Sphinx Field + Lists + `__. + + +.. _reST smart ref: + +smart references +---------------- + +With the power of sphinx.ext.extlinks_ and intersphinx_ referencing external +content becomes smart. To refer ... + +sphinx.ext.extlinks_: + +:project's wiki article: :wiki:`Searx-instances` +:to docs public URL: :docs:`dev/reST.html` +:files & folders from origin: :origin:`docs/dev/reST.rst` +:a pull request: :pull:`1756` +:a patch: :patch:`af2cae6` +:a PyPi package: :pypi:`searx` +:a manual page man: :man:`bash` + +.. code:: reST + + :project's wiki article: :wiki:`Searx-instances` + :to docs public URL: :docs:`dev/reST.html` + :files & folders from origin: :origin:`docs/dev/reST.rst` + :a pull request: :pull:`1756` + :a patch: :patch:`af2cae6` + :a PyPi package: :pypi:`searx` + :a manual page man: :man:`bash` + + +intersphinx_: + + :external anchor: :ref:`python:and` + :external doc anchor: :doc:`jinja:templates` + :python code object: :py:obj:`datetime.datetime` + :flask code object: webapp is a :py:obj:`flask.Flask` app + +.. code:: reST + + :external anchor: :ref:`python:and` + :external doc anchor: :doc:`jinja:templates` + :python code object: :py:obj:`datetime.datetime` + :flask code object: webapp is a :py:obj:`flask.Flask` app + + +Intersphinx is configured in :origin:`docs/conf.py`: + +.. code:: python + + intersphinx_mapping = { + "python": ("https://docs.python.org/3/", None), + "flask": ("https://flask.palletsprojects.com/", None), + "jinja": ("https://jinja.palletsprojects.com/", None), + } + + +To list all anchors of the inventory (e.g. ``python``) use: + +.. code:: sh + + $ python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv + + +.. _reST basic structure: + +Basic article structure +======================= + +The basic structure of an article makes use of heading adornments to markup +chapter, sections and subsections. + +#. ``=`` with overline for document title +#. ``=`` for chapters +#. ``-`` for sections +#. ``~`` for subsections + +.. _reST template: + +.. admonition:: reST template + :class: rst-example + + .. code:: reST + + .. _document title: + + ============== + Document title + ============== + + Lorem ipsum dolor sit amet, consectetur adipisici elit .. + Further read :ref:`chapter title`. + + .. _chapter title: + + Chapters + ======== + + Ut enim ad minim veniam, quis nostrud exercitation ullamco + laboris nisi ut aliquid ex ea commodi consequat ... + + Section + ------- + + lorem .. + + Subsection + ~~~~~~~~~~ + + lorem .. + +.. _reST lists: + +List markups +============ + +Bullet list +----------- + +List markup (:duref:`ref `) is simple: + +.. code:: reST + + - This is a bulleted list. + + 1. Nested lists are possible, but be aware that they must be separated from + the parent list items by blank line + 2. Second item of nested list + + - It has two items, the second + item uses two lines. + + #. This is a numbered list. + #. It has two items too. + +.. admonition:: bullet list + :class: rst-example + + - This is a bulleted list. + + 1. Nested lists are possible, but be aware that they must be separated from + the parent list items by blank line + 2. Second item of nested list + + - It has two items, the second + item uses two lines. + + #. This is a numbered list. + #. It has two items too. + + +Definition list +--------------- + +.. sidebar:: definition term + + Note that the term cannot have more than one line of text. + +Definition lists (:duref:`ref `) are created as follows: + +.. code:: reST + + term (up to a line of text) + Definition of the term, which must be indented + + and can even consist of multiple paragraphs + + next term + Description. + +.. admonition:: definition list + :class: rst-example + + term (up to a line of text) + Definition of the term, which must be indented + + and can even consist of multiple paragraphs + + next term + Description. + + +Quoted paragraphs +----------------- + +Quoted paragraphs (:duref:`ref `) are created by just indenting +them more than the surrounding paragraphs. Line blocks (:duref:`ref +`) are a way of preserving line breaks: + +.. code:: reST + + normal paragraph ... + lorem ipsum. + + Quoted paragraph ... + lorem ipsum. + + | These lines are + | broken exactly like in + | the source file. + + +.. admonition:: Quoted paragraph and line block + :class: rst-example + + normal paragraph ... + lorem ipsum. + + Quoted paragraph ... + lorem ipsum. + + | These lines are + | broken exactly like in + | the source file. + + +.. _reST field list: + +Field Lists +----------- + +.. _Sphinx Field Lists: + https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html + +.. sidebar:: bibliographic fields + + First lines fields are bibliographic fields, see `Sphinx Field Lists`_. + +Field lists are used as part of an extension syntax, such as options for +directives, or database-like records meant for further processing. Field lists +are mappings from field names to field bodies. They marked up like this: + +.. code:: reST + + :fieldname: Field content + :foo: first paragraph in field foo + + second paragraph in field foo + + :bar: Field content + +.. admonition:: Field List + :class: rst-example + + :fieldname: Field content + :foo: first paragraph in field foo + + second paragraph in field foo + + :bar: Field content + + +They are commonly used in Python documentation: + +.. code:: python + + def my_function(my_arg, my_other_arg): + """A function just for me. + + :param my_arg: The first of my arguments. + :param my_other_arg: The second of my arguments. + + :returns: A message (just for me, of course). + """ + +Further list blocks +------------------- + +- field lists (:duref:`ref `, with caveats noted in + :ref:`reST field list`) +- option lists (:duref:`ref `) +- quoted literal blocks (:duref:`ref `) +- doctest blocks (:duref:`ref `) + + +.. _KISS: https://en.wikipedia.org/wiki/KISS_principle +.. _readability: https://docs.python-guide.org/writing/style/ +.. _Sphinx-Primer: + http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html +.. _reST: https://docutils.sourceforge.io/rst.html +.. _Sphinx Roles: + https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html +.. _Sphinx: http://www.sphinx-doc.org +.. _`sphinx-doc FAQ`: http://www.sphinx-doc.org/en/stable/faq.html +.. _Sphinx markup constructs: + http://www.sphinx-doc.org/en/stable/markup/index.html +.. _`sphinx cross references`: + http://www.sphinx-doc.org/en/stable/markup/inline.html#cross-referencing-arbitrary-locations +.. _sphinx.ext.extlinks: + https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html +.. _intersphinx: http://www.sphinx-doc.org/en/stable/ext/intersphinx.html +.. _sphinx config: http://www.sphinx-doc.org/en/stable/config.html +.. _Sphinx's autodoc: http://www.sphinx-doc.org/en/stable/ext/autodoc.html +.. _Sphinx's Python domain: + http://www.sphinx-doc.org/en/stable/domains.html#the-python-domain +.. _Sphinx's C domain: + http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-c-constructs +.. _doctree: + http://www.sphinx-doc.org/en/master/extdev/tutorial.html?highlight=doctree#build-phases +.. _docutils: http://docutils.sourceforge.net/docs/index.html +.. _docutils FAQ: http://docutils.sourceforge.net/FAQ.html From e1566e68aa9e18e60a86d0eea8772a3673cb3c7b Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 19 Dec 2019 23:36:53 +0100 Subject: [PATCH 04/21] doc: add content to reST primer (WIP) // linuxdoc Signed-off-by: Markus Heiser --- docs/_themes/searx/static/searx.css | 8 + docs/conf.py | 11 + docs/dev/hello.dot | 3 + docs/dev/reST.rst | 311 ++++++++++++++++++++-------- docs/dev/svg_image.svg | 10 + requirements-dev.txt | 1 + 6 files changed, 254 insertions(+), 90 deletions(-) create mode 100644 docs/dev/hello.dot create mode 100644 docs/dev/svg_image.svg diff --git a/docs/_themes/searx/static/searx.css b/docs/_themes/searx/static/searx.css index ee084d499..747cb0507 100644 --- a/docs/_themes/searx/static/searx.css +++ b/docs/_themes/searx/static/searx.css @@ -29,6 +29,14 @@ p.sidebar-title, .sidebar p { } +div.admonition, +div.topic { + background-color: #fafafa; + margin: 8px 0px; + padding: 1em; + border: none; +} + /* admonitions with (rendered) reST markup examples (:class: rst-example) * * .. admonition:: title of the example diff --git a/docs/conf.py b/docs/conf.py index 33954cbd2..b960621d3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,6 +20,7 @@ highlight_language = 'none' master_doc = "index" source_suffix = '.rst' +numfig = True # usage:: lorem :patch:`f373169` ipsum extlinks = {} @@ -35,6 +36,8 @@ extlinks['search'] = (SEARX_URL + '/%s', '#') extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ') extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ') extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '') +#extlinks['role'] = ( +# 'https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-%s', '') extlinks['duref'] = ( 'http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#%s', '') extlinks['durole'] = ( @@ -49,6 +52,12 @@ extensions = [ "sphinx.ext.intersphinx", "pallets_sphinx_themes", "sphinx_issues", # https://github.com/sloria/sphinx-issues/blob/master/README.rst + 'linuxdoc.rstFlatTable', # Implementation of the 'flat-table' reST-directive. + 'linuxdoc.rstKernelDoc', # Implementation of the 'kernel-doc' reST-directive. + 'linuxdoc.kernel_include', # Implementation of the 'kernel-include' reST-directive. + 'linuxdoc.manKernelDoc', # Implementation of the 'kernel-doc-man' builder + 'linuxdoc.cdomain', # Replacement for the sphinx c-domain. + 'linuxdoc.kfigure', # Sphinx extension which implements scalable image handling. ] intersphinx_mapping = { @@ -56,6 +65,8 @@ intersphinx_mapping = { "flask": ("https://flask.palletsprojects.com/", None), # "werkzeug": ("https://werkzeug.palletsprojects.com/", None), "jinja": ("https://jinja.palletsprojects.com/", None), + "linuxdoc" : ("https://return42.github.io/linuxdoc/", None), + "sphinx" : ("https://www.sphinx-doc.org/en/master/", None), } issues_github_path = "asciimoo/searx" diff --git a/docs/dev/hello.dot b/docs/dev/hello.dot new file mode 100644 index 000000000..504621dfc --- /dev/null +++ b/docs/dev/hello.dot @@ -0,0 +1,3 @@ +graph G { + Hello -- World +} diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index c8482e77d..5522f9e15 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -18,11 +18,26 @@ The sources of Searx's documentation are located at :origin:`docs`. Run ------ +.. sidebar:: Further reading + + - Sphinx-Primer_ + - `Sphinx markup constructs`_ + - reST_, docutils_, `docutils FAQ`_ + - Sphinx_, `sphinx-doc FAQ`_ + - `sphinx config`_, doctree_ + - `sphinx cross references`_ + - linuxdoc_ + - intersphinx_ + - `Sphinx's autodoc`_ + - `Sphinx's Python domain`_, `Sphinx's C domain`_ + .. contents:: Contents :depth: 3 :local: :backlinks: entry +------ + Sphinx_ and reST_ have their place in the python ecosystem. Over that reST is used in popular projects, e.g the Linux kernel documentation `[kernel doc]`_. @@ -55,18 +70,6 @@ To be more concrete what a *point of view* means. In the (:origin:`docs`) folder we have three sections (and the *blog* folder), each dedicate to a different group of audience. -.. sidebar:: Further reading - - - Sphinx-Primer_ - - `Sphinx markup constructs`_ - - reST_, docutils_, `docutils FAQ`_ - - Sphinx_, `sphinx-doc FAQ`_ - - `sphinx config`_, doctree_ - - `sphinx cross references`_ - - intersphinx_ - - `Sphinx's autodoc`_ - - `Sphinx's Python domain`_, `Sphinx's C domain`_ - User's POV: :origin:`docs/user` A typical user knows about search engines and might have heard about meta crawlers and privacy. @@ -100,25 +103,52 @@ Basic inline markup inline markup delimiters, they have to be escaped with a backslash (``\*foo is a pointer``). +.. _reST basic structure: -Roles -===== +Basic article structure +======================= -A *custom interpreted text role* (:duref:`ref `) is an inline piece of -explicit markup. It signifies that that the enclosed text should be interpreted -in a specific way. The general syntax is ``:rolename:`content```. +The basic structure of an article makes use of heading adornments to markup +chapter, sections and subsections. -Docutils supports the following roles: +#. ``=`` with overline for document title +#. ``=`` for chapters +#. ``-`` for sections +#. ``~`` for subsections -* :durole:`emphasis` -- equivalent of ``*emphasis*`` -* :durole:`strong` -- equivalent of ``**strong**`` -* :durole:`literal` -- equivalent of ````literal```` -* :durole:`subscript` -- subscript text -* :durole:`superscript` -- superscript text -* :durole:`title-reference` -- for titles of books, periodicals, and other - materials +.. _reST template: -Refer to `Sphinx Roles`_ for roles added by Sphinx. +.. admonition:: reST template + :class: rst-example + + .. code:: reST + + .. _document title: + + ============== + Document title + ============== + + Lorem ipsum dolor sit amet, consectetur adipisici elit .. + Further read :ref:`chapter title`. + + .. _chapter title: + + Chapters + ======== + + Ut enim ad minim veniam, quis nostrud exercitation ullamco + laboris nisi ut aliquid ex ea commodi consequat ... + + Section + ------- + + lorem .. + + Subsection + ~~~~~~~~~~ + + lorem .. Anchors & Links @@ -196,42 +226,29 @@ smart references ---------------- With the power of sphinx.ext.extlinks_ and intersphinx_ referencing external -content becomes smart. To refer ... +content becomes smart. -sphinx.ext.extlinks_: - -:project's wiki article: :wiki:`Searx-instances` -:to docs public URL: :docs:`dev/reST.html` -:files & folders from origin: :origin:`docs/dev/reST.rst` -:a pull request: :pull:`1756` -:a patch: :patch:`af2cae6` -:a PyPi package: :pypi:`searx` -:a manual page man: :man:`bash` - -.. code:: reST - - :project's wiki article: :wiki:`Searx-instances` - :to docs public URL: :docs:`dev/reST.html` - :files & folders from origin: :origin:`docs/dev/reST.rst` - :a pull request: :pull:`1756` - :a patch: :patch:`af2cae6` - :a PyPi package: :pypi:`searx` - :a manual page man: :man:`bash` - - -intersphinx_: - - :external anchor: :ref:`python:and` - :external doc anchor: :doc:`jinja:templates` - :python code object: :py:obj:`datetime.datetime` - :flask code object: webapp is a :py:obj:`flask.Flask` app - -.. code:: reST - - :external anchor: :ref:`python:and` - :external doc anchor: :doc:`jinja:templates` - :python code object: :py:obj:`datetime.datetime` - :flask code object: webapp is a :py:obj:`flask.Flask` app +========================== ================================== ==================================== +refer ... rendered example markup +========================== ================================== ==================================== +:rst:role:`rfc` :rfc:`822` ``:rfc:`822``` +:rst:role:`pep` :pep:`8` ``:pep:`8``` +sphinx.ext.extlinks_ +-------------------------------------------------------------------------------------------------- +project's wiki article :wiki:`Searx-instances` ``:wiki:`Searx-instances``` +to docs public URL :docs:`dev/reST.html` ``:docs:`dev/reST.html``` +files & folders origin :origin:`docs/dev/reST.rst` ``:origin:`docs/dev/reST.rst``` +pull request :pull:`1756` ``:pull:`1756``` +patch :patch:`af2cae6` ``:patch:`af2cae6``` +PyPi package :pypi:`searx` ``:pypi:`searx``` +manual page man :man:`bash` ``:man:`bash``` +intersphinx_ +-------------------------------------------------------------------------------------------------- +external anchor :ref:`python:and` ``:ref:`python:and``` +external doc anchor :doc:`jinja:templates` ``:doc:`jinja:templates``` +python code object :py:obj:`datetime.datetime` ``:py:obj:`datetime.datetime``` +flask code object :py:obj:`flask.Flask` ``:py:obj:`flask.Flask``` +========================== ================================== ==================================== Intersphinx is configured in :origin:`docs/conf.py`: @@ -242,6 +259,8 @@ Intersphinx is configured in :origin:`docs/conf.py`: "python": ("https://docs.python.org/3/", None), "flask": ("https://flask.palletsprojects.com/", None), "jinja": ("https://jinja.palletsprojects.com/", None), + "linuxdoc" : ("https://return42.github.io/linuxdoc/", None), + "sphinx" : ("https://www.sphinx-doc.org/en/master/", None), } @@ -252,52 +271,163 @@ To list all anchors of the inventory (e.g. ``python``) use: $ python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv -.. _reST basic structure: +Roles +===== -Basic article structure -======================= +A *custom interpreted text role* (:duref:`ref `) is an inline piece of +explicit markup. It signifies that that the enclosed text should be interpreted +in a specific way. The general syntax is ``:rolename:`content```. -The basic structure of an article makes use of heading adornments to markup -chapter, sections and subsections. +========================== ================================== ==================================== +role rendered example markup +========================== ================================== ==================================== +:rst:role:`guilabel` :guilabel:`&Cancel` ``:guilabel:`&Cancel``` +:rst:role:`kbd` :kbd:`C-x C-f` ``:kbd:`C-x C-f``` +:rst:role:`menuselection` :menuselection:`Open --> File` ``:menuselection:`Open --> File``` +:rst:role:`download` :download:`this file ` ``:download:`this file ``` +:rst:role:`math` :math:`a^2 + b^2 = c^2` ``:math:`a^2 + b^2 = c^2``` +:rst:role:`ref` :ref:`svg image example` ``:ref:`svg image example``` +:rst:role:`command` :command:`ls -la` ``:command:`ls -la``` +:durole:`emphasis` :emphasis:`italic` ``:emphasis:`italic``` +:durole:`strong` :strong:`bold` ``:strong:`bold``` +:durole:`literal` :literal:`foo()` ``:literal:`foo()``` +:durole:`subscript` H\ :sub:`2`\ O ``H\ :sub:`2`\ O`` +:durole:`superscript` E = mc\ :sup:`2` ``E = mc\ :sup:`2``` +:durole:`title-reference` :title:`Time` ``:title:`Time``` +========================== ================================== ==================================== -#. ``=`` with overline for document title -#. ``=`` for chapters -#. ``-`` for sections -#. ``~`` for subsections +Refer to `Sphinx Roles`_ for roles added by Sphinx. -.. _reST template: -.. admonition:: reST template +Figures & Images +================ + +Searx's sphinx setup includes: :ref:`linuxdoc:kfigure`. Scalable here means; +scalable in sense of the build process. Normally in absence of a converter +tool, the build process will break. From the authors POV it’s annoying to care +about the build process when handling with images, especially since he has no +access to the build process. With :ref:`linuxdoc:kfigure` the build process +continues and scales output quality in dependence of installed image processors. + +If you want to add an image, you should use the ``kernel-figure`` and +``kernel-image`` directives. E.g. to insert a figure with a scalable image +format use SVG (:ref:`svg_image_example`): + +.. code:: reST + + .. _svg image example: + + .. kernel-figure:: svg_image.svg + :alt: simple SVG image + + SVG image example + +.. _svg image example: + +.. kernel-figure:: svg_image.svg + :alt: simple SVG image + + SVG image example + +DOT files (aka Graphviz) +------------------------ + +The kernel figure (and image) directive support **DOT** formated files, see + +* DOT: http://graphviz.org/pdf/dotguide.pdf +* Graphviz: http://www.graphviz.org/content/dot-language + +A simple example (:ref:`hello_dot_file`): + +.. code:: reST + + .. kernel-figure:: hello.dot + :alt: hello world + + DOT's hello world example + +.. admonition:: hello.dot :class: rst-example - .. code:: reST + .. kernel-figure:: hello.dot + :alt: hello world - .. _document title: + DOT's hello world example - ============== - Document title - ============== +``kernel-render`` DOT +--------------------- - Lorem ipsum dolor sit amet, consectetur adipisici elit .. - Further read :ref:`chapter title`. +Embed *render* markups (or languages) like Graphviz's **DOT** is provided by the +``kernel-render`` directives. - .. _chapter title: +.. code:: reST - Chapters - ======== + .. kernel-render:: DOT markup + :alt: foobar digraph + :caption: Embedded **DOT** (Graphviz) code - Ut enim ad minim veniam, quis nostrud exercitation ullamco - laboris nisi ut aliquid ex ea commodi consequat ... + digraph foo { + "bar" -> "baz"; + } - Section - ------- +How this will be rendered depends on the installed tools. If Graphviz is +installed, you will see an vector image. If not the raw markup is inserted as +*literal-block* (:ref:`hello_dot_render`). - lorem .. +.. admonition:: DOT markup + :class: rst-example - Subsection - ~~~~~~~~~~ + .. _hello_dot_render: + + .. kernel-render:: DOT + :alt: foobar digraph + :caption: Embedded **DOT** (Graphviz) code + + digraph foo { + "bar" -> "baz"; + } + +The *render* directive has all the options known from the *figure* directive, +plus option ``caption``. If ``caption`` has a value, a *figure* node is +inserted. If not, a *image* node is inserted. A ``caption`` is also needed, if +you want to refer it (:ref:`hello_svg_render`). + + +``kernel-render`` SVG +--------------------- + +.. code:: reST + + .. kernel-render:: SVG markup + :caption: Embedded **SVG** markup + :alt: so-nw-arrow +.. + + .. code:: xml + + + + + + + +.. admonition:: SVG markup + :class: rst-example + + .. _hello_svg_render: + + .. kernel-render:: SVG + :caption: Embedded **SVG** markup + :alt: so-nw-arrow + + + + + + - lorem .. .. _reST lists: @@ -489,3 +619,4 @@ Further list blocks http://www.sphinx-doc.org/en/master/extdev/tutorial.html?highlight=doctree#build-phases .. _docutils: http://docutils.sourceforge.net/docs/index.html .. _docutils FAQ: http://docutils.sourceforge.net/FAQ.html +.. _linuxdoc: https://return42.github.io/linuxdoc diff --git a/docs/dev/svg_image.svg b/docs/dev/svg_image.svg new file mode 100644 index 000000000..5405f85b8 --- /dev/null +++ b/docs/dev/svg_image.svg @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/requirements-dev.txt b/requirements-dev.txt index 0bdf20469..54643908e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -11,3 +11,4 @@ transifex-client==0.12.2 unittest2==1.1.0 zope.testrunner==4.5.1 selenium==3.141.0 +linuxdoc @ git+http://github.com/return42/linuxdoc.git From b82f61f7044665b900b0d8f556cbe207f3133837 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 20 Dec 2019 11:01:41 +0100 Subject: [PATCH 05/21] doc: reST primer -- describe admonitions & customize their CSS Signed-off-by: Markus Heiser --- docs/_themes/searx/static/searx.css | 73 +++++++++++++++++------------ docs/dev/reST.rst | 72 ++++++++++++++++++++++++++-- 2 files changed, 110 insertions(+), 35 deletions(-) diff --git a/docs/_themes/searx/static/searx.css b/docs/_themes/searx/static/searx.css index 747cb0507..10cfc413e 100644 --- a/docs/_themes/searx/static/searx.css +++ b/docs/_themes/searx/static/searx.css @@ -28,53 +28,64 @@ p.sidebar-title, .sidebar p { list-style-type: disclosure-closed; } +/* admonitions +*/ -div.admonition, -div.topic { +div.admonition, div.topic { background-color: #fafafa; margin: 8px 0px; padding: 1em; - border: none; + border-radius: 3pt 0 0 3pt; + border-top: none; + border-right: none; + border-bottom: none; + border-left: 5pt solid #ccc; } +p.admonition-title:after { + content: none; +} + +.admonition.hint { border-color: #416dc0b0; } +.admonition.note { border-color: #6c856cb0; } +.admonition.tip { border-color: #85c5c2b0; } +.admonition.attention { border-color: #ecec97b0; } +.admonition.caution { border-color: #a6c677b0; } +.admonition.danger { border-color: #d46262b0; } +.admonition.important { border-color: #dfa3a3b0; } +.admonition.error { border-color: red; } +.admonition.warning { border-color: darkred; } + +.admonition.admonition-generic-admonition-title { + border-color: #416dc0b0; +} + + /* admonitions with (rendered) reST markup examples (:class: rst-example) * * .. admonition:: title of the example * :class: rst-example * .... -/* navigation menu: use sans font and select light/dark colors for better -* contrast. */ div.rst-example { - padding-left: 12px; - padding-right: 12px; - background-color: white; - transform: scale(0.9); - transition: transform 1s; + padding-left: 12px; + padding-right: 12px; + background-color: inherit; + transform: scale(0.9); + transition: transform 1s; + border-left: none; } -/* div.rst-example > .admonition-title { */ -/* background-color: inherit; */ -/* color: inherit; */ -/* } */ - -/* div.rst-example > .admonition-title:after{ */ -/* font-family: inherit; */ -/* font-style: italic; */ -/* content: " // hover mouse over .."; */ -/* } */ - @media screen { - div.rst-example:hover { - transform: scale(1); - background-color: inherit; - padding-left: inherit; - padding-right: inherit; - border-left: inherit; - } + div.rst-example:hover { + transform: scale(1); + padding-left: inherit; + padding-right: inherit; + border-left: inherit; + } - div.rst-example:hover > .admonition-title { - display: none; - } + div.rst-example:hover > .admonition-title { + display: none; + } } diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index 5522f9e15..69e4a9305 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -16,8 +16,6 @@ generated and deployed at :docs:`github.io <.>`. The sources of Searx's documentation are located at :origin:`docs`. Run :ref:`make docs-live ` to build HTML while editing. ------- - .. sidebar:: Further reading - Sphinx-Primer_ @@ -36,8 +34,6 @@ The sources of Searx's documentation are located at :origin:`docs`. Run :local: :backlinks: entry ------- - Sphinx_ and reST_ have their place in the python ecosystem. Over that reST is used in popular projects, e.g the Linux kernel documentation `[kernel doc]`_. @@ -593,6 +589,74 @@ Further list blocks - doctest blocks (:duref:`ref `) +Admonitions +=========== + +Admonitions: :dudir:`hint`, :dudir:`note`, :dudir:`tip` :dudir:`attention`, +:dudir:`caution`, :dudir:`danger`, :dudir:`error`, , :dudir:`important`, , +:dudir:`warning` and the generic :dudir:`admonition `. + +.. code:: reST + + .. admonition:: generic admonition title + + lorem ipsum .. + + .. hint:: + + lorem ipsum .. + + .. note:: + + lorem ipsum .. + + .. warning:: + + lorem ipsum .. + + +.. admonition:: generic admonition title + + lorem ipsum .. + +.. hint:: + + lorem ipsum .. + +.. note:: + + lorem ipsum .. + +.. tip:: + + lorem ipsum .. + +.. attention:: + + lorem ipsum .. + +.. caution:: + + lorem ipsum .. + +.. danger:: + + lorem ipsum .. + +.. important:: + + lorem ipsum .. + +.. error:: + + lorem ipsum .. + +.. warning:: + + lorem ipsum .. + + + .. _KISS: https://en.wikipedia.org/wiki/KISS_principle .. _readability: https://docs.python-guide.org/writing/style/ .. _Sphinx-Primer: From ae7cb5937e597dd59b652333f5e3693efef3c1aa Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 20 Dec 2019 12:10:43 +0100 Subject: [PATCH 06/21] docs: reST-primer first proofreading (WIP) Signed-off-by: Markus Heiser --- docs/dev/reST.rst | 152 ++++++++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 52 deletions(-) diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index 69e4a9305..8bab5e332 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -28,6 +28,9 @@ The sources of Searx's documentation are located at :origin:`docs`. Run - intersphinx_ - `Sphinx's autodoc`_ - `Sphinx's Python domain`_, `Sphinx's C domain`_ + - SVG_, ImageMagick_ + - DOT_, `Graphviz's dot`_, Graphviz_ + .. contents:: Contents :depth: 3 @@ -76,9 +79,9 @@ Admin's POV: :origin:`docs/admin` Developer's POV: :origin:`docs/dev` Depending on the readability_ of code, a typical developer is able to read and - understand source code. Describe what a item aims to do (e.g. a function), - describe chronological order matters, describe it. Name the *out-of-limits - condition* and all the side effects a external developer will not know. + understand source code. Describe what a item aims to do (e.g. a function). + If the chronological order matters, describe it. Name the *out-of-limits + conditions* and all the side effects a external developer will not know. .. _reST inline markup: @@ -254,7 +257,7 @@ Intersphinx is configured in :origin:`docs/conf.py`: intersphinx_mapping = { "python": ("https://docs.python.org/3/", None), "flask": ("https://flask.palletsprojects.com/", None), - "jinja": ("https://jinja.palletsprojects.com/", None), + "jinja": ("https://jinja.palletsprojects.com/", None), "linuxdoc" : ("https://return42.github.io/linuxdoc/", None), "sphinx" : ("https://www.sphinx-doc.org/en/master/", None), } @@ -298,6 +301,12 @@ Refer to `Sphinx Roles`_ for roles added by Sphinx. Figures & Images ================ +.. sidebar:: Image processing + + With the directives from :ref:`linuxdoc ` the build process + is flexible. To get best results in the generated output format, install + ImageMagick_ and Graphviz_. + Searx's sphinx setup includes: :ref:`linuxdoc:kfigure`. Scalable here means; scalable in sense of the build process. Normally in absence of a converter tool, the build process will break. From the authors POV it’s annoying to care @@ -307,36 +316,44 @@ continues and scales output quality in dependence of installed image processors. If you want to add an image, you should use the ``kernel-figure`` and ``kernel-image`` directives. E.g. to insert a figure with a scalable image -format use SVG (:ref:`svg_image_example`): +format use SVG (:ref:`svg image example`): .. code:: reST .. _svg image example: .. kernel-figure:: svg_image.svg - :alt: simple SVG image + :alt: SVG image example - SVG image example + simple SVG image + + To refer the figure, a caption block is needed: :ref:`svg image example`. .. _svg image example: .. kernel-figure:: svg_image.svg - :alt: simple SVG image + :alt: SVG image example - SVG image example + simple SVG image + +To refer the figure, a caption block is needed: :ref:`svg image example`. DOT files (aka Graphviz) ------------------------ -The kernel figure (and image) directive support **DOT** formated files, see +With :ref:`linuxdoc:kernel-figure` reST support for **DOT** formatted files is +given. -* DOT: http://graphviz.org/pdf/dotguide.pdf -* Graphviz: http://www.graphviz.org/content/dot-language +- `Graphviz's dot`_ +- DOT_ +- Graphviz_ -A simple example (:ref:`hello_dot_file`): +A simple example is shown in :ref:`dot file example`: .. code:: reST + .. _dot file example: + .. kernel-figure:: hello.dot :alt: hello world @@ -345,6 +362,8 @@ A simple example (:ref:`hello_dot_file`): .. admonition:: hello.dot :class: rst-example + .. _dot file example: + .. kernel-figure:: hello.dot :alt: hello world @@ -354,77 +373,100 @@ A simple example (:ref:`hello_dot_file`): --------------------- Embed *render* markups (or languages) like Graphviz's **DOT** is provided by the -``kernel-render`` directives. +:ref:`linuxdoc:kernel-render` directive. A simple example of embedded DOT_ is +shown in figure :ref:`dot render example`: -.. code:: reST +.. code-block:: rst - .. kernel-render:: DOT markup - :alt: foobar digraph - :caption: Embedded **DOT** (Graphviz) code - - digraph foo { - "bar" -> "baz"; - } - -How this will be rendered depends on the installed tools. If Graphviz is -installed, you will see an vector image. If not the raw markup is inserted as -*literal-block* (:ref:`hello_dot_render`). - -.. admonition:: DOT markup - :class: rst-example - - .. _hello_dot_render: + .. _dot render example: .. kernel-render:: DOT - :alt: foobar digraph - :caption: Embedded **DOT** (Graphviz) code + :alt: digraph + :caption: Embedded DOT (Graphviz) code digraph foo { "bar" -> "baz"; } -The *render* directive has all the options known from the *figure* directive, -plus option ``caption``. If ``caption`` has a value, a *figure* node is -inserted. If not, a *image* node is inserted. A ``caption`` is also needed, if -you want to refer it (:ref:`hello_svg_render`). + Attribute ``caption`` is needed, if you want to refer the figure: :ref:`dot + render example`. +Please note :ref:`build tools `. If Graphviz_ is +installed, you will see an vector image. If not, the raw markup is inserted as +*literal-block*. + +.. admonition:: kernel-render DOT + :class: rst-example + + .. _dot render example: + + .. kernel-render:: DOT + :alt: digraph + :caption: Embedded DOT (Graphviz) code + + digraph foo { + "bar" -> "baz"; + } + + Attribute ``caption`` is needed, if you want to refer the figure: :ref:`dot + render example`. ``kernel-render`` SVG --------------------- -.. code:: reST +A simple example of embedded SVG_ is shown in figure :ref:`svg render example`: - .. kernel-render:: SVG markup +.. code-block:: rst + + .. _svg render example: + + .. kernel-render:: SVG :caption: Embedded **SVG** markup :alt: so-nw-arrow .. - .. code:: xml + .. code:: xml - - - + + + -.. admonition:: SVG markup +.. admonition:: kernel-render SVG :class: rst-example - .. _hello_svg_render: + .. _svg render example: .. kernel-render:: SVG :caption: Embedded **SVG** markup :alt: so-nw-arrow - - - + + + + + .. _reST lists: List markups @@ -551,7 +593,7 @@ are mappings from field names to field bodies. They marked up like this: :fieldname: Field content :foo: first paragraph in field foo - second paragraph in field foo + second paragraph in field foo :bar: Field content @@ -561,7 +603,7 @@ are mappings from field names to field bodies. They marked up like this: :fieldname: Field content :foo: first paragraph in field foo - second paragraph in field foo + second paragraph in field foo :bar: Field content @@ -684,3 +726,9 @@ Admonitions: :dudir:`hint`, :dudir:`note`, :dudir:`tip` :dudir:`attention`, .. _docutils: http://docutils.sourceforge.net/docs/index.html .. _docutils FAQ: http://docutils.sourceforge.net/FAQ.html .. _linuxdoc: https://return42.github.io/linuxdoc +.. _SVG: https://www.w3.org/TR/SVG11/expanded-toc.html +.. _DOT: https://graphviz.gitlab.io/_pages/doc/info/lang.html +.. _`Graphviz's dot`: https://graphviz.gitlab.io/_pages/pdf/dotguide.pdf +.. _Graphviz: https://graphviz.gitlab.io + +.. _ImageMagick: https://www.imagemagick.org From b201f8459527a9a186838d1325977fe950dd2f0a Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 20 Dec 2019 17:47:24 +0100 Subject: [PATCH 07/21] docs: reST-primer continued proofreading (WIP) Signed-off-by: Markus Heiser --- docs/dev/reST.rst | 168 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 119 insertions(+), 49 deletions(-) diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index 8bab5e332..609517f6a 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -88,19 +88,23 @@ Developer's POV: :origin:`docs/dev` Basic inline markup =================== -``*italics*`` -- *italics* - one asterisk for emphasis +.. sidebar:: Inline markup -``**boldface**`` -- **boldface** - two asterisks for strong emphasis and + - :ref:`reST roles` + - :ref:`reST smart ref` -````foo()```` -- ``foo()`` - backquotes for code samples and literals. +Basic inline markup is done with asterisks and backquotes. If asterisks or +backquotes appear in running text and could be confused with inline markup +delimiters, they have to be escaped with a backslash (``\*pointer``). -``\*foo is a pointer`` -- \*foo is a pointer - If asterisks or backquotes appear in running text and could be confused with - inline markup delimiters, they have to be escaped with a backslash (``\*foo is - a pointer``). +================================================ ==================== ======================== +description rendered markup +================================================ ==================== ======================== +one asterisk for emphasis *italics* ``*italics*`` +two asterisks for strong emphasis **boldface** ``**boldface**`` +backquotes for code samples and literals ``foo()`` ````foo()```` +quote asterisks or backquotes \*foo is a pointer ``\*foo is a pointer`` +================================================ ==================== ======================== .. _reST basic structure: @@ -110,44 +114,82 @@ Basic article structure The basic structure of an article makes use of heading adornments to markup chapter, sections and subsections. -#. ``=`` with overline for document title -#. ``=`` for chapters -#. ``-`` for sections -#. ``~`` for subsections - .. _reST template: -.. admonition:: reST template - :class: rst-example +reST template +------------- + +reST template for an simple article: + +.. code:: reST + + .. _doc refname: + + ============== + Document title + ============== + + Lorem ipsum dolor sit amet, consectetur adipisici elit .. Further read + :ref:`chapter refname`. + + .. _chapter refname: + + Chapter + ======= + + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut + aliquid ex ea commodi consequat ... + + .. _section refname: + + Section + ------- + + lorem .. + + .. _subsection refname: + + Subsection + ~~~~~~~~~~ + + lorem .. + + +Headings +-------- + +#. title - with overline for document title: + + .. code:: reST + + ============== + Document title + ============== + + +#. chapter - with anchor named ``anchor name``: .. code:: reST - .. _document title: + .. _anchor name: - ============== - Document title - ============== + Chapter + ======= - Lorem ipsum dolor sit amet, consectetur adipisici elit .. - Further read :ref:`chapter title`. +#. section - .. _chapter title: + .. code:: reST - Chapters - ======== + Section + ------- - Ut enim ad minim veniam, quis nostrud exercitation ullamco - laboris nisi ut aliquid ex ea commodi consequat ... +#. subsection - Section - ------- + .. code:: reST - lorem .. + Subsection + ~~~~~~~~~~ - Subsection - ~~~~~~~~~~ - - lorem .. Anchors & Links @@ -179,18 +221,18 @@ To refer anchors use the `ref role`_ markup: .. code:: reST - Visit chapter :ref:`reST anchor`. - Or set hyperlink text manualy :ref:`foo bar `. + Visit chapter :ref:`reST anchor`. Or set hyperlink text manualy :ref:`foo + bar `. .. admonition:: ``:ref:`` role :class: rst-example - Visist chapter :ref:`reST anchor` - Or set hyperlink text manualy :ref:`foo bar `. + Visist chapter :ref:`reST anchor`. Or set hyperlink text manualy :ref:`foo + bar `. .. _reST ordinary ref: -link ordinary URL +Link ordinary URL ----------------- If you need to reference external URLs use *named* hyperlinks to maintain @@ -221,8 +263,8 @@ readability of reST sources. Here is a example taken from *this* article: .. _reST smart ref: -smart references ----------------- +Smart refs +---------- With the power of sphinx.ext.extlinks_ and intersphinx_ referencing external content becomes smart. @@ -270,6 +312,8 @@ To list all anchors of the inventory (e.g. ``python``) use: $ python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv +.. _reST roles: + Roles ===== @@ -634,9 +678,24 @@ Further list blocks Admonitions =========== -Admonitions: :dudir:`hint`, :dudir:`note`, :dudir:`tip` :dudir:`attention`, -:dudir:`caution`, :dudir:`danger`, :dudir:`error`, , :dudir:`important`, , -:dudir:`warning` and the generic :dudir:`admonition `. +Sidebar +------- + +Sidebar is an eye catcher, often used for admonitions pointing further stuff or +site effects. Here is the source of the sidebar :ref:`on top of this page `. + +.. code:: reST + + .. sidebar:: KISS_ and readability_ + + Instead of defining more and more roles, we at searx encourage our + contributors to follow principles like KISS_ and readability_. + +Generic admonition +------------------ + +The generic :dudir:`admonition ` needs a title: .. code:: reST @@ -644,6 +703,21 @@ Admonitions: :dudir:`hint`, :dudir:`note`, :dudir:`tip` :dudir:`attention`, lorem ipsum .. + +.. admonition:: generic admonition title + + lorem ipsum .. + + +Specific admonitions +-------------------- + +Specific admonitions: :dudir:`hint`, :dudir:`note`, :dudir:`tip` :dudir:`attention`, +:dudir:`caution`, :dudir:`danger`, :dudir:`error`, , :dudir:`important`, and +:dudir:`warning` . + +.. code:: reST + .. hint:: lorem ipsum .. @@ -657,10 +731,6 @@ Admonitions: :dudir:`hint`, :dudir:`note`, :dudir:`tip` :dudir:`attention`, lorem ipsum .. -.. admonition:: generic admonition title - - lorem ipsum .. - .. hint:: lorem ipsum .. From c2b9aa0c2fe5e9eee24619d2fe563da01d9ecf87 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 20 Dec 2019 20:39:14 +0100 Subject: [PATCH 08/21] docs: reST-primer describe table markup (WIP) Signed-off-by: Markus Heiser --- docs/dev/csv_table.txt | 6 + docs/dev/reST.rst | 419 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 374 insertions(+), 51 deletions(-) create mode 100644 docs/dev/csv_table.txt diff --git a/docs/dev/csv_table.txt b/docs/dev/csv_table.txt new file mode 100644 index 000000000..8a1454137 --- /dev/null +++ b/docs/dev/csv_table.txt @@ -0,0 +1,6 @@ +stub col row 1, column, "loremLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy +eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam +voluptua." +stub col row 1, "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita +kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", column +stub col row 1, column, column diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index 609517f6a..50caa0feb 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -97,14 +97,17 @@ Basic inline markup is done with asterisks and backquotes. If asterisks or backquotes appear in running text and could be confused with inline markup delimiters, they have to be escaped with a backslash (``\*pointer``). -================================================ ==================== ======================== -description rendered markup -================================================ ==================== ======================== -one asterisk for emphasis *italics* ``*italics*`` -two asterisks for strong emphasis **boldface** ``**boldface**`` -backquotes for code samples and literals ``foo()`` ````foo()```` -quote asterisks or backquotes \*foo is a pointer ``\*foo is a pointer`` -================================================ ==================== ======================== +.. table:: basic inline markup + :widths: 4 3 7 + + ================================================ ==================== ======================== + description rendered markup + ================================================ ==================== ======================== + one asterisk for emphasis *italics* ``*italics*`` + two asterisks for strong emphasis **boldface** ``**boldface**`` + backquotes for code samples and literals ``foo()`` ````foo()```` + quote asterisks or backquotes \*foo is a pointer ``\*foo is a pointer`` + ================================================ ==================== ======================== .. _reST basic structure: @@ -269,27 +272,30 @@ Smart refs With the power of sphinx.ext.extlinks_ and intersphinx_ referencing external content becomes smart. -========================== ================================== ==================================== -refer ... rendered example markup -========================== ================================== ==================================== -:rst:role:`rfc` :rfc:`822` ``:rfc:`822``` -:rst:role:`pep` :pep:`8` ``:pep:`8``` -sphinx.ext.extlinks_ --------------------------------------------------------------------------------------------------- -project's wiki article :wiki:`Searx-instances` ``:wiki:`Searx-instances``` -to docs public URL :docs:`dev/reST.html` ``:docs:`dev/reST.html``` -files & folders origin :origin:`docs/dev/reST.rst` ``:origin:`docs/dev/reST.rst``` -pull request :pull:`1756` ``:pull:`1756``` -patch :patch:`af2cae6` ``:patch:`af2cae6``` -PyPi package :pypi:`searx` ``:pypi:`searx``` -manual page man :man:`bash` ``:man:`bash``` -intersphinx_ --------------------------------------------------------------------------------------------------- -external anchor :ref:`python:and` ``:ref:`python:and``` -external doc anchor :doc:`jinja:templates` ``:doc:`jinja:templates``` -python code object :py:obj:`datetime.datetime` ``:py:obj:`datetime.datetime``` -flask code object :py:obj:`flask.Flask` ``:py:obj:`flask.Flask``` -========================== ================================== ==================================== +.. table:: smart refs with sphinx.ext.extlinks_ and intersphinx_ + :widths: 4 3 7 + + ========================== ================================== ==================================== + refer ... rendered example markup + ========================== ================================== ==================================== + :rst:role:`rfc` :rfc:`822` ``:rfc:`822``` + :rst:role:`pep` :pep:`8` ``:pep:`8``` + sphinx.ext.extlinks_ + -------------------------------------------------------------------------------------------------- + project's wiki article :wiki:`Searx-instances` ``:wiki:`Searx-instances``` + to docs public URL :docs:`dev/reST.html` ``:docs:`dev/reST.html``` + files & folders origin :origin:`docs/dev/reST.rst` ``:origin:`docs/dev/reST.rst``` + pull request :pull:`1756` ``:pull:`1756``` + patch :patch:`af2cae6` ``:patch:`af2cae6``` + PyPi package :pypi:`searx` ``:pypi:`searx``` + manual page man :man:`bash` ``:man:`bash``` + intersphinx_ + -------------------------------------------------------------------------------------------------- + external anchor :ref:`python:and` ``:ref:`python:and``` + external doc anchor :doc:`jinja:templates` ``:doc:`jinja:templates``` + python code object :py:obj:`datetime.datetime` ``:py:obj:`datetime.datetime``` + flask code object :py:obj:`flask.Flask` ``:py:obj:`flask.Flask``` + ========================== ================================== ==================================== Intersphinx is configured in :origin:`docs/conf.py`: @@ -317,30 +323,43 @@ To list all anchors of the inventory (e.g. ``python``) use: Roles ===== +.. sidebar:: Further reading + + - `Sphinx Roles`_ + - :doc:`sphinx:usage/restructuredtext/domains` + + A *custom interpreted text role* (:duref:`ref `) is an inline piece of explicit markup. It signifies that that the enclosed text should be interpreted -in a specific way. The general syntax is ``:rolename:`content```. +in a specific way. -========================== ================================== ==================================== -role rendered example markup -========================== ================================== ==================================== -:rst:role:`guilabel` :guilabel:`&Cancel` ``:guilabel:`&Cancel``` -:rst:role:`kbd` :kbd:`C-x C-f` ``:kbd:`C-x C-f``` -:rst:role:`menuselection` :menuselection:`Open --> File` ``:menuselection:`Open --> File``` -:rst:role:`download` :download:`this file ` ``:download:`this file ``` -:rst:role:`math` :math:`a^2 + b^2 = c^2` ``:math:`a^2 + b^2 = c^2``` -:rst:role:`ref` :ref:`svg image example` ``:ref:`svg image example``` -:rst:role:`command` :command:`ls -la` ``:command:`ls -la``` -:durole:`emphasis` :emphasis:`italic` ``:emphasis:`italic``` -:durole:`strong` :strong:`bold` ``:strong:`bold``` -:durole:`literal` :literal:`foo()` ``:literal:`foo()``` -:durole:`subscript` H\ :sub:`2`\ O ``H\ :sub:`2`\ O`` -:durole:`superscript` E = mc\ :sup:`2` ``E = mc\ :sup:`2``` -:durole:`title-reference` :title:`Time` ``:title:`Time``` -========================== ================================== ==================================== +The general markup is one of: -Refer to `Sphinx Roles`_ for roles added by Sphinx. +.. code:: reST + :rolename:`ref-name` + :rolename:`ref text ` + +.. table:: smart refs with sphinx.ext.extlinks_ and intersphinx_ + :widths: 4 3 7 + + ========================== ================================== ==================================== + role rendered example markup + ========================== ================================== ==================================== + :rst:role:`guilabel` :guilabel:`&Cancel` ``:guilabel:`&Cancel``` + :rst:role:`kbd` :kbd:`C-x C-f` ``:kbd:`C-x C-f``` + :rst:role:`menuselection` :menuselection:`Open --> File` ``:menuselection:`Open --> File``` + :rst:role:`download` :download:`this file ` ``:download:`this file ``` + :rst:role:`math` :math:`a^2 + b^2 = c^2` ``:math:`a^2 + b^2 = c^2``` + :rst:role:`ref` :ref:`svg image example` ``:ref:`svg image example``` + :rst:role:`command` :command:`ls -la` ``:command:`ls -la``` + :durole:`emphasis` :emphasis:`italic` ``:emphasis:`italic``` + :durole:`strong` :strong:`bold` ``:strong:`bold``` + :durole:`literal` :literal:`foo()` ``:literal:`foo()``` + :durole:`subscript` H\ :sub:`2`\ O ``H\ :sub:`2`\ O`` + :durole:`superscript` E = mc\ :sup:`2` ``E = mc\ :sup:`2``` + :durole:`title-reference` :title:`Time` ``:title:`Time``` + ========================== ================================== ==================================== Figures & Images ================ @@ -420,7 +439,7 @@ Embed *render* markups (or languages) like Graphviz's **DOT** is provided by the :ref:`linuxdoc:kernel-render` directive. A simple example of embedded DOT_ is shown in figure :ref:`dot render example`: -.. code-block:: rst +.. code:: reST .. _dot render example: @@ -460,7 +479,7 @@ installed, you will see an vector image. If not, the raw markup is inserted as A simple example of embedded SVG_ is shown in figure :ref:`svg render example`: -.. code-block:: rst +.. code:: reST .. _svg render example: @@ -768,8 +787,302 @@ Specific admonitions: :dudir:`hint`, :dudir:`note`, :dudir:`tip` :dudir:`attenti lorem ipsum .. +Tables +====== + +.. sidebar:: Nested tables + + Nested tables are ugly! Not all builder support nested tables, don't use + them! + +ASCII-art tables like :ref:`reST simple table` and :ref:`reST grid table` might +be comfortable for readers of the text-files, but they have huge disadvantages +in the creation and modifying. First, they are hard to edit. Think about +adding a row or a column to a ASCII-art table or adding a paragraph in a cell, +it is a nightmare on big tables. + + +.. sidebar:: List tables + + For meaningful patch and diff use :ref:`reST flat table`. + +Second the diff of modifying ASCII-art tables is not meaningful, e.g. widening a +cell generates a diff in which also changes are included, which are only +ascribable to the ASCII-art. Anyway, if you prefer ASCII-art for any reason, +here are some helpers: + +* `Emacs Table Mode`_ +* `Online Tables Generator`_ + +.. _reST simple table: + +Simple tables +------------- + +:duref:`Simple tables ` allow *colspan* but not *rowspan*. If +your table need some metadata (e.g. a title) you need to add the ``.. table:: +directive`` :dudir:`(ref) ` in front and place the table in its body: + +.. code:: reST + + .. table:: foo gate truth table + :widths: grid + :align: left + + ====== ====== ====== + Inputs Output + ------------- ------ + A B A or B + ====== ====== ====== + False + -------------------- + True + -------------------- + True False True + (foo) + ------ ------ ------ + False True + (foo) + ====== ============= + +.. admonition:: Simple ASCII table + :class: rst-example + + .. table:: foo gate truth table + :widths: grid + :align: left + + ====== ====== ====== + Inputs Output + ------------- ------ + A B A or B + ====== ====== ====== + False + -------------------- + True + -------------------- + True False True + (foo) + ------ ------ ------ + False True + (foo) + ====== ============= + + + +.. _reST grid table: + +Grid tables +----------- + +:duref:`Grid tables ` allow colspan *colspan* and *rowspan*: + +.. code:: reST + + .. table:: grid table example + :widths: 1 1 5 + + +------------+------------+-----------+ + | Header 1 | Header 2 | Header 3 | + +============+============+===========+ + | body row 1 | column 2 | column 3 | + +------------+------------+-----------+ + | body row 2 | Cells may span columns.| + +------------+------------+-----------+ + | body row 3 | Cells may | - Cells | + +------------+ span rows. | - contain | + | body row 4 | | - blocks. | + +------------+------------+-----------+ + +.. admonition:: ASCII grid table + :class: rst-example + + .. table:: grid table example + :widths: 1 1 5 + + +------------+------------+-----------+ + | Header 1 | Header 2 | Header 3 | + +============+============+===========+ + | body row 1 | column 2 | column 3 | + +------------+------------+-----------+ + | body row 2 | Cells may span columns.| + +------------+------------+-----------+ + | body row 3 | Cells may | - Cells | + +------------+ span rows. | - contain | + | body row 4 | | - blocks. | + +------------+------------+-----------+ + + +.. _reST flat table: + +flat-table +---------- + +The ``flat-table`` is a further developed variant of the :ref:`list tables +`. It is a double-stage list similar to the +:dudir:`list-table` with some additional features: + +column-span: ``cspan`` + with the role ``cspan`` a cell can be extended through additional columns + +row-span: ``rspan`` + with the role ``rspan`` a cell can be extended through additional rows + +auto-span: + spans rightmost cell of a table row over the missing cells on the right side + of that table-row. With Option ``:fill-cells:`` this behavior can changed + from *auto span* to *auto fill*, which automatically inserts (empty) cells + instead of spanning the last cell. + +options: + :header-rows: [int] count of header rows + :stub-columns: [int] count of stub columns + :widths: [[int] [int] ... ] widths of columns + :fill-cells: instead of auto-span missing cells, insert missing cells + +roles: + :cspan: [int] additional columns (*morecols*) + :rspan: [int] additional rows (*morerows*) + +The example below shows how to use this markup. The first level of the staged +list is the *table-row*. In the *table-row* there is only one markup allowed, +the list of the cells in this *table-row*. Exception are *comments* ( ``..`` ) +and *targets* (e.g. a ref to :ref:`row 2 of table's body `). + +.. code:: reST + + .. flat-table:: ``flat-table`` example + :header-rows: 2 + :stub-columns: 1 + :widths: 1 1 1 1 2 + + * - :rspan:`1` head / stub + - :cspan:`3` head 1.1-4 + + * - head 2.1 + - head 2.2 + - head 2.3 + - head 2.4 + + * .. row body 1 / this is a comment + + - row 1 + - :rspan:`2` cell 1-3.1 + - cell 1.2 + - cell 1.3 + - cell 1.4 + + * .. Comments and targets are allowed on *table-row* stage. + .. _`row body 2`: + + - row 2 + - cell 2.2 + - :rspan:`1` :cspan:`1` + cell 2.3 with a span over + + * col 3-4 & + * row 2-3 + + * - row 3 + - cell 3.2 + + * - row 4 + - cell 4.1 + - cell 4.2 + - cell 4.3 + - cell 4.4 + + * - row 5 + - cell 5.1 with automatic span to rigth end + + * - row 6 + - cell 6.1 + - .. + + +.. admonition:: List table + :class: rst-example + + .. flat-table:: ``flat-table`` example + :header-rows: 2 + :stub-columns: 1 + :widths: 1 1 1 1 2 + + * - :rspan:`1` head / stub + - :cspan:`3` head 1.1-4 + + * - head 2.1 + - head 2.2 + - head 2.3 + - head 2.4 + + * .. row body 1 / this is a comment + + - row 1 + - :rspan:`2` cell 1-3.1 + - cell 1.2 + - cell 1.3 + - cell 1.4 + + * .. Comments and targets are allowed on *table-row* stage. + .. _`row body 2`: + + - row 2 + - cell 2.2 + - :rspan:`1` :cspan:`1` + cell 2.3 with a span over + + * col 3-4 & + * row 2-3 + + * - row 3 + - cell 3.2 + + * - row 4 + - cell 4.1 + - cell 4.2 + - cell 4.3 + - cell 4.4 + + * - row 5 + - cell 5.1 with automatic span to rigth end + + * - row 6 + - cell 6.1 + - .. + + +CSV table +--------- + +CSV table might be the choice if you want to include CSV-data from a outstanding +(build) process into your documentation. + +.. code:: reST + + .. csv-table:: CSV table example + :header: .. , Column 1, Column 2 + :widths: 2 5 5 + :stub-columns: 1 + :file: csv_table.txt + +Content of file ``csv_table.txt``: + +.. literalinclude:: csv_table.txt + +.. admonition:: CSV table + :class: rst-example + + .. csv-table:: CSV table example + :header: .. , Column 1, Column 2 + :widths: 3 5 5 + :stub-columns: 1 + :file: csv_table.txt + + .. _KISS: https://en.wikipedia.org/wiki/KISS_principle + .. _readability: https://docs.python-guide.org/writing/style/ .. _Sphinx-Primer: http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html @@ -796,9 +1109,13 @@ Specific admonitions: :dudir:`hint`, :dudir:`note`, :dudir:`tip` :dudir:`attenti .. _docutils: http://docutils.sourceforge.net/docs/index.html .. _docutils FAQ: http://docutils.sourceforge.net/FAQ.html .. _linuxdoc: https://return42.github.io/linuxdoc + .. _SVG: https://www.w3.org/TR/SVG11/expanded-toc.html .. _DOT: https://graphviz.gitlab.io/_pages/doc/info/lang.html .. _`Graphviz's dot`: https://graphviz.gitlab.io/_pages/pdf/dotguide.pdf .. _Graphviz: https://graphviz.gitlab.io - .. _ImageMagick: https://www.imagemagick.org + +.. _`Emacs Table Mode`: https://www.emacswiki.org/emacs/TableMode +.. _`Online Tables Generator`: http://www.tablesgenerator.com/text_tables +.. _`OASIS XML Exchange Table Model`: https://www.oasis-open.org/specs/tm9901.html From d1154202bcd27a7cf3a1bed524ee6b24955df8af Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 21 Dec 2019 17:13:38 +0100 Subject: [PATCH 09/21] doc: add reST templating // incl. generic engine tabe Signed-off-by: Markus Heiser --- docs/admin/engines.rst | 68 ++++++++++++++++++++++++++++++++++++ docs/admin/index.rst | 1 + docs/conf.py | 10 +++--- docs/dev/engine_overview.rst | 2 ++ docs/dev/reST.rst | 34 +++++++++++++++++- docs/dev/search_api.rst | 7 ++++ requirements-dev.txt | 1 + 7 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 docs/admin/engines.rst diff --git a/docs/admin/engines.rst b/docs/admin/engines.rst new file mode 100644 index 000000000..40c3b9e4f --- /dev/null +++ b/docs/admin/engines.rst @@ -0,0 +1,68 @@ +.. _engines generic: + +======= +engines +======= + +.. sidebar:: Further reading .. + + - :ref:`engines generic` + - :ref:`configured engines` + - :ref:`engine settings` + - :ref:`engine file` + +============= =========== ==================== ============ +:ref:`engine settings` :ref:`engine file` +------------------------- --------------------------------- +Name (cfg) Categories +------------------------- --------------------------------- +Engine .. Paging support **P** +------------------------- -------------------- ------------ +Shortcut **S** Language support **L** +Timeout **TO** Time range support **TR** +Disabled **D** Offline **O** +------------- ----------- -------------------- ------------ +Suspend end **SE** +------------- ----------- --------------------------------- +Safe search **SS** +============= =========== ================================= + +Configuration defaults (at built time): + +.. _configured engines: + +.. jinja:: webapp + + .. flat-table:: Engines configured at built time (defaults) + :header-rows: 1 + :stub-columns: 2 + + * - Name (cfg) + - S + - Engine + - TO + - Categories + - P + - L + - SS + - D + - TR + - O + - SE + + {% for name, mod in engines.items() %} + + * - {{name}} + - !{{mod.shortcut}} + - {{mod.__name__}} + - {{mod.timeout}} + - {{", ".join(mod.categories)}} + - {{(mod.paging and "y") or ""}} + - {{(mod.language_support and "y") or ""}} + - {{(mod.safesearch and "y") or ""}} + - {{(mod.disabled and "y") or ""}} + - {{(mod.time_range_support and "y") or ""}} + - {{(mod.offline and "y") or ""}} + - {{mod.suspend_end_time}} + + {% endfor %} diff --git a/docs/admin/index.rst b/docs/admin/index.rst index f3a995769..6e9a3451f 100644 --- a/docs/admin/index.rst +++ b/docs/admin/index.rst @@ -9,3 +9,4 @@ Administrator documentation api filtron morty + engines diff --git a/docs/conf.py b/docs/conf.py index b960621d3..e49562a33 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,6 +22,11 @@ master_doc = "index" source_suffix = '.rst' numfig = True +from searx import webapp +jinja_contexts = { + 'webapp': dict(**webapp.__dict__) +} + # usage:: lorem :patch:`f373169` ipsum extlinks = {} @@ -52,11 +57,8 @@ extensions = [ "sphinx.ext.intersphinx", "pallets_sphinx_themes", "sphinx_issues", # https://github.com/sloria/sphinx-issues/blob/master/README.rst + "sphinxcontrib.jinja", # https://github.com/tardyp/sphinx-jinja 'linuxdoc.rstFlatTable', # Implementation of the 'flat-table' reST-directive. - 'linuxdoc.rstKernelDoc', # Implementation of the 'kernel-doc' reST-directive. - 'linuxdoc.kernel_include', # Implementation of the 'kernel-include' reST-directive. - 'linuxdoc.manKernelDoc', # Implementation of the 'kernel-doc-man' builder - 'linuxdoc.cdomain', # Replacement for the sphinx c-domain. 'linuxdoc.kfigure', # Sphinx extension which implements scalable image handling. ] diff --git a/docs/dev/engine_overview.rst b/docs/dev/engine_overview.rst index 92405dc64..449c837a9 100644 --- a/docs/dev/engine_overview.rst +++ b/docs/dev/engine_overview.rst @@ -29,6 +29,7 @@ the ones in the engine file. It does not matter if an option is stored in the engine file or in the settings. However, the standard way is the following: +.. _engine file: engine file ----------- @@ -43,6 +44,7 @@ time_range_support boolean support search time range offline boolean engine runs offline ======================= =========== =========================================== +.. _engine settings: settings.yml ------------ diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index 50caa0feb..9e90c8c64 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -26,6 +26,7 @@ The sources of Searx's documentation are located at :origin:`docs`. Run - `sphinx cross references`_ - linuxdoc_ - intersphinx_ + - sphinx-jinja_ - `Sphinx's autodoc`_ - `Sphinx's Python domain`_, `Sphinx's C domain`_ - SVG_, ImageMagick_ @@ -1079,6 +1080,36 @@ Content of file ``csv_table.txt``: :stub-columns: 1 :file: csv_table.txt +Templating +========== + +.. sidebar:: Build environment + + All *generic-doc* tasks are running in the :ref:`build environment `. + +Templating is suitable for documentation which is created generic at the build +time. The sphinx-jinja_ extension evaluates jinja_ templates in the :ref:`build +environment ` with installed searx modules. We use this e.g. to +build chapter: :ref:`engines generic`. + +Here is the content of the :origin:`docs/admin/engines.rst`: + +.. literalinclude:: ../admin/engines.rst + :language: reST + :start-after: .. _configured engines: + +The context for the template is selected in the line ``.. jinja:: webapp``. In +sphinx's build configuration (:origin:`docs/conf.py`) the ``webapp`` context +points to the name space of the python module: ``webapp``. + +.. code:: py + + from searx import webapp + jinja_contexts = { + 'webapp': dict(**webapp.__dict__) + } + .. _KISS: https://en.wikipedia.org/wiki/KISS_principle @@ -1109,7 +1140,8 @@ Content of file ``csv_table.txt``: .. _docutils: http://docutils.sourceforge.net/docs/index.html .. _docutils FAQ: http://docutils.sourceforge.net/FAQ.html .. _linuxdoc: https://return42.github.io/linuxdoc - +.. _jinja: https://jinja.palletsprojects.com/ +.. _sphinx-jinja: https://github.com/tardyp/sphinx-jinja .. _SVG: https://www.w3.org/TR/SVG11/expanded-toc.html .. _DOT: https://graphviz.gitlab.io/_pages/doc/info/lang.html .. _`Graphviz's dot`: https://graphviz.gitlab.io/_pages/pdf/dotguide.pdf diff --git a/docs/dev/search_api.rst b/docs/dev/search_api.rst index 158cab7c5..8ca804b8c 100644 --- a/docs/dev/search_api.rst +++ b/docs/dev/search_api.rst @@ -14,6 +14,13 @@ Furthermore, two enpoints ``/`` and ``/search`` are available for querying. Parameters ========== +.. sidebar:: Further reading .. + + - :ref:`engines generic` + - :ref:`configured engines` + - :ref:`engine settings` + - :ref:`engine file` + ``q`` : required The search query. This string is passed to external search services. Thus, searx supports syntax of each search service. For example, ``site:github.com diff --git a/requirements-dev.txt b/requirements-dev.txt index 54643908e..74754fa8a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,3 +12,4 @@ unittest2==1.1.0 zope.testrunner==4.5.1 selenium==3.141.0 linuxdoc @ git+http://github.com/return42/linuxdoc.git +sphinx-jinja From 5bdca1a5bfeb825dd1efab426a6f5ec31efba7d0 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 22 Dec 2019 11:46:03 +0100 Subject: [PATCH 10/21] doc: improved HTML table layout (CSS) Signed-off-by: Markus Heiser --- docs/_themes/searx/static/searx.css | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/_themes/searx/static/searx.css b/docs/_themes/searx/static/searx.css index 10cfc413e..347fc71ab 100644 --- a/docs/_themes/searx/static/searx.css +++ b/docs/_themes/searx/static/searx.css @@ -89,3 +89,35 @@ div.rst-example { display: none; } } + +/* Table theme +*/ + + +thead, tfoot { + background-color: #fff; +} + +th:hover, td:hover { + background-color: #ffc; +} + +thead th, tfoot th, tfoot td, tbody th { + background-color: #fffaef; +} + +tbody tr:nth-child(odd) { + background-color: #fff; +} + +tbody tr:nth-child(even) { + background-color: #fafafa; +} + +caption { + font-family: Sans Serif; + padding: 0.5em; + margin: 0.5em 0 0.5em 0; + caption-side: top; + text-align: left; +} From aa3b0265e761eec07055d8f248d677a5cb4e8725 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 22 Dec 2019 14:05:33 +0100 Subject: [PATCH 11/21] doc: add 'Architecture' article to admin section Herein we add some hints and suggestions about typical architectures of searx infrastructures. We start with a contribution from @dalf - https://github.com/asciimoo/searx/pull/1776#issuecomment-567917320 thanks @dalf !! Signed-off-by: Markus Heiser --- docs/admin/arch_public.dot | 33 +++++++++++++++++++++++++++++++++ docs/admin/architecture.rst | 24 ++++++++++++++++++++++++ docs/admin/index.rst | 1 + docs/dev/contribution_guide.rst | 2 ++ 4 files changed, 60 insertions(+) create mode 100644 docs/admin/arch_public.dot create mode 100644 docs/admin/architecture.rst diff --git a/docs/admin/arch_public.dot b/docs/admin/arch_public.dot new file mode 100644 index 000000000..a46c96de3 --- /dev/null +++ b/docs/admin/arch_public.dot @@ -0,0 +1,33 @@ +digraph G { + + node [style=filled, shape=box, fillcolor="#ffffcc", fontname="Sans"]; + edge [fontname="Sans"]; + + browser [label="Browser", shape=Mdiamond]; + rp [label="Reverse Proxy", href="url to configure reverse proxy"]; + filtron [label="Filtron", href="https://github.com/asciimoo/filtron"]; + morty [label="Morty", href="https://github.com/asciimoo/morty"]; + static [label="Static files", href="url to configure static files"]; + uwsgi [label="uwsgi", href="url to configure uwsgi"] + searx1 [label="Searx #1"]; + searx2 [label="Searx #2"]; + searx3 [label="Searx #3"]; + searx4 [label="Searx #4"]; + + browser -> rp [label="HTTPS"] + + subgraph cluster_searx { + label = "Searx instance" fontname="Sans"; + bgcolor="#fafafa"; + { rank=same; static rp }; + rp -> morty [label="optional: images and HTML pages proxy"]; + rp -> static [label="optional: reverse proxy serves directly static files"]; + rp -> filtron [label="HTTP"]; + filtron -> uwsgi [label="HTTP"]; + uwsgi -> searx1; + uwsgi -> searx2; + uwsgi -> searx3; + uwsgi -> searx4; + } + +} diff --git a/docs/admin/architecture.rst b/docs/admin/architecture.rst new file mode 100644 index 000000000..7064a294b --- /dev/null +++ b/docs/admin/architecture.rst @@ -0,0 +1,24 @@ +.. _architecture: + +============ +Architecture +============ + +.. sidebar:: Needs work! + + This article needs some work / Searx is a collaborative effort. If you have + any contribution, feel welcome to send us your :pull:`PR <../pulls>`, see + :ref:`how to contribute`. + +Herein you will find some hints and suggestions about typical architectures of +searx infrastructures. + +We start with a contribution from :pull:`@dalf <1776#issuecomment-567917320>`. +It shows a *reference* setup for public searx instances. + +.. _arch public: + +.. kernel-figure:: arch_public.dot + :alt: arch_public.dot + + Reference architecture of a public searx setup. diff --git a/docs/admin/index.rst b/docs/admin/index.rst index 6e9a3451f..1b05db42d 100644 --- a/docs/admin/index.rst +++ b/docs/admin/index.rst @@ -7,6 +7,7 @@ Administrator documentation installation api + architecture filtron morty engines diff --git a/docs/dev/contribution_guide.rst b/docs/dev/contribution_guide.rst index 6d8d3924d..ccc101d2e 100644 --- a/docs/dev/contribution_guide.rst +++ b/docs/dev/contribution_guide.rst @@ -1,3 +1,5 @@ +.. _how to contribute: + ================= How to contribute ================= From 31db843c9c1f66da4ab2f8f23f969a0671ae6e65 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 22 Dec 2019 14:08:57 +0100 Subject: [PATCH 12/21] doc: CSS - fix alignment of code block in figure blocks BTW: minor profread of reST.rst Signed-off-by: Markus Heiser --- docs/_themes/searx/static/searx.css | 8 +++++++- docs/dev/reST.rst | 7 +++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/_themes/searx/static/searx.css b/docs/_themes/searx/static/searx.css index 347fc71ab..05bbb49da 100644 --- a/docs/_themes/searx/static/searx.css +++ b/docs/_themes/searx/static/searx.css @@ -90,10 +90,16 @@ div.rst-example { } } +/* code block in figures + */ + +div.highlight pre { + text-align: left; +} + /* Table theme */ - thead, tfoot { background-color: #fff; } diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index 9e90c8c64..ff76ea91e 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -1090,10 +1090,9 @@ Templating Templating is suitable for documentation which is created generic at the build time. The sphinx-jinja_ extension evaluates jinja_ templates in the :ref:`build -environment ` with installed searx modules. We use this e.g. to -build chapter: :ref:`engines generic`. - -Here is the content of the :origin:`docs/admin/engines.rst`: +environment ` (with searx modules installed). We use this e.g. to +build chapter: :ref:`engines generic`. Below the jinja directive from the +:origin:`docs/admin/engines.rst` is shown: .. literalinclude:: ../admin/engines.rst :language: reST From 90174e215c2eeb44ad8d76d7389ec5f661e63b82 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 22 Dec 2019 23:26:06 +0100 Subject: [PATCH 13/21] doc: add plugin section to admin section (template) - Plugins configured at built time (defaults) Signed-off-by: Markus Heiser --- docs/admin/index.rst | 1 + docs/admin/plugins.rst | 39 +++++++++++++++++++++++++++++++++++++++ docs/dev/plugins.rst | 6 ++++++ 3 files changed, 46 insertions(+) create mode 100644 docs/admin/plugins.rst diff --git a/docs/admin/index.rst b/docs/admin/index.rst index 1b05db42d..c08cadb67 100644 --- a/docs/admin/index.rst +++ b/docs/admin/index.rst @@ -11,3 +11,4 @@ Administrator documentation filtron morty engines + plugins diff --git a/docs/admin/plugins.rst b/docs/admin/plugins.rst new file mode 100644 index 000000000..4ed9066fd --- /dev/null +++ b/docs/admin/plugins.rst @@ -0,0 +1,39 @@ +.. _plugins generic: + +=============== +Plugins builtin +=============== + +.. sidebar:: Further reading .. + + - :ref:`dev plugin` + +Configuration defaults (at built time): + +:DO: Default on + +.. _configured plugins: + +.. jinja:: webapp + + .. flat-table:: Plugins configured at built time (defaults) + :header-rows: 1 + :stub-columns: 1 + :widths: 3 1 9 + + * - Name + - DO + - Description + + JS & CSS dependencies + + {% for plgin in plugins %} + + * - {{plgin.name}} + - {{(plgin.default_on and "y") or ""}} + - {{plgin.description}} + + {% for dep in (plgin.js_dependencies + plgin.css_dependencies) %} + | ``{{dep}}`` {% endfor %} + + {% endfor %} diff --git a/docs/dev/plugins.rst b/docs/dev/plugins.rst index e97bbeb4a..2bf44f181 100644 --- a/docs/dev/plugins.rst +++ b/docs/dev/plugins.rst @@ -1,7 +1,13 @@ +.. _dev plugin: + ======= Plugins ======= +.. sidebar:: Further reading .. + + - :ref:`plugins generic` + Plugins can extend or replace functionality of various components of searx. Example plugin From d3e4e81fafbdf24604924ce34c70c511c0531301 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 22 Dec 2019 23:28:07 +0100 Subject: [PATCH 14/21] makefile.sphinx: fix gh-pages / pull before add commits Signed-off-by: Markus Heiser --- utils/makefile.sphinx | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/makefile.sphinx b/utils/makefile.sphinx index 5cbc5ebdd..2c1922fc9 100644 --- a/utils/makefile.sphinx +++ b/utils/makefile.sphinx @@ -198,6 +198,7 @@ $(GH_PAGES):: $(MAKE) docs [ -d "gh-pages/.git" ] || git clone $(GIT_URL) gh-pages -cd $(GH_PAGES); git checkout gh-pages >/dev/null + -cd $(GH_PAGES); git pull -cd $(GH_PAGES); ls -A | grep -v '.git$$' | xargs rm -rf cp -r $(DOCS_DIST)/* $(GH_PAGES)/ touch $(GH_PAGES)/.nojekyll From c8645d6e376ba5a072be370d12efdec298f4e3ad Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 23 Dec 2019 09:37:51 +0100 Subject: [PATCH 15/21] doc: reST-primer -- imrpove desription of definition lists Signed-off-by: Markus Heiser --- docs/dev/reST.rst | 64 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index ff76ea91e..c6aa990f2 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -574,32 +574,70 @@ List markup (:duref:`ref `) is simple: Definition list --------------- -.. sidebar:: definition term +.. sidebar:: Note .. - Note that the term cannot have more than one line of text. + - the term cannot have more than one line of text -Definition lists (:duref:`ref `) are created as follows: + - there is **no blank line between term and definition block** // this + distinguishes definition lists (:duref:`ref `) from block + quotes (:duref:`ref `). + +Each definition list (:duref:`ref `) item contains a term, +optional classifiers and a definition. A term is a simple one-line word or +phrase. Optional classifiers may follow the term on the same line, each after +an inline ' : ' (**space, colon, space**). A definition is a block indented +relative to the term, and may contain multiple paragraphs and other body +elements. There may be no blank line between a term line and a definition block +(*this distinguishes definition lists from block quotes*). Blank lines are +required before the first and after the last definition list item, but are +optional in-between. + +Definition lists are created as follows: .. code:: reST - term (up to a line of text) - Definition of the term, which must be indented + term 1 (up to a line of text) + Definition 1. - and can even consist of multiple paragraphs + See the typo : this line is not a term! - next term - Description. + And this is not term's definition. **There is a blank line** in between + the line above and this paragraph. That's why this paragraph is taken as + **block quote** (:duref:`ref `) and not as term's definition! + + term 2 + Definition 2, paragraph 1. + + Definition 2, paragraph 2. + + term 3 : classifier + Definition 3. + + term 4 : classifier one : classifier two + Definition 4. .. admonition:: definition list :class: rst-example - term (up to a line of text) - Definition of the term, which must be indented + term 1 (up to a line of text) + Definition 1. - and can even consist of multiple paragraphs + See the typo : this line is not a term! - next term - Description. + And this is not term's definition. **There is a blank line** in between + the line above and this paragraph. That's why this paragraph is taken as + **block quote** (:duref:`ref `) and not as term's definition! + + + term 2 + Definition 2, paragraph 1. + + Definition 2, paragraph 2. + + term 3 : classifier + Definition 3. + + term 4 : classifier one : classifier two Quoted paragraphs From 4ca8b69c81ddbd965ff88deeaed7bc4f0709fbf4 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 24 Dec 2019 18:48:23 +0100 Subject: [PATCH 16/21] doc(dev): add remarks about creating good commits (messages) preview (don't bookmark): https://return42.github.io/searx/dev/contribution_guide.html#code Signed-off-by: Markus Heiser --- docs/dev/contribution_guide.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/dev/contribution_guide.rst b/docs/dev/contribution_guide.rst index ccc101d2e..c6030fbe3 100644 --- a/docs/dev/contribution_guide.rst +++ b/docs/dev/contribution_guide.rst @@ -50,6 +50,16 @@ Code ==== .. _PEP8: https://www.python.org/dev/peps/pep-0008/ +.. _Conventional Commits: https://www.conventionalcommits.org/ +.. _Git Commit Good Practice: https://wiki.openstack.org/wiki/GitCommitMessages +.. _Structural split of changes: + https://wiki.openstack.org/wiki/GitCommitMessages#Structural_split_of_changes + +.. sidebar:: Create good commits! + + - `Structural split of changes`_ + - `Conventional Commits`_ + - `Git Commit Good Practice`_ In order to submit a patch, please follow the steps below: @@ -59,6 +69,9 @@ In order to submit a patch, please follow the steps below: - PEP8_ standards apply, except the convention of line length - Maximum line length is 120 characters +- The cardinal rule for creating good commits is to ensure there is only one + *logical change* per commit / read `Structural split of changes`_ + - Check if your code breaks existing tests. If so, update the tests or fix your code. @@ -66,6 +79,16 @@ In order to submit a patch, please follow the steps below: - Add yourself to the :origin:`AUTHORS.rst` file. +- Choose meaning full commit messages, read `Conventional Commits`_ + + .. code:: + + [optional scope]: + + [optional body] + + [optional footer(s)] + - Create a pull request. For more help on getting started with searx development, see :ref:`devquickstart`. From 62505f8982c2bc2cae5456a7ab50932fea580cc4 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 25 Dec 2019 09:57:21 +0100 Subject: [PATCH 17/21] docs(dev): add refs to to gitmoji and Semantic PR in contrib section preview (don't bookmark): https://return42.github.io/searx/dev/contribution_guide.html#code Signed-off-by: Markus Heiser --- docs/dev/contribution_guide.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/dev/contribution_guide.rst b/docs/dev/contribution_guide.rst index c6030fbe3..459dfb448 100644 --- a/docs/dev/contribution_guide.rst +++ b/docs/dev/contribution_guide.rst @@ -54,13 +54,16 @@ Code .. _Git Commit Good Practice: https://wiki.openstack.org/wiki/GitCommitMessages .. _Structural split of changes: https://wiki.openstack.org/wiki/GitCommitMessages#Structural_split_of_changes +.. _gitmoji: https://gitmoji.carloscuesta.me/ +.. _Semantic PR: https://github.com/zeke/semantic-pull-requests .. sidebar:: Create good commits! - `Structural split of changes`_ - `Conventional Commits`_ - `Git Commit Good Practice`_ - + - some like to use: gitmoji_ + - not yet active: `Semantic PR`_ In order to submit a patch, please follow the steps below: From 92afe68d6532c93d455b7eafb827cc18b812a327 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 26 Dec 2019 10:26:12 +0100 Subject: [PATCH 18/21] doc(dev): reST/sphinx add tabbed views extension (sphinx_tabs.tabs) See issue #1785: idea: in the doc, provide installation instructions with one tab per distrubution preview (don't bookmark): https://return42.github.io/searx/dev/reST.html#tabbed-views Signed-off-by: Markus Heiser --- docs/conf.py | 1 + docs/dev/reST.rst | 75 ++++++++++++++++++++++++++++++++++++++++++++ requirements-dev.txt | 1 + 3 files changed, 77 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index e49562a33..b07e020d1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,6 +60,7 @@ extensions = [ "sphinxcontrib.jinja", # https://github.com/tardyp/sphinx-jinja 'linuxdoc.rstFlatTable', # Implementation of the 'flat-table' reST-directive. 'linuxdoc.kfigure', # Sphinx extension which implements scalable image handling. + "sphinx_tabs.tabs", # https://github.com/djungelorm/sphinx-tabs ] intersphinx_mapping = { diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index c6aa990f2..edd7e19b7 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -1148,6 +1148,81 @@ points to the name space of the python module: ``webapp``. } +Tabbed views +============ + +.. _sphinx-tabs: https://github.com/djungelorm/sphinx-tabs +.. _basic-tabs: https://github.com/djungelorm/sphinx-tabs#basic-tabs +.. _group-tabs: https://github.com/djungelorm/sphinx-tabs#group-tabs +.. _code-tabs: https://github.com/djungelorm/sphinx-tabs#code-tabs + +With `sphinx-tabs`_ extension we have *tabbed views*. To provide installation +instructions with one tab per distribution we use the `group-tabs`_ directive, +others are basic-tabs_ and code-tabs_. + + +.. code:: reST + + .. tabs:: + + .. group-tab:: Linux + + Linux Line 1 + + .. group-tab:: Mac OSX + + Mac OSX Line 1 + + .. group-tab:: Windows + + Windows Line 1 + + .. tabs:: + + .. group-tab:: Linux + + Linux Line 1 + + .. group-tab:: Mac OSX + + Mac OSX Line 1 + + .. group-tab:: Windows + + Windows Line 1 + + +.. admonition:: Tabbed view (grouped) + :class: rst-example + + .. tabs:: + + .. group-tab:: Linux + + Linux Line 1 + + .. group-tab:: Mac OSX + + Mac OSX Line 1 + + .. group-tab:: Windows + + Windows Line 1 + + .. tabs:: + + .. group-tab:: Linux + + Linux Line 1 + + .. group-tab:: Mac OSX + + Mac OSX Line 1 + + .. group-tab:: Windows + + Windows Line 1 + .. _KISS: https://en.wikipedia.org/wiki/KISS_principle diff --git a/requirements-dev.txt b/requirements-dev.txt index 74754fa8a..3e8f617af 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -13,3 +13,4 @@ zope.testrunner==4.5.1 selenium==3.141.0 linuxdoc @ git+http://github.com/return42/linuxdoc.git sphinx-jinja +sphinx-tabs From d6f2802e4b6066b718e86ab53ea168ab2a3394e9 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 28 Dec 2019 01:01:11 +0100 Subject: [PATCH 19/21] docs(dev): add more markups to reST primer - Literal blocks - Unicode substitution - Horizontal list - Math equations Signed-off-by: Markus Heiser --- docs/conf.py | 2 + docs/dev/reST.rst | 277 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 222 insertions(+), 57 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b07e020d1..e041428ff 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -49,6 +49,8 @@ extlinks['durole'] = ( 'http://docutils.sourceforge.net/docs/ref/rst/roles.html#%s', '') extlinks['dudir'] = ( 'http://docutils.sourceforge.net/docs/ref/rst/directives.html#%s', '') +extlinks['ctan'] = ( + 'https://ctan.org/pkg/%s', 'CTAN: ') extensions = [ 'sphinx.ext.extlinks', diff --git a/docs/dev/reST.rst b/docs/dev/reST.rst index edd7e19b7..4dc1279f0 100644 --- a/docs/dev/reST.rst +++ b/docs/dev/reST.rst @@ -11,10 +11,12 @@ reST primer We at searx are using reStructuredText (aka reST_) markup for all kind of documentation, with the builders from the Sphinx_ project a HTML output is -generated and deployed at :docs:`github.io <.>`. +generated and deployed at :docs:`github.io <.>`. For build prerequisites read +:ref:`docs build`. -The sources of Searx's documentation are located at :origin:`docs`. Run -:ref:`make docs-live ` to build HTML while editing. +The source files of Searx's documentation are located at :origin:`docs`. Sphinx +assumes source files to be encoded in UTF-8 by defaul. Run :ref:`make docs-live +` to build HTML while editing. .. sidebar:: Further reading @@ -318,6 +320,123 @@ To list all anchors of the inventory (e.g. ``python``) use: $ python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv +Literal blocks +============== + +The simplest form of :duref:`literal-blocks` is a indented block introduced by +two colons (``::``). For highlighting use :dudir:`highlight` or :ref:`reST +code` directive. To include literals from external files use directive +:dudir:`literalinclude`. + +.. _reST literal: + +``::`` +------ + +.. code:: reST + + :: + + Literal block + + Lorem ipsum dolor:: + + Literal block + + Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy + eirmod tempor invidunt ut labore :: + + Literal block + +.. admonition:: Literal block + :class: rst-example + + :: + + Literal block + + Lorem ipsum dolor:: + + Literal block + + Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy + eirmod tempor invidunt ut labore :: + + Literal block + + +.. _reST code: + +``code-block`` +-------------- + +.. _pygments: https://pygments.org/languages/ + +.. sidebar:: Syntax highlighting + + is handled by pygments_. + +The :rst:dir:`code-block` directive is a variant of the :dudir:`code` directive +with additional options. To learn more about code literals visit +:ref:`sphinx:code-examples`. + +.. code-block:: reST + + The URL ``/stats`` handle is shown in :ref:`stats-handle` + + .. code-block:: Python + :caption: python code block + :name: stats-handle + + @app.route('/stats', methods=['GET']) + def stats(): + """Render engine statistics page.""" + stats = get_engines_stats() + return render( + 'stats.html' + , stats = stats ) + +.. code-block:: reST + +.. admonition:: Code block + :class: rst-example + + The URL ``/stats`` handle is shown in :ref:`stats-handle` + + .. code-block:: Python + :caption: python code block + :name: stats-handle + + @app.route('/stats', methods=['GET']) + def stats(): + """Render engine statistics page.""" + stats = get_engines_stats() + return render( + 'stats.html' + , stats = stats ) + +Unicode substitution +==================== + +The :dudir:`unicode directive ` converts Unicode +character codes (numerical values) to characters. This directive can only be +used within a substitution definition. + +.. code-block:: reST + + .. |copy| unicode:: 0xA9 .. copyright sign + .. |(TM)| unicode:: U+2122 + + Trademark |(TM)| and copyright |copy| glyphs. + +.. admonition:: Unicode + :class: rst-example + + .. |copy| unicode:: 0xA9 .. copyright sign + .. |(TM)| unicode:: U+2122 + + Trademark |(TM)| and copyright |copy| glyphs. + .. _reST roles: @@ -351,7 +470,7 @@ The general markup is one of: :rst:role:`kbd` :kbd:`C-x C-f` ``:kbd:`C-x C-f``` :rst:role:`menuselection` :menuselection:`Open --> File` ``:menuselection:`Open --> File``` :rst:role:`download` :download:`this file ` ``:download:`this file ``` - :rst:role:`math` :math:`a^2 + b^2 = c^2` ``:math:`a^2 + b^2 = c^2``` + math_ :math:`a^2 + b^2 = c^2` ``:math:`a^2 + b^2 = c^2``` :rst:role:`ref` :ref:`svg image example` ``:ref:`svg image example``` :rst:role:`command` :command:`ls -la` ``:command:`ls -la``` :durole:`emphasis` :emphasis:`italic` ``:emphasis:`italic``` @@ -371,16 +490,17 @@ Figures & Images is flexible. To get best results in the generated output format, install ImageMagick_ and Graphviz_. -Searx's sphinx setup includes: :ref:`linuxdoc:kfigure`. Scalable here means; -scalable in sense of the build process. Normally in absence of a converter +Searx's sphinx setup includes: :ref:`linuxdoc:kfigure`. Scaleable here means; +scaleable in sense of the build process. Normally in absence of a converter tool, the build process will break. From the authors POV it’s annoying to care about the build process when handling with images, especially since he has no access to the build process. With :ref:`linuxdoc:kfigure` the build process continues and scales output quality in dependence of installed image processors. -If you want to add an image, you should use the ``kernel-figure`` and -``kernel-image`` directives. E.g. to insert a figure with a scalable image -format use SVG (:ref:`svg image example`): +If you want to add an image, you should use the ``kernel-figure`` (inheritance +of :dudir:`figure`) and ``kernel-image`` (inheritance of :dudir:`image`) +directives. E.g. to insert a figure with a scaleable image format use SVG +(:ref:`svg image example`): .. code:: reST @@ -389,7 +509,7 @@ format use SVG (:ref:`svg image example`): .. kernel-figure:: svg_image.svg :alt: SVG image example - simple SVG image + Simple SVG image To refer the figure, a caption block is needed: :ref:`svg image example`. @@ -398,7 +518,7 @@ format use SVG (:ref:`svg image example`): .. kernel-figure:: svg_image.svg :alt: SVG image example - simple SVG image + Simple SVG image. To refer the figure, a caption block is needed: :ref:`svg image example`. @@ -571,6 +691,35 @@ List markup (:duref:`ref `) is simple: #. It has two items too. +Horizontal list +--------------- + +The :rst:dir:`.. hlist:: ` transforms a bullet list into a more compact +list. + +.. code:: reST + + .. hlist:: + + - first list item + - second list item + - third list item + ... + +.. admonition:: hlist + :class: rst-example + + .. hlist:: + + - first list item + - second list item + - third list item + - next list item + - next list item xxxx + - next list item yyyy + - next list item zzzz + + Definition list --------------- @@ -1158,70 +1307,84 @@ Tabbed views With `sphinx-tabs`_ extension we have *tabbed views*. To provide installation instructions with one tab per distribution we use the `group-tabs`_ directive, -others are basic-tabs_ and code-tabs_. +others are basic-tabs_ and code-tabs_. Below a *group-tab* example from +:ref:`docs build` is shown: +.. literalinclude:: ../admin/buildhosts.rst + :language: reST + :start-after: .. _system requirements: + :end-before: .. _system requirements END: + + +.. _math: + +Math equations +============== + +.. _Mathematics: https://en.wikibooks.org/wiki/LaTeX/Mathematics +.. _amsmath user guide: + http://vesta.informatik.rwth-aachen.de/ftp/pub/mirror/ctan/macros/latex/required/amsmath/amsldoc.pdf + +.. sidebar:: About LaTeX + + - `amsmath user guide`_ + - Mathematics_ + - :ref:`docs build` + +The input language for mathematics is LaTeX markup using the :ctan:`amsmath` +package. + +To embed LaTeX markup in reST documents, use role :rst:role:`:math: ` for +inline and directive :rst:dir:`.. math:: ` for block markup. .. code:: reST - .. tabs:: + In :math:numref:`schroedinger general` the time-dependent Schrödinger equation + is shown. - .. group-tab:: Linux + .. math:: + :label: schroedinger general - Linux Line 1 + \mathrm{i}\hbar\dfrac{\partial}{\partial t} |\,\psi (t) \rangle = + \hat{H} |\,\psi (t) \rangle. - .. group-tab:: Mac OSX - - Mac OSX Line 1 - - .. group-tab:: Windows - - Windows Line 1 - - .. tabs:: - - .. group-tab:: Linux - - Linux Line 1 - - .. group-tab:: Mac OSX - - Mac OSX Line 1 - - .. group-tab:: Windows - - Windows Line 1 - - -.. admonition:: Tabbed view (grouped) +.. admonition:: LaTeX math equation :class: rst-example - .. tabs:: + In :math:numref:`schroedinger general` the time-dependent Schrödinger equation + is shown. - .. group-tab:: Linux + .. math:: + :label: schroedinger general - Linux Line 1 + \mathrm{i}\hbar\dfrac{\partial}{\partial t} |\,\psi (t) \rangle = + \hat{H} |\,\psi (t) \rangle. - .. group-tab:: Mac OSX - Mac OSX Line 1 +The next example shows the difference of ``\tfrac`` (*textstyle*) and ``\dfrac`` +(*displaystyle*) used in a inline markup or another fraction. - .. group-tab:: Windows +.. code:: reST - Windows Line 1 + ``\tfrac`` **inline example** :math:`\tfrac{\tfrac{1}{x}+\tfrac{1}{y}}{y-z}` + ``\dfrac`` **inline example** :math:`\dfrac{\dfrac{1}{x}+\dfrac{1}{y}}{y-z}` - .. tabs:: +.. admonition:: Line spacing + :class: rst-example - .. group-tab:: Linux + Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy + eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam + voluptua. ... + ``\tfrac`` **inline example** :math:`\tfrac{\tfrac{1}{x}+\tfrac{1}{y}}{y-z}` + At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd + gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. - Linux Line 1 - - .. group-tab:: Mac OSX - - Mac OSX Line 1 - - .. group-tab:: Windows - - Windows Line 1 + Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy + eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam + voluptua. ... + ``\tfrac`` **inline example** :math:`\dfrac{\dfrac{1}{x}+\dfrac{1}{y}}{y-z}` + At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd + gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. .. _KISS: https://en.wikipedia.org/wiki/KISS_principle From d1892b211268d958e4134c82328ba1e6065a7fa3 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 28 Dec 2019 01:25:16 +0100 Subject: [PATCH 20/21] docs(admin): add article 'Buildhosts' with system requirements Signed-off-by: Markus Heiser --- docs/admin/buildhosts.rst | 103 ++++++++++++++++++++++++++++++++++++++ docs/admin/index.rst | 1 + docs/conf.py | 8 ++- 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 docs/admin/buildhosts.rst diff --git a/docs/admin/buildhosts.rst b/docs/admin/buildhosts.rst new file mode 100644 index 000000000..5260da033 --- /dev/null +++ b/docs/admin/buildhosts.rst @@ -0,0 +1,103 @@ +.. _buildhosts: + +========== +Buildhosts +========== + +.. sidebar:: This article needs some work + + If you have any contribution send us your :pull:`PR <../pulls>`, see + :ref:`how to contribute`. + +To get best results from build, its recommend to install additional packages +on build hosts. + +.. _docs build: + +Build docs +========== + +.. _Graphviz: https://graphviz.gitlab.io +.. _ImageMagick: https://www.imagemagick.org +.. _XeTeX: https://tug.org/xetex/ +.. _dvisvgm: https://dvisvgm.de/ + +.. sidebar:: Sphinx build needs + + - ImageMagick_ + - Graphviz_ + - XeTeX_ + - dvisvgm_ + +Most of the sphinx requirements are installed from :origin:`setup.py` and the +docs can be build from scratch with ``make docs``. For better math and image +processing additional packages are needed. The XeTeX_ needed not only for PDF +creation, its also needed for :ref:`math` when HTML output is build. + +To be able to do :ref:`sphinx:math-support` without CDNs, the math are rendered +as images (``sphinx.ext.imgmath`` extension). If your docs build (``make +docs``) shows warnings like this:: + + WARNING: dot(1) not found, for better output quality install \ + graphviz from http://www.graphviz.org + .. + WARNING: LaTeX command 'latex' cannot be run (needed for math \ + display), check the imgmath_latex setting + +you need to install additional packages on your build host, to get better HTML +output. + +.. _system requirements: + +.. tabs:: + + .. group-tab:: Ubuntu / debian + + .. code-block:: sh + + $ sudo apt install graphviz imagemagick texlive-xetex librsvg2-bin + + .. group-tab:: Arch Linux + + .. code-block:: sh + + $ sudo pacman -S graphviz imagemagick texlive-bin extra/librsvg + + .. group-tab:: Fedora / RHEL + + .. code-block:: sh + + $ sudo dnf install graphviz graphviz-gd texlive-xetex-bin librsvg2-tools + + +For PDF output you also need: + +.. tabs:: + + .. group-tab:: Ubuntu / debian + + .. code:: sh + + $ sudo apt texlive-latex-recommended texlive-extra-utils ttf-dejavu + + .. group-tab:: Arch Linux + + .. code:: sh + + $ sudo pacman -S texlive-core texlive-latexextra ttf-dejavu + + .. group-tab:: Fedora / RHEL + + .. code:: sh + + $ sudo dnf install \ + texlive-collection-fontsrecommended texlive-collection-latex \ + dejavu-sans-fonts dejavu-serif-fonts dejavu-sans-mono-fonts + +.. _system requirements END: + +.. literalinclude:: ../conf.py + :language: python + :start-after: # sphinx.ext.imgmath setup + :end-before: # sphinx.ext.imgmath setup END + diff --git a/docs/admin/index.rst b/docs/admin/index.rst index c08cadb67..7799343be 100644 --- a/docs/admin/index.rst +++ b/docs/admin/index.rst @@ -12,3 +12,4 @@ Administrator documentation morty engines plugins + buildhosts diff --git a/docs/conf.py b/docs/conf.py index e041428ff..be0c9d6ee 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -53,6 +53,7 @@ extlinks['ctan'] = ( 'https://ctan.org/pkg/%s', 'CTAN: ') extensions = [ + 'sphinx.ext.imgmath', 'sphinx.ext.extlinks', 'sphinx.ext.viewcode', "sphinx.ext.autodoc", @@ -79,10 +80,15 @@ issues_github_path = "asciimoo/searx" # HTML ----------------------------------------------------------------- sys.path.append(os.path.abspath('_themes')) - html_theme_path = ['_themes'] html_theme = "searx" +# sphinx.ext.imgmath setup +html_math_renderer = 'imgmath' +imgmath_image_format = 'svg' +imgmath_font_size = 14 +# sphinx.ext.imgmath setup END + html_theme_options = {"index_sidebar_logo": True} html_context = { "project_links": [ From b91e07bbf156241f6236b7e26d389e10e37553a3 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 28 Dec 2019 01:26:24 +0100 Subject: [PATCH 21/21] docs(css): render HTML rst-example slightly more discreet Signed-off-by: Markus Heiser --- docs/_themes/searx/static/searx.css | 33 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/_themes/searx/static/searx.css b/docs/_themes/searx/static/searx.css index 05bbb49da..d6a664f0f 100644 --- a/docs/_themes/searx/static/searx.css +++ b/docs/_themes/searx/static/searx.css @@ -24,10 +24,12 @@ p.sidebar-title, .sidebar p { margin: 6pt; } -.sidebar li { +.sidebar li, +.hlist li { list-style-type: disclosure-closed; } + /* admonitions */ @@ -69,25 +71,24 @@ p.admonition-title:after { */ div.rst-example { - padding-left: 12px; - padding-right: 12px; background-color: inherit; - transform: scale(0.9); - transition: transform 1s; + margin: 0; + border-top: none; + border-right: 1px solid #ccc; + border-bottom: none; border-left: none; + border-radius: none; + padding: 0; } -@media screen { - div.rst-example:hover { - transform: scale(1); - padding-left: inherit; - padding-right: inherit; - border-left: inherit; - } - - div.rst-example:hover > .admonition-title { - display: none; - } +div.rst-example > p.admonition-title { + font-family: Sans Serif; + font-style: italic; + font-size: 0.8em; + display: block; + border-bottom: 1px solid #ccc; + padding: 0.5em 1em; + text-align: right; } /* code block in figures