Fix sphinx-docs job for sphinx >1.7

Upper requirements recently bumped sphinx from 1.6.5 to 1.7.4 which
breaks our docs job. This switches the apidocs build to use
sphinxcontrib.apidoc.

Change-Id: I116c520cffe74da0477f0e436b5bc3a9f2af905b
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 1f18a18..2d5c49f 100755
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -16,7 +16,6 @@
 import sys
 
 import openstackdocstheme
-from sphinx import apidoc
 
 sys.path.insert(0, os.path.abspath('../..'))
 sys.path.insert(0, os.path.abspath('.'))
@@ -29,7 +28,8 @@
     'sphinx.ext.autodoc',
     'sphinx.ext.viewcode',
     'openstackdocstheme',
-    'oslo_config.sphinxext'
+    'oslo_config.sphinxext',
+    'sphinxcontrib.apidoc'
 ]
 
 # autodoc generation is a bit aggressive and a nuisance when doing heavy
@@ -98,22 +98,6 @@
 bug_project = '910'
 bug_tag = 'docs'
 
-# TODO(mordred) We should extract this into a sphinx plugin
-def run_apidoc(_):
-    cur_dir = os.path.abspath(os.path.dirname(__file__))
-    out_dir = os.path.join(cur_dir, '_build', 'modules')
-    module = os.path.join(cur_dir, '..', '..', 'octavia_tempest_plugin')
-    # Keep the order of arguments same as the sphinx-apidoc help, otherwise it
-    # would cause unexpected errors:
-    # sphinx-apidoc [options] -o <output_path> <module_path>
-    # [exclude_pattern, ...]
-    apidoc.main([
-        '--force',
-        '-o',
-        out_dir,
-        module,
-    ])
-
-
-def setup(app):
-    app.connect('builder-inited', run_apidoc)
+apidoc_output_dir = '_build/modules'
+apidoc_module_dir = '../../octavia_tempest_plugin'
+apidoc_excluded_paths = []