doc: conf.py: make sure west is importable from Python

We need this to be able to pull in its API documentation.

This will need modifications when multi-repo support is available, in
order to get the imports from the independent West repo, but for now
just use the copy in Zephyr.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
This commit is contained in:
Marti Bolivar 2018-06-07 21:45:55 -04:00 committed by Maureen Helm
parent e802d8de35
commit 1c852ddf5c
1 changed files with 7 additions and 5 deletions

View File

@ -15,9 +15,16 @@
import sys
import os
if "ZEPHYR_BASE" not in os.environ:
sys.stderr.write("$ZEPHYR_BASE environment variable undefined.\n")
exit(1)
ZEPHYR_BASE = os.environ["ZEPHYR_BASE"]
# Add the 'extensions' directory to sys.path, to enable finding Sphinx
# extensions within.
sys.path.insert(0, os.path.join(os.path.abspath('.'), 'extensions'))
# Also add west, to be able to pull in its API docs.
sys.path.append(os.path.abspath(os.path.join(ZEPHYR_BASE, 'scripts', 'meta')))
# -- General configuration ------------------------------------------------
@ -52,11 +59,6 @@ project = u'Zephyr Project'
copyright = u'2015-2017 Zephyr Project members and individual contributors.'
author = u'many'
if "ZEPHYR_BASE" not in os.environ:
sys.stderr.write("$ZEPHYR_BASE environment variable undefined.\n")
exit(1)
ZEPHYR_BASE = os.environ["ZEPHYR_BASE"]
# The following code tries to extract the information by reading the Makefile,
# when Sphinx is run directly (e.g. by Read the Docs).
try: