summaryrefslogtreecommitdiff
path: root/lib/spack/docs/conf.py
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-05-20 12:44:36 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2019-05-26 18:23:44 -0700
commit6380f1917a840bfe9fab6bc219c6806e30b7ce2a (patch)
tree8fe83400422448b66cb3c3c847849a1bb8a98709 /lib/spack/docs/conf.py
parent43aaf8c404e31a193d446d9074b333dd7bf1f286 (diff)
downloadspack-6380f1917a840bfe9fab6bc219c6806e30b7ce2a.tar.gz
spack-6380f1917a840bfe9fab6bc219c6806e30b7ce2a.tar.bz2
spack-6380f1917a840bfe9fab6bc219c6806e30b7ce2a.tar.xz
spack-6380f1917a840bfe9fab6bc219c6806e30b7ce2a.zip
commands: Add --header and --update options to `spack commands`
The Spack documentation currently hard-codes some functionality in `conf.py`, which makes the doc build less "pluggable" for things like localized doc builds. In particular, we unconditionally generate an index of commands and a package list as part of the docs, but those should really only be done if things are not up to date. This commit does the following: - Add `--header` option to `spack commands` so that it can do the work of prepending text to its output. - Add `--update FILE` option to `spack commands` that makes it generate a new command index *only* if FILE is out of date w.r.t. commands in the Spack source. - Simplify code in `conf.py` to use these options and only update the command index when needed.
Diffstat (limited to 'lib/spack/docs/conf.py')
-rw-r--r--lib/spack/docs/conf.py39
1 files changed, 11 insertions, 28 deletions
diff --git a/lib/spack/docs/conf.py b/lib/spack/docs/conf.py
index b826299611..4af4e13035 100644
--- a/lib/spack/docs/conf.py
+++ b/lib/spack/docs/conf.py
@@ -51,36 +51,18 @@ os.environ['PATH'] += '%s%s/bin' % (os.pathsep, spack_root)
# Set an environment variable so that colify will print output like it would to
# a terminal.
os.environ['COLIFY_SIZE'] = '25x120'
+os.environ['COLUMNS'] = '120'
-#
-# Generate package list using spack command
-#
-with open('package_list.html', 'w') as plist_file:
- subprocess.Popen(
- [spack_root + '/bin/spack', 'list', '--format=html'],
- stdout=plist_file)
+# Generate full package list if needed
+subprocess.Popen(
+ ['spack', 'list', '--format=html', '--update=package_list.html'])
-#
-# Find all the `cmd-spack-*` references and add them to a command index
-#
-import spack
-import spack.cmd
-command_names = spack.cmd.all_commands()
-documented_commands = set()
-for filename in glob('*rst'):
- with open(filename) as f:
- for line in f:
- match = re.match('.. _cmd-(spack-.*):', line)
- if match:
- documented_commands.add(match.group(1).strip())
-
-os.environ['COLUMNS'] = '120'
-shutil.copy('command_index.in', 'command_index.rst')
-with open('command_index.rst', 'a') as index:
- subprocess.Popen(
- [spack_root + '/bin/spack', 'commands', '--format=rst'] + list(
- documented_commands),
- stdout=index)
+# Generate a command index if an update is needed
+subprocess.call([
+ 'spack', 'commands',
+ '--format=rst',
+ '--header=command_index.in',
+ '--update=command_index.rst'] + glob('*rst'))
#
# Run sphinx-apidoc
@@ -158,6 +140,7 @@ copyright = u'2013-2019, Lawrence Livermore National Laboratory.'
# built documents.
#
# The short X.Y version.
+import spack
version = '.'.join(str(s) for s in spack.spack_version_info[:2])
# The full version, including alpha/beta/rc tags.
release = spack.spack_version