diff --git a/lib/spack/docs/.gitignore b/lib/spack/docs/.gitignore
index 26c343d3eb1dfb14f411b2e7b8851ae7da36fc74..0bbf78cce02258b2c52ee26982eaa3ab9f8bc674 100644
--- a/lib/spack/docs/.gitignore
+++ b/lib/spack/docs/.gitignore
@@ -1,4 +1,5 @@
 package_list.rst
 command_index.rst
 spack*.rst
+modules.rst
 _build
diff --git a/lib/spack/docs/Makefile b/lib/spack/docs/Makefile
index 302ffd4c97979c48031b4c3af55b7f529a8821fe..f9eae29187f570f7fd8bc769d24c0980190a9c00 100644
--- a/lib/spack/docs/Makefile
+++ b/lib/spack/docs/Makefile
@@ -74,7 +74,7 @@ clean:
 	-rm -f package_list.rst command_index.rst
 	-rm -rf $(BUILDDIR)/* $(APIDOC_FILES)
 
-html: apidoc
+html:
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
 	@echo
 	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
diff --git a/lib/spack/docs/conf.py b/lib/spack/docs/conf.py
index 06a2523ca2c5af37a5b4dcfe0dbd452f2bfab181..c0dccaa6baa1c2d65332ff05a968cd560acc26da 100644
--- a/lib/spack/docs/conf.py
+++ b/lib/spack/docs/conf.py
@@ -42,6 +42,7 @@
 import shutil
 import subprocess
 from glob import glob
+from sphinx.apidoc import main as sphinx_apidoc
 
 # -- Spack customizations -----------------------------------------------------
 
@@ -93,6 +94,10 @@
     for cmd in sorted(command_names):
         index.write('   * :ref:`%s`\n' % cmd)
 
+
+# Run sphinx-apidoc
+sphinx_apidoc(['-T', '-o', '.', '../spack'])
+
 #
 # Exclude everything in spack.__all__ from indexing.  All of these
 # symbols are imported from elsewhere in spack; their inclusion in