[build-system]
build-backend = "setuptools.build_meta"
requires = [
  "setuptools",
  "setuptools-scm>=7",
]

[project]
name = "sphinx-gallery"
description = "A Sphinx extension that builds an HTML gallery of examples from any set of Python scripts."
readme = "README.rst"
license = { text = "3-clause BSD" }
authors = [
  { name = "Óscar Nájera", email = "najera.oscar@gmail.com" },
]
requires-python = ">=3.10"
classifiers = [
  "Development Status :: 4 - Beta",
  "Framework :: Sphinx :: Extension",
  "Intended Audience :: Developers",
  "Programming Language :: Python",
  "Programming Language :: Python :: 3 :: Only",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
  "Programming Language :: Python :: 3.13",
  "Programming Language :: Python :: 3.14",
]
dynamic = [
  "version",
]
dependencies = [
  "pillow",
  "sphinx>=6", # 6.0.0 out on 2022/12/29
]
optional-dependencies.animations = [
  "sphinxcontrib-video",
]
optional-dependencies.dev = [
  "absl-py",
  "graphviz",
  "intersphinx-registry",
  "ipython",
  "joblib",
  "jupyterlite-sphinx>=0.17.1",
  "lxml",
  "matplotlib",
  "mypy",
  "numpy",
  "packaging",
  "plotly",
  "pydata-sphinx-theme",
  "pytest",
  "pytest-coverage",
  "seaborn",
  "sphinx-design",
  "sphinxcontrib-video",
  "statsmodels",
  "types-docutils",
  "types-pillow",
  "types-pygments",
]
optional-dependencies.jupyterlite = [
  "jupyterlite-sphinx",
]
optional-dependencies.parallel = [
  "joblib",
]
optional-dependencies.recommender = [
  "numpy",
]
optional-dependencies.show-api-usage = [
  "graphviz",
]
optional-dependencies.show-memory = [
  "memory-profiler",
]
urls.Documentation = "https://sphinx-gallery.github.io"
urls.Source = "https://github.com/sphinx-gallery/sphinx-gallery"
scripts.sphinx_gallery_py2jupyter = "sphinx_gallery.notebook:python_to_jupyter_cli"

[tool.setuptools]
include-package-data = true
dynamic.version = { attr = "sphinx_gallery.__version__" }
packages.find.where = [
  ".",
]  # list of folders that contain the packages (["."] by default)
packages.find.include = [
  "sphinx_gallery*",
]  # package names should match these glob patterns (["*"] by default)
packages.find.namespaces = true  # allow scanning PEP 420 namespaces (true by default)

[tool.ruff]
exclude = [
  "__init__.py",
  "plot_syntaxerror.py",
]
lint.select = [
  "D",
  "E",
  "F",
  "W",
]
lint.ignore = [
  # TODO: A lot of these we should actually fix eventually
  "D105", # Missing docstring in magic method
  "D401", # First line of docstring should be in imperative mood
]
lint.per-file-ignores."*examples*/*.py" = [
  "D205", # 1 blank line required between summary line and description
  "D400", # First line should end with a period
  "E402", # Module level import not at top of file
]
lint.per-file-ignores."bin/*.py" = [
  "D205", # 1 blank line required between summary line and description
  "D400", # First line should end with a period
]
lint.per-file-ignores."examples/no_output/plot_syntaxerror.py" = [
  "E999", # SyntaxError
]
lint.per-file-ignores."sphinx_gallery/tests/*.py" = [
  "D103", # Missing docstring in public function
  "E501", # line too long
]
lint.per-file-ignores."sphinx_gallery/tests/testconfs/src/*.py" = [
  "D205", # 1 blank line required between summary line and description
  "D400", # First line should end with a period
]
lint.per-file-ignores."tutorials/*.py" = [
  "D205", # 1 blank line required between summary line and description
  "D400", # First line should end with a period
  "E402", # Module level import not at top of file
]
lint.per-file-ignores."tutorials/plot_parse.py" = [
  "D202", # [*] No blank lines allowed after function docstring (found 1)
  "D209", # Multi-line docstring closing quotes should be on a separate line
]
# Example files cannot satisfy below rules due to header and imports in code blocks
lint.pydocstyle.convention = "numpy"

[tool.codespell]
builtin = "clear,rare,informal,names,usage"
# comma separated list of words to be ignored by codespell.
# Words are case sensitive based on how they are written in the dictionary file
ignore-words-list = "master"

[tool.mypy]
python_version = "3.10"  # keep in sync with requires-python
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false
disallow_incomplete_defs = false
check_untyped_defs = true
no_implicit_optional = true
local_partial_types = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
strict_equality = true
show_error_codes = true
exclude = [
  "^build/",
  "^doc/",
  "^examples/",
  "^examples/plotly_examples/",
  "^pyvista_examples/",
  "^tutorials/",
  "^sphinx_gallery/tests/tinybuild/",
  "^sphinx_gallery\\.egg-info/",
]

# Ignore test files for now
[[tool.mypy.overrides]]
module = "sphinx_gallery.tests.*"
ignore_errors = true

# Third-party packages without type stubs
[[tool.mypy.overrides]]
module = [
  "joblib.*",
  "memory_profiler.*",
  "matplotlib.*",
  "seaborn.*",
  "plotly.*",
  "pypandoc",
  "graphviz",
]
ignore_missing_imports = true

[tool.pytest]
ini_options.addopts = [
  "--color=yes",
  "--cov-report=",
  "--cov=sphinx_gallery",
  "--durations=5",
  "-r a",
  "--tb=short",
  "--junit-xml=junit-results.xml",
]
ini_options.python_files = "tests/*.py"
ini_options.norecursedirs = "build _build auto_examples gen_modules sphinx_gallery/tests/tinybuild"
ini_options.filterwarnings = [
  "ignore:.*HasTraits.trait_.*:DeprecationWarning",
  "ignore:.*importing the ABCs.*:DeprecationWarning",
  "ignore:np.loads is deprecated, use pickle.loads instead:DeprecationWarning",
  "ignore:'U' mode is deprecated:DeprecationWarning",
  "ignore:node class .* is already registered.*:",
  "ignore:node.Node.* is obsoleted by Node.*:",
]
ini_options.junit_family = "xunit2"
ini_options.markers = [
  "add_conf: Configuration file.",
  "add_file: Add file to src.",
]
