Skip to content

Commit

Permalink
Allow detecting documentation regardless of testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiirola committed Aug 30, 2024
1 parent b327c19 commit bf9a569
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyomo/common/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def UnavailableClass(unavailable_module):

class UnavailableMeta(type):
def __getattr__(cls, name):
if building_documentation():
if building_documentation(ignore_testing_flag=True):
# If we are building documentation, avoid the
# DeferredImportError (we will still raise one if
# someone attempts to *create* an instance of this
Expand Down
8 changes: 5 additions & 3 deletions pyomo/common/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ def in_testing_environment(state=NOTSET):
in_testing_environment.state = None


def building_documentation():
def building_documentation(ignore_testing_flag=False):
"""Return True if we are building the Sphinx documentation
Returns
-------
bool
"""
return not in_testing_environment() and (
"""
import sys

return (ignore_testing_flag or not in_testing_environment()) and (
'sphinx' in sys.modules or 'Sphinx' in sys.modules
)

0 comments on commit bf9a569

Please sign in to comment.