We detect if we are building the documentation by looking if the
sphinx or Sphinx modules are imported.
Parameters:
state (bool or None) – If provided, sets the current state of the building environment
flag (Setting to None reverts to the normal interrogation of
sys.modules)