"""Sphinx config file.""" import datetime import subprocess from pathlib import Path from haddock import version as haddock_version extensions = [ "sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx.ext.coverage", "sphinx.ext.doctest", "sphinx.ext.extlinks", "sphinx.ext.ifconfig", "sphinx.ext.intersphinx", "sphinx.ext.napoleon", "sphinx.ext.todo", "sphinx.ext.viewcode", "sphinxarg.ext", "sphinx.ext.autosectionlabel", "myst_parser", "sphinx_rtd_theme", ] source_suffix = { ".rst": "restructuredtext", ".txt": "markdown", ".md": "markdown", } master_doc = "pages/index" project = "haddock3" year = datetime.date.today().year author = "BonvinLab" copyright = "{0}, {1}".format(year, author) version = release = haddock_version # docs/ is the Sphinx source root: docs/pages/ holds hand-authored content, # docs/src/ holds content generated by sphinx-apidoc / build_defaults_rst.py. # Everything else directly under docs/ (this file, README.md, Makefile, # build_defaults_rst.py, titles.yaml) is build tooling, not a documentation # page. Only README.md needs excluding explicitly -- the others don't match # source_suffix, so Sphinx never treats them as documents. exclude_patterns = ["README.md"] todo_include_todos = True pygments_style = "trac" templates_path = ["."] extlinks = { "issue": ("https://github.com/haddocking/haddock3/issues/%s", "#"), "pr": ("https://github.com/haddocking/haddock3/pull/%s", "PR #"), } intersphinx_mapping = { "python": ("https://docs.python.org/3", None), } linkcheck_ignore = [r"https://codecov.io/*"] html_theme = "sphinx_rtd_theme" html_use_smartypants = True html_last_updated_fmt = "%b %d, %Y" html_split_index = False html_short_title = "%s-%s" % (project, version) # master_doc lives at pages/index, so it builds to pages/index.html rather # than index.html at the site root. Static hosts (GitHub Pages included) # need an index.html at the root to serve the bare site URL, so redirect/ # provides one that forwards to pages/index.html. html_extra_path = ["redirect"] autosectionlabel_prefix_document = True napoleon_use_ivar = True napoleon_use_rtype = False napoleon_use_param = False # myst options myst_heading_anchors = 3 # prepare default yaml RST # this procedure is not part of the docs configuration for sphinx. # it is a quick "hack" to run the script that generates rst files for the # default parameters def build_default_rst(*args): """Build the RST files for default parameters when Sphinx is initiated.""" repo_root = Path(__file__).parent.parent build_yaml_rst_path = str(Path(__file__).parent / "build_defaults_rst.py") subprocess.run( ["python", build_yaml_rst_path], cwd=str(repo_root), timeout=60, check=True, capture_output=False, ) def setup(app): app.connect("builder-inited", build_default_rst)