From 1c852ddf5ca0107ee903c5811e7e7c288ca74f6b Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Thu, 7 Jun 2018 21:45:55 -0400 Subject: [PATCH] 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 --- doc/conf.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index e71210c804a..819b5684bb8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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: