summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-08-30 00:47:04 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-08-30 00:47:04 -0700
commitdae00fec299a5c147094d6873a263506cffeb12e (patch)
treeecd6ffa2e61c7742711d1e4c1b5734b607319433
parent47bf7ecb2bbb505b9a18046a8ddfb3974c4fb0d7 (diff)
downloadspack-dae00fec299a5c147094d6873a263506cffeb12e.tar.gz
spack-dae00fec299a5c147094d6873a263506cffeb12e.tar.bz2
spack-dae00fec299a5c147094d6873a263506cffeb12e.tar.xz
spack-dae00fec299a5c147094d6873a263506cffeb12e.zip
Move all documentation generation into conf.py
- extra steps in Makefile are ignored by readthedocs
-rw-r--r--lib/spack/docs/Makefile20
-rw-r--r--lib/spack/docs/basic_usage.rst4
-rw-r--r--lib/spack/docs/conf.py29
3 files changed, 32 insertions, 21 deletions
diff --git a/lib/spack/docs/Makefile b/lib/spack/docs/Makefile
index 00203b5b61..302ffd4c97 100644
--- a/lib/spack/docs/Makefile
+++ b/lib/spack/docs/Makefile
@@ -22,24 +22,6 @@ I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
all: html
#
-# This autogenerates a package list.
-#
-package_list:
- spack package-list > package_list.rst
-
-#
-# Generate a command index
-#
-command_index:
- cp command_index.in command_index.rst
- echo >> command_index.rst
- grep -ho '.. _spack-.*:' *rst \
- | perl -pe 's/.. _([^:]*):/ * :ref:`\1`/' \
- | sort >> command_index.rst
-
-custom_targets: package_list command_index
-
-#
# This creates a git repository and commits generated html docs.
# It them pushes the new branch into THIS repository as gh-pages.
#
@@ -92,7 +74,7 @@ clean:
-rm -f package_list.rst command_index.rst
-rm -rf $(BUILDDIR)/* $(APIDOC_FILES)
-html: apidoc custom_targets
+html: apidoc
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
diff --git a/lib/spack/docs/basic_usage.rst b/lib/spack/docs/basic_usage.rst
index a5478d10c2..342c93d609 100644
--- a/lib/spack/docs/basic_usage.rst
+++ b/lib/spack/docs/basic_usage.rst
@@ -779,7 +779,7 @@ use the triplet form of platform, operating system and processor.
Users on non-Cray systems won't have to worry about specifying the architecture.
Spack will autodetect what kind of operating system is on your machine as well
as the processor. For more information on how the architecture can be
-used on Cray machines, check here :ref:`spack-cray`
+used on Cray machines, check here :ref:`cray-support`
.. _sec-virtual-dependencies:
@@ -1798,7 +1798,7 @@ This issue typically manifests with the error below:
A nicer error message is TBD in future versions of Spack.
-.. _spack-cray:
+.. _cray-support:
Spack on Cray
-----------------------------
diff --git a/lib/spack/docs/conf.py b/lib/spack/docs/conf.py
index f3cb268177..1416074356 100644
--- a/lib/spack/docs/conf.py
+++ b/lib/spack/docs/conf.py
@@ -37,7 +37,10 @@
import sys
import os
+import re
+import shutil
import subprocess
+from glob import glob
# 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
@@ -50,10 +53,36 @@ spack_root = '../../..'
os.environ['SPACK_ROOT'] = spack_root
os.environ['PATH'] += os.pathsep + '$SPACK_ROOT/bin'
+# Get the spack version for use in the docs
spack_version = subprocess.Popen(
[spack_root + '/bin/spack', '-V'],
stderr=subprocess.PIPE).communicate()[1].strip().split('.')
+#
+# Generate package list using spack command
+#
+with open('package_list.rst', 'w') as plist_file:
+ subprocess.Popen(
+ [spack_root + '/bin/spack', 'package-list'], stdout=plist_file)
+
+#
+# Find all the `spack-*` references and add them to a command index
+#
+command_names = []
+for filename in glob('*rst'):
+ with open(filename) as f:
+ for line in f:
+ match = re.match(r'.. _(spack-[^:]*)', line)
+ if match:
+ command_names.append(match.group(1).strip())
+
+shutil.copy('command_index.in', 'command_index.rst')
+with open('command_index.rst', 'a') as index:
+ index.write('\n')
+ for cmd in command_names:
+ index.write(' * :ref:`%s`\n' % cmd)
+
+
# Set an environment variable so that colify will print output like it would to
# a terminal.
os.environ['COLIFY_SIZE'] = '25x80'