diff --git a/docs/conf.py b/docs/conf.py index 46fdd87..2b16ebc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,6 +8,31 @@ import os from pkg_resources import get_distribution import sys +import mock + +# See +# (http://read-the-docs.readthedocs.org/en/latest/faq.html#\ +# i-get-import-errors-on-libraries-that-depend-on-c-modules) + +class Mock(mock.Mock): + + @classmethod + def __getattr__(cls, name): + return Mock() + + +MOCK_MODULES = ( + 'google', + 'google.appengine', + 'google.appengine.api', + 'google.appengine.api.app_identiy', + 'google.appengine.api.urlfetch', + 'google.appengine.ext', + 'google.appengine.ext.webapp', + 'google.appengine.ext.webapp.util', +) + + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -40,32 +65,18 @@ exclude_patterns = ['_build'] # settings module and load it. This assumes django has been installed # (but it must be for the docs to build), so if it has not already # been installed run `pip install -r docs/requirements.txt`. +os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.contrib.test_django_settings' import django if django.VERSION[1] < 7: sys.path.insert(0, '.') - os.environ['DJANGO_SETTINGS_MODULE'] = 'django_settings' # -- Options for HTML output ---------------------------------------------- +# We fake our more expensive imports when building the docs. +sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) + # We want to set the RTD theme, but not if we're on RTD. -if os.environ.get('READTHEDOCS', None) == 'True': - # Download the GAE SDK if we are building on READTHEDOCS. - docs_dir = os.path.dirname(os.path.abspath(__file__)) - root_dir = os.path.abspath(os.path.join(docs_dir, '..')) - gae_dir = os.path.join(root_dir, 'google_appengine') - if not os.path.isdir(gae_dir): - scripts_dir = os.path.join(root_dir, 'scripts') - sys.path.append(scripts_dir) - import fetch_gae_sdk - # The first argument is the script name and the second is - # the destination dir (where google_appengine is downloaded). - result = fetch_gae_sdk.main([None, root_dir]) - if result not in (0, None): - sys.stderr.write('Result failed %d\n' % (result,)) - sys.exit(result) - # Allow imports from the GAE directory as well. - sys.path.append(gae_dir) -else: +if os.environ.get('READTHEDOCS', None) != 'True': import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] diff --git a/docs/django_settings.py b/docs/django_settings.py deleted file mode 100644 index dd524da..0000000 --- a/docs/django_settings.py +++ /dev/null @@ -1 +0,0 @@ -SECRET_KEY = 'abcdefg' diff --git a/docs/requirements.txt b/docs/requirements.txt index 7b9458e..433a833 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,6 +1,7 @@ django flask keyring +mock pycrypto>=2.6 pyopenssl>=0.14 python-gflags diff --git a/scripts/build_docs.sh b/scripts/build_docs.sh index b583416..170b113 100755 --- a/scripts/build_docs.sh +++ b/scripts/build_docs.sh @@ -14,15 +14,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Build the oauth2client docs, installing the GAE SDK as needed. +# Build the oauth2client docs. set -e -if [[ -z "${SKIP_GAE_SDK}" ]]; then - scripts/fetch_gae_sdk.py - export PYTHONPATH="${PWD}/google_appengine:${PYTHONPATH}" -fi - rm -rf docs/_build/* docs/source/* sphinx-apidoc --separate --force -o docs/source oauth2client # We only have one package, so modules.rst is overkill.