Skip to content

Commit

Permalink
Fix documentation build.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Aug 27, 2023
1 parent 281f71c commit afeb3ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
21 changes: 21 additions & 0 deletions colour_hdri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,27 @@
tonemapping_operator_Tumblin1999,
)

from colour.utilities import is_matplotlib_installed

# Exposing "colour.plotting" sub-package if "Matplotlib" is available.
if is_matplotlib_installed():
import colour_hdri.plotting as plotting # noqa: F401, PLR0402
else:

class MockPlotting: # pragma: no cover
"""
Mock object for :mod:`colour_hdri.plotting` sub-package raising an exception
if the sub-package is accessed but *Matplotlib* is not installed.
"""

def __getattr__(self, attribute) -> Any:
"""Return the value from the attribute with given name."""

is_matplotlib_installed(raise_exception=True)

globals()["plotting"] = MockPlotting() # pragma: no cover


__author__ = "Colour Developers"
__copyright__ = "Copyright 2015 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
Expand Down
6 changes: 5 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
"""

import re
import sys
from pathlib import Path

import colour_hdri as package
sys.path.append(str(Path(__file__).parent.parent))

import colour_hdri as package # noqa: E402

basename = re.sub(
"_(\\w)", lambda x: x.group(1).upper(), package.__name__.title()
Expand Down

0 comments on commit afeb3ac

Please sign in to comment.