Commit 196e55a0 authored by Duncan Macleod's avatar Duncan Macleod

added sphinx documentation

should almost completely replace the Conda wiki page, and looks nicer
parent 8a3b9abe
......@@ -9,6 +9,7 @@ variables:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
......@@ -36,3 +37,36 @@ build-nightly:
- docker build --no-cache --pull -t $NIGHTLY -f Dockerfile-singularity .
- docker push $NIGHTLY
# -- documentation
stage: test
image: python:3.7
- branches
- tags
- merge_requests
- python -m pip install -r docs/requirements.txt
- cd docs
- python -m sphinx -M html . ../build/sphinx
- build/sphinx/html
- .cache/pip
stage: build
- docs
- master
- mv build/sphinx/html public
- public
LSCSoft Conda
|MIT license| |Build status|
.. |MIT license| image::
.. |Build status| image::
LSCSoft Conda is a programme to manage and distribute software
used by the LIGO Scientific Collaboration and partner groups
using the `conda <>`_ package manager, and the
`conda-forge <>`_ community.
1. Install conda (or `Miniconda <>`_)
2. Add the conda-forge channel:
conda config --add channels conda-forge
3. Install packages:
conda install gwpy pycbc ...
If you would like to improve LSCSoft Conda, simply add a package
to the conda-forge channel, then
`open a ticket <>`_
to ask that it gets included in one of the environments.
img.badge {
max-width: none;
# -*- coding: utf-8 -*-
# Configuration file for the Sphinx documentation builder.
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
from sphinx.util import logging
# -- Path setup --------------------------------------------------------------
# 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
# documentation root, use os.path.abspath to make it absolute, like shown here.
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'LSCSoft Conda'
copyright = '2019, The LIGO Scientific Collaboration'
author = 'The LIGO Scientific Collaboration'
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = ''
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"collapse_navigation": False,
"display_version": False,
"sticky_navigation": True,
"logo_only": True,
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
# html_sidebars = {}
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "_static/lsc-logo.png"
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'LSCSoftCondadoc'
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Latex figure (float) alignment
# 'figure_align': 'htbp',
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'LSCSoftConda.tex', 'LSCSoft Conda Documentation',
'The LIGO Scientific Collaboration', 'manual'),
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'lscsoftconda', 'LSCSoft Conda Documentation',
[author], 1)
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'LSCSoftConda', 'LSCSoft Conda Documentation',
author, 'LSCSoftConda', 'One line description of project.',
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
# epub_identifier = ''
# A unique identification for the text.
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# -- Create extra content -----------------------------------------------------
def build_environment_list(_):
from pathlib import Path
from utils import (find_environments, write_environment)
logger = logging.getLogger('environments')
for env in find_environments(path=Path.cwd().parent):
envfn = Path('environments')/(env.stem + '.rst')
with open(envfn, 'w') as envf:
write_environment(env, file=envf)"created {0}".format(envfn))
# -- Setup --------------------------------------------------------------------
def setup(app):
app.connect('builder-inited', build_environment_list)
Pre-built environments
The LSCSoft Conda team currently provides pre-defined environments for a number
of version of Python.
You can install these by downloading the relevant YAML file from the repository
and installing them.
.. toctree::
:caption: Available environments
.. LSCSoft Conda documentation master file, created by
sphinx-quickstart on Wed Feb 6 08:39:38 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. sectionauthor:: Duncan Macleod <>
.. title:: LSCSoft Conda
.. _lscsoft-conda:
.. include:: ../README.rst
.. toctree::
:caption: Documentation
:maxdepth: 2
Using LSCSoft Conda
**LSCSoft Conda is fully supported on 64-bit Linux and macOS, support for
other platforms is on a best-effort basis only.**
1. Install conda
Using software provided by LSCSoft Conda requires the conda package manager.
We recommend installing `Miniconda <>`_,
however you can also install conda
`using your Linux package manager <>`_.
2. Add the conda-forge channnel
All LSCSoft Conda packages are distributed on the conda-forge channnel.
.. code-block:: shell
conda config --add channels conda-forge
3. Install packages
You should now be able to install packages into the current conda environment:
.. code-block:: bash
conda install gwpy
or you can create a new environment:
.. code-block:: bash
conda create --name lscsoft python=3.7 gwpy pycbc
#!/usr/bin/env python
"""Format the current list of environments for inclusion in the sphinx docs
import os.path
import pathlib
import re
import yaml
from astropy.table import Table
def find_environments(path=None):
"""Finds all of the environment.yml files under the given path
if path is None:
path = pathlib.Path(_file_).resolve().parent.parent
yield from path.glob('environment-*.yml')
def list_environments(path=None, file=None):
yamls = find_environments(path=path)
for yaml in map(os.path.basename, yamls):
"* `{0} <"
def pinned_version(spec):
match ="\A[a-zA-Z0-9_\s]+=", spec)
if match:
return spec[match.end():].strip()
return None
def write_environment(env, file=None):
env = pathlib.Path(env)
with"rb") as envf:
content = yaml.load(envf)
# write name
name = content['name']
print("*" * len(name), file=file)
print(name, file=file)
print("*" * len(name), file=file)
print("", file=file)
# write link
print("| **Download:** `{0} <"
channels = content['channels']
if 'nodefaults' not in channels:
channels.insert(0, 'defaults')
print("| **Channels:** ``{0}``".format("``, ``".join(channels)),
print("| **Install:**\n\n::\n\n"
" conda env create --file {0}\n".format(,
# write packages
print("| **Packages:**\n", file=file)
rows = []
images = {}
for pkg in content['dependencies']:
pname = re.split("[>=]", pkg)[0].strip()
version = pinned_version(pkg)
"`{0} <{0}/>`_".format(pname),
if version:
colour = "orange" if version.startswith("0.") else "blue"
images["{0}-version".format(pname)] = (
version, colour,
"{0} version on conda-forge".format(pname),
images["{0}-version".format(pname)] = (
"{0} version on conda-forge".format(pname),
images["{0}-platform".format(pname)] = (
"{0} version on conda-forge".format(pname),
tab = Table(rows=rows, names=('Package name', 'Version', 'Platforms'))
tab.write(file, format='ascii.rst')
for img, (url, alt) in images.items():
print("", file=file)
print(".. |{0}| image:: {1}".format(img, url), file=file)
print(" :alt: {0}".format(alt), file=file)
print(" :class: badge", file=file)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment