diff --git a/doc/source/conf.py b/doc/source/conf.py index 65eec4644b..49f35e923c 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -86,9 +86,9 @@ "sphinx.ext.extlinks", "sphinx.ext.intersphinx", "sphinx_autodoc_typehints", + "sphinx_jinja", "sphinx_design", "sphinx_copybutton", - "sphinx_gallery.gen_gallery", "sphinxemoji.sphinxemoji", "sphinx.ext.graphviz", "sphinx_reredirects", @@ -187,6 +187,24 @@ "substitutions.rst", ] +BUILD_API = True if os.environ.get("BUILD_API", "true") == "true" else False +if not BUILD_API: + exclude_patterns.extend(["api/**", "mapdl_commands/**", "api.rst"]) + +BUILD_EXAMPLES = True if os.environ.get("BUILD_EXAMPLES", "true") == "true" else False +if not BUILD_EXAMPLES: + exclude_patterns.extend(["examples/index.rst", "examples/**", "examples/**/**"]) + suppress_warnings.append("ref.*") +else: + extensions.append("sphinx_gallery.gen_gallery") + +jinja_contexts = { + "main_toctree": { + "build_api": BUILD_API, + "build_examples": BUILD_EXAMPLES, + }, +} + # make rst_epilog a variable, so you can add other epilog parts to it rst_epilog = "" diff --git a/doc/source/index.rst b/doc/source/index.rst index e9b46222fd..9be02bcf23 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -5,16 +5,21 @@ .. meta:: :keywords: pymapdl mapdl simulation finite elements python - -.. toctree:: - :hidden: - :maxdepth: 3 - - getting_started/index - user_guide/index - mapdl_commands/index - api/index - examples/index +.. jinja:: main_toctree + + .. toctree:: + :hidden: + :maxdepth: 3 + + getting_started/index + user_guide/index + {% if build_api %} + mapdl_commands/index + api/index + {% endif %} + {% if build_examples %} + examples/index + {% endif %} .. image:: ../source/_static/logo_dark.png diff --git a/pyproject.toml b/pyproject.toml index ad9ce5c1be..5d0d56843b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,6 +97,7 @@ doc = [ "sphinx-copybutton==0.5.2", "sphinx-design==0.6.0", "sphinx-gallery==0.16.0", + "sphinx-jinja==2.0.2", "sphinx-notfound-page==1.0.2", "sphinxcontrib-websupport==1.2.7", "sphinxemoji==0.3.1",