Move all documentation generation into conf.py

- extra steps in Makefile are ignored by readthedocs
This commit is contained in:
Todd Gamblin 2016-08-30 00:47:04 -07:00
parent 47bf7ecb2b
commit dae00fec29
3 changed files with 32 additions and 21 deletions

View File

@ -21,24 +21,6 @@ I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
all: html 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. # This creates a git repository and commits generated html docs.
# It them pushes the new branch into THIS repository as gh-pages. # 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 -f package_list.rst command_index.rst
-rm -rf $(BUILDDIR)/* $(APIDOC_FILES) -rm -rf $(BUILDDIR)/* $(APIDOC_FILES)
html: apidoc custom_targets html: apidoc
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo @echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html." @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

View File

@ -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. 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 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 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: .. _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. A nicer error message is TBD in future versions of Spack.
.. _spack-cray: .. _cray-support:
Spack on Cray Spack on Cray
----------------------------- -----------------------------

View File

@ -37,7 +37,10 @@
import sys import sys
import os import os
import re
import shutil
import subprocess import subprocess
from glob import glob
# If extensions (or modules to document with autodoc) are in another directory, # 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 # add these directories to sys.path here. If the directory is relative to the
@ -50,10 +53,36 @@
os.environ['SPACK_ROOT'] = spack_root os.environ['SPACK_ROOT'] = spack_root
os.environ['PATH'] += os.pathsep + '$SPACK_ROOT/bin' os.environ['PATH'] += os.pathsep + '$SPACK_ROOT/bin'
# Get the spack version for use in the docs
spack_version = subprocess.Popen( spack_version = subprocess.Popen(
[spack_root + '/bin/spack', '-V'], [spack_root + '/bin/spack', '-V'],
stderr=subprocess.PIPE).communicate()[1].strip().split('.') 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 # Set an environment variable so that colify will print output like it would to
# a terminal. # a terminal.
os.environ['COLIFY_SIZE'] = '25x80' os.environ['COLIFY_SIZE'] = '25x80'