diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 80cdccf5..3a7ccf66 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -17,12 +17,11 @@ sphinx: # If using Sphinx, optionally build your docs in additional formats such as PDF formats: - - pdf + - htmlzip # Optionally declare the Python requirements required to build your docs python: install: - requirements: docs/requirements.txt - method: pip - path: . - system_packages: true \ No newline at end of file + path: . \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 23448ad9..81059807 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -53,6 +53,27 @@ 'sphinx.ext.todo', 'sphinx.ext.viewcode', # Add a link to the Python source code for classes, functions etc. 'nbsphinx', + 'sphinx_search.extension', # search across multiple docsets in domain + 'sphinx.ext.viewcode', # link to view source code + 'myst_parser', # source files written in MD or RST +] + +myst_enable_extensions = [ + "amsmath", + "attrs_inline", + "colon_fence", + "deflist", + "dollarmath", + "fieldlist", + "html_admonition", + "html_image", + "inv_link", + "linkify", + "replacements", + "smartquotes", + "strikethrough", + "substitution", + "tasklist", ] autodoc_default_options = { @@ -78,7 +99,7 @@ # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: -source_suffix = '.rst' +source_suffix = ['.rst', '.md'] master_doc = 'index' # General information about the project. @@ -98,7 +119,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'README.md'] # suppress warnings for multiple possible Python references in the namespace # suppress_warnings = ['ref.python'] @@ -128,8 +149,11 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". + html_static_path = ['_static'] +html_css_files = ['theme_overrides.css'] + html_context = { 'rtd_url': 'https://docs.idmod.org/projects/covasim/en/latest', 'theme_vcs_pageview_mode': 'edit' @@ -156,6 +180,22 @@ # base URL from which the finished HTML is served. html_use_opensearch = 'docs.idmod.org/projects/covasim/en/latest' + +# -- RTD Sphinx search for searching across the entire domain, default child ------------- + +if os.environ.get('READTHEDOCS') == 'True': + + search_project_parent = "institute-for-disease-modeling-idm" + search_project = os.environ["READTHEDOCS_PROJECT"] + search_version = os.environ["READTHEDOCS_VERSION"] + + rtd_sphinx_search_default_filter = f"subprojects:{search_project}/{search_version}" + + rtd_sphinx_search_filters = { + "Search this project": f"project:{search_project}/{search_version}", + "Search all IDM docs": f"subprojects:{search_project_parent}/{search_version}", + } + # Output file base name for HTML help builder. htmlhelp_basename = 'Covasim' diff --git a/docs/requirements.txt b/docs/requirements.txt index 32f9fe40..3025a044 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -8,4 +8,7 @@ nbsphinx pandoc pypandoc optuna -seaborn \ No newline at end of file +seaborn +myst-parser +readthedocs-sphinx-search +jupyterlab \ No newline at end of file