[IMP] contributing/doc, install: add an extension for content tabs

In many places in the docs, we need to document several flows that
differ only by a few details. For example, the steps to install Odoo
from the sources are almost identical for Windows, Linux, and Mac OS.
In other places, we'd want to suggest a command in different
environments or programming languages, etc.

This commit thus adds an extension for content tabs (tabs within the
content) to help reduce content repetition in the documentation. As a
proof of concept, the "Packaged installers" and "Source install"
sections of the "Installing Odoo" page are reworked to present their
content within tabs whenever it helps clarify the instructions.

A new python dependency is added as of this commit: `sphinx-tabs`

task-2713983

closes odoo/documentation#1528

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Co-authored-by: Lucie Van Nieuwenhuyse (luvn) <luvn@odoo.com>
This commit is contained in:
Antoine Vandevenne (anv) 2021-12-17 14:06:56 +00:00
parent b71cf50f9e
commit cf6ca0fbb2
6 changed files with 642 additions and 519 deletions

View File

@ -124,9 +124,13 @@ extensions = [
# Code switcher (switcher and case directives) # Code switcher (switcher and case directives)
'switcher', 'switcher',
# Content tabs
'sphinx_tabs.tabs',
# Strange html domain logic used in memento pages # Strange html domain logic used in memento pages
'html_domain', 'html_domain',
] ]
if odoo_dir_in_path: if odoo_dir_in_path:
# GitHub links generation # GitHub links generation
extensions += [ extensions += [
@ -167,6 +171,9 @@ supported_languages = {
# The specifications of redirect rules used by the redirects extension. # The specifications of redirect rules used by the redirects extension.
redirects_file = 'redirects.txt' redirects_file = 'redirects.txt'
sphinx_tabs_disable_tab_closing = True
sphinx_tabs_disable_css_loading = False
#=== Options for HTML output ===# #=== Options for HTML output ===#
html_theme = 'odoo_theme' html_theme = 'odoo_theme'

View File

@ -4,6 +4,8 @@
Install Install
======= =======
.. If you add content on this page, remove the redirect rule 'install -> install/install'
.. toctree:: .. toctree::
install/install install/install

File diff suppressed because it is too large Load Diff

View File

@ -521,6 +521,219 @@ Render
Customize this admonition with a **Title** of your choice. Customize this admonition with a **Title** of your choice.
.. _contributing/tabs:
Content tabs
============
.. caution::
The `tabs` directive may not work well in some situations. In particular:
- The tabs' headers cannot be translated.
- A tab cannot contain :ref:`headings <contributing/headings>`.
- An :ref:`admonition <contributing/admonitions>` cannot contain tabs.
- A tab cannot contain :ref:`internal hyperlink targets
<contributing/internal-hyperlink-targets>`.
Basic tabs
----------
RST
~~~
.. code-block:: rst
.. tabs::
.. tab:: Odoo Online
Content dedicated to Odoo Online users.
.. tab:: Odoo.sh
Alternative for Odoo.sh users.
.. tab:: On-premise
Third version for On-premise users.
Render
~~~~~~
.. tabs::
.. tab:: Odoo Online
Content dedicated to Odoo Online users.
.. tab:: Odoo.sh
Alternative for Odoo.sh users.
.. tab:: On-premise
Third version for On-premise users.
Nested tabs
-----------
RST
~~~
.. code-block:: rst
.. tabs::
.. tab:: Stars
.. tabs::
.. tab:: The Sun
The closest star to us.
.. tab:: Proxima Centauri
The second closest star to us.
.. tab:: Polaris
The North Star.
.. tab:: Moons
.. tabs::
.. tab:: The Moon
Orbits the Earth.
.. tab:: Titan
Orbits Jupiter.
Render
~~~~~~
.. tabs::
.. tab:: Stars
.. tabs::
.. tab:: The Sun
The closest star to us.
.. tab:: Proxima Centauri
The second closest star to us.
.. tab:: Polaris
The North Star.
.. tab:: Moons
.. tabs::
.. tab:: The Moon
Orbits the Earth.
.. tab:: Titan
Orbits Jupiter.
Group tabs
----------
RST
~~~
.. code-block:: rst
.. tabs::
.. group-tab:: C++
C++
.. group-tab:: Python
Python
.. group-tab:: Java
Java
.. tabs::
.. group-tab:: C++
.. code-block:: c++
int main(const int argc, const char **argv) {
return 0;
}
.. group-tab:: Python
.. code-block:: python
def main():
return
.. group-tab:: Java
.. code-block:: java
class Main {
public static void main(String[] args) {}
}
Render
~~~~~~
.. tabs::
.. group-tab:: C++
C++
.. group-tab:: Python
Python
.. group-tab:: Java
Java
.. tabs::
.. group-tab:: C++
.. code-block:: c++
int main(const int argc, const char **argv) {
return 0;
}
.. group-tab:: Python
.. code-block:: python
def main():
return
.. group-tab:: Java
.. code-block:: java
class Main {
public static void main(String[] args) {}
}
.. _contributing/document-metadata: .. _contributing/document-metadata:
Document metadata Document metadata

View File

@ -184,7 +184,7 @@ You can check your Python version with:
Install required packages Install required packages
------------------------- -------------------------
See :ref:`install/python-dependencies` See :ref:`install/dependencies`.
.. _howto/rdtraining/02_setup/install-wkhtmltopdf: .. _howto/rdtraining/02_setup/install-wkhtmltopdf:

View File

@ -2,4 +2,5 @@ libsass==0.18.0
pygments~=2.6.1 pygments~=2.6.1
pygments-csv-lexer~=0.1 pygments-csv-lexer~=0.1
sphinx~=3.0 sphinx~=3.0
sphinx-tabs~=3.2.0
werkzeug==0.14.1 werkzeug==0.14.1