Bake in oslo sample config generation to sphinx build

The expectation from users is that to build docs locally all you need
to do is run build_sphinx on the repo and the docs will be fully
created. When we added the sample config to the tempest docs we ignored
this and just added the sample config generation to the docs tox job.
This commit fixes this by baking in the sample config generation to
the sphinx conf.py file which should ensure we have the sample config
generated every time that we call build_sphinx.

Change-Id: Ifd570707847f52592f5bc9bc743b8d3c98512639
diff --git a/doc/source/conf.py b/doc/source/conf.py
index daa293c..3ec25ea 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -13,6 +13,19 @@
 
 import sys
 import os
+import subprocess
+
+# Build a tempest sample config file:
+def build_sample_config(app):
+    root_dir = os.path.dirname(
+        os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+    subprocess.call(["oslo-config-generator", "--config-file",
+                     "tools/config/config-generator.tempest.conf",
+                     "--output-file", "doc/source/_static/tempest.conf"],
+                    cwd=root_dir)
+
+def setup(app):
+    app.connect('builder-inited', build_sample_config)
 
 # 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
diff --git a/tox.ini b/tox.ini
index eae6fc7..15652e8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -110,7 +110,6 @@
 [testenv:docs]
 # The sample config file we generate is included in the sphinxdoc, so build that first.
 commands =
-   oslo-config-generator --config-file tools/config/config-generator.tempest.conf --output-file doc/source/_static/tempest.conf
    python setup.py build_sphinx {posargs}
 
 [testenv:pep8]