|
| 1 | +import os |
| 2 | +import sys |
| 3 | + |
| 4 | +from pyfracval import __version__, _authors |
| 5 | + |
| 6 | +# Adjust the path to go up two levels from docs/source/ to the project root |
| 7 | +sys.path.insert(0, os.path.abspath("../../")) |
| 8 | + |
| 9 | +# Configuration file for the Sphinx documentation builder. |
| 10 | +# |
| 11 | +# For the full list of built-in configuration values, see the documentation: |
| 12 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 13 | + |
| 14 | +# -- Project information ----------------------------------------------------- |
| 15 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information |
| 16 | + |
| 17 | + |
| 18 | +project = name = "PyFracVAL" |
| 19 | +author = _authors |
| 20 | +copyright = f"2025, {_authors}" |
| 21 | +version, release = __version__, __version__.split("+")[0] |
| 22 | + |
| 23 | +# -- General configuration --------------------------------------------------- |
| 24 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration |
| 25 | + |
| 26 | +extensions = [ |
| 27 | + "sphinx.ext.napoleon", # Support for NumPy and Google style docstrings |
| 28 | + "sphinx.ext.autodoc", # Core Sphinx library to pull documentation from docstrings |
| 29 | + "sphinx.ext.intersphinx", # Link to other projects' documentation (e.g. Python, NumPy) |
| 30 | + "sphinx.ext.viewcode", # Add links to source code |
| 31 | + "sphinx_autodoc_typehints", # Automatically document types based on type hints |
| 32 | + "autoapi.extension", |
| 33 | + "myst_parser", # Parse Markdown files |
| 34 | + "sphinx_copybutton", # Add copy buttons to code blocks |
| 35 | + "sphinxcontrib.bibtex", # For BibTeX citation support |
| 36 | +] |
| 37 | + |
| 38 | +source_suffix = { |
| 39 | + ".rst": "restructuredtext", |
| 40 | + ".md": "markdown", |
| 41 | +} |
| 42 | + |
| 43 | +myst_enable_extensions = [ |
| 44 | + "colon_fence", # Enables ::: directives for admonitions, etc. |
| 45 | + "deflist", # Enables definition lists |
| 46 | + "linkify", # Auto-detect URLs and make them links (use with caution) |
| 47 | + "tasklist", # Enable checklists - [ ] / - [x] |
| 48 | +] |
| 49 | + |
| 50 | +templates_path = ["_templates"] |
| 51 | +exclude_patterns = [] |
| 52 | + |
| 53 | + |
| 54 | +# -- Options for HTML output ------------------------------------------------- |
| 55 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output |
| 56 | + |
| 57 | +# html_theme = "alabaster" |
| 58 | +# html_theme = "furo" |
| 59 | +html_theme = "pydata_sphinx_theme" |
| 60 | +# html_logo = "_static/logo.png" # Optional: Add a logo file to _static/ |
| 61 | +# html_favicon = "_static/favicon.ico" # Optional: Add a favicon |
| 62 | +html_static_path = ["_static"] |
| 63 | + |
| 64 | +# Napoleon config |
| 65 | +# napoleon_google_docstring = True |
| 66 | +napoleon_numpy_docstring = True |
| 67 | +napoleon_include_init_with_doc = False # Include __init__ docstrings |
| 68 | +napoleon_include_private_with_doc = False # Usually False |
| 69 | +napoleon_include_special_with_doc = True |
| 70 | +napoleon_use_admonition_for_examples = False |
| 71 | +napoleon_use_admonition_for_notes = False |
| 72 | +napoleon_use_admonition_for_references = False |
| 73 | +# napoleon_use_ivar = False |
| 74 | +# napoleon_use_param = True |
| 75 | +# napoleon_use_rtype = True |
| 76 | +napoleon_preprocess_types = False # Let sphinx-autodoc-typehints handle types |
| 77 | +napoleon_type_aliases = None |
| 78 | +napoleon_attr_annotations = True |
| 79 | + |
| 80 | +# autodoc |
| 81 | +autoclass_content = "class" |
| 82 | +autodoc_typehints = "none" |
| 83 | +autodoc_default_options = { |
| 84 | + "members": True, |
| 85 | + "member-order": "bysource", |
| 86 | + "undoc-members": True, |
| 87 | + "show-inheritance": True, |
| 88 | +} |
| 89 | +inheritance_alias = {} |
| 90 | + |
| 91 | +# autoapi |
| 92 | +autoapi_dirs = ["../../pyfracval"] |
| 93 | +autoapi_options = [ |
| 94 | + "members", |
| 95 | + # "undoc-members", |
| 96 | + # "private-members", |
| 97 | + # "show-inheritance", |
| 98 | + # "show-module-summary", |
| 99 | + # "special-members", # '__init__' etc. |
| 100 | + "imported-members", |
| 101 | +] |
| 102 | +autoapi_ignore = ["*migrations*", "__init__*"] |
| 103 | +autoapi_add_toctree_entry = True |
| 104 | + |
| 105 | +## Use sphinx-autodoc-typehints setup |
| 106 | +# Add parameter types from Napoleon processing |
| 107 | +always_document_param_types = True |
| 108 | +# Show short names for types (e.g. ndarray instead of numpy.ndarray) |
| 109 | +typehints_fully_qualified = False |
| 110 | +# Process return type hints |
| 111 | +typehints_document_rtype = True |
| 112 | +# Don't use napoleon rtype processing, let extension handle it |
| 113 | +# typehints_use_rtype = False |
| 114 | +# Show default values after comma, 'braces' is other option |
| 115 | +# typehints_defaults = "comma" |
| 116 | +# Optional: Simplify representation of complex types like Union[str, Path] |
| 117 | +# typehints_formatter = lambda annotation, config: repr(annotation) |
| 118 | +always_use_bars_union = True |
| 119 | + |
| 120 | +## BibTeX Configuration: Tell the extension where your .bib file is: |
| 121 | +bibtex_bibfiles = ["references.bib"] # Assumes references.bib is in docs/source/ |
| 122 | +bibtex_default_style = "unsrt" # Common numeric style, others: plain, alpha |
| 123 | +# Optional: Control how citations look, e.g. [(Morán et al. 2019)] |
| 124 | +bibtex_reference_style = "author_year" |
| 125 | + |
| 126 | +## Intersphinx Configuration: Set up links to external documentation: |
| 127 | +intersphinx_mapping = { |
| 128 | + "python": ("https://docs.python.org/3/", None), |
| 129 | + "numpy": ("https://numpy.org/doc/stable/", None), |
| 130 | + "pytest": ("https://docs.pytest.org/en/stable/", None), |
| 131 | + # Add others like scipy, pandas if you use/reference them |
| 132 | +} |
0 commit comments