From f5f0669803ebfaf3ee115507e7a05bbf71c20471 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:14:34 -0400 Subject: [PATCH 001/113] add astropy-helpers --- .gitmodules | 3 +++ astropy_helpers | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 astropy_helpers diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..aca5d4a73 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "astropy_helpers"] + path = astropy_helpers + url = git@github.com:astropy/astropy-helpers diff --git a/astropy_helpers b/astropy_helpers new file mode 160000 index 000000000..aaa450659 --- /dev/null +++ b/astropy_helpers @@ -0,0 +1 @@ +Subproject commit aaa4506595b88d46c2cffe06741e36947bb58a55 From d5ee582addf596ae27dc6e357686514a30f055fa Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:40:21 -0400 Subject: [PATCH 002/113] move tutorials to docs subdir --- .../tutorials}/Coordinates/Coordinates.ipynb | 0 .../tutorials}/Coordinates/HCG7_2MASS.tbl | 0 .../tutorials}/Coordinates/HCG7_SDSS_cutout.jpg | Bin .../tutorials}/Coordinates/HCG7_SDSS_photo.dat | 0 .../tutorials}/Coordinates/requirements.txt | 0 .../tutorials}/FITS-header/FITS-header.ipynb | 0 .../tutorials}/FITS-header/input_file.fits | Bin .../tutorials}/FITS-header/requirements.txt | 0 .../tutorials}/FITS-images/FITS-images.ipynb | 0 .../tutorials}/FITS-images/requirements.txt | 0 .../tutorials}/FITS-tables/FITS-tables.ipynb | 0 .../tutorials}/FITS-tables/requirements.txt | 0 .../Plot-Catalog/Young-Objects-Compilation.csv | 0 .../tutorials}/Plot-Catalog/plot-catalog.ipynb | 0 .../tutorials}/Plot-Catalog/requirements.txt | 0 .../tutorials}/Plot-Catalog/simple_table.csv | 0 .../tutorials}/Quantities/Quantities.ipynb | 0 .../tutorials}/Quantities/requirements.txt | 0 {tutorials => docs/tutorials}/UVES/CaII-1.png | Bin {tutorials => docs/tutorials}/UVES/CaII-2.png | Bin {tutorials => docs/tutorials}/UVES/CaII-3.png | Bin .../tutorials}/UVES/CaII-lines-all.png | Bin .../tutorials}/UVES/CaII-lines-one.png | Bin {tutorials => docs/tutorials}/UVES/CaII.png | Bin {tutorials => docs/tutorials}/UVES/UVES.ipynb | 0 {tutorials => docs/tutorials}/UVES/requirements.txt | 0 .../tutorials}/redshift_plot/ang_dist.png | Bin .../tutorials}/redshift_plot/redshift_plot.ipynb | 0 .../tutorials}/redshift_plot/requirements.txt | 0 {tutorials => docs/tutorials}/vo/README.rst | 0 .../tutorials}/vo/conesearch_tutorial.ipynb | 0 31 files changed, 0 insertions(+), 0 deletions(-) rename {tutorials => docs/tutorials}/Coordinates/Coordinates.ipynb (100%) rename {tutorials => docs/tutorials}/Coordinates/HCG7_2MASS.tbl (100%) rename {tutorials => docs/tutorials}/Coordinates/HCG7_SDSS_cutout.jpg (100%) rename {tutorials => docs/tutorials}/Coordinates/HCG7_SDSS_photo.dat (100%) rename {tutorials => docs/tutorials}/Coordinates/requirements.txt (100%) rename {tutorials => docs/tutorials}/FITS-header/FITS-header.ipynb (100%) rename {tutorials => docs/tutorials}/FITS-header/input_file.fits (100%) rename {tutorials => docs/tutorials}/FITS-header/requirements.txt (100%) rename {tutorials => docs/tutorials}/FITS-images/FITS-images.ipynb (100%) rename {tutorials => docs/tutorials}/FITS-images/requirements.txt (100%) rename {tutorials => docs/tutorials}/FITS-tables/FITS-tables.ipynb (100%) rename {tutorials => docs/tutorials}/FITS-tables/requirements.txt (100%) rename {tutorials => docs/tutorials}/Plot-Catalog/Young-Objects-Compilation.csv (100%) rename {tutorials => docs/tutorials}/Plot-Catalog/plot-catalog.ipynb (100%) rename {tutorials => docs/tutorials}/Plot-Catalog/requirements.txt (100%) rename {tutorials => docs/tutorials}/Plot-Catalog/simple_table.csv (100%) rename {tutorials => docs/tutorials}/Quantities/Quantities.ipynb (100%) rename {tutorials => docs/tutorials}/Quantities/requirements.txt (100%) rename {tutorials => docs/tutorials}/UVES/CaII-1.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII-2.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII-3.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII-lines-all.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII-lines-one.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII.png (100%) rename {tutorials => docs/tutorials}/UVES/UVES.ipynb (100%) rename {tutorials => docs/tutorials}/UVES/requirements.txt (100%) rename {tutorials => docs/tutorials}/redshift_plot/ang_dist.png (100%) rename {tutorials => docs/tutorials}/redshift_plot/redshift_plot.ipynb (100%) rename {tutorials => docs/tutorials}/redshift_plot/requirements.txt (100%) rename {tutorials => docs/tutorials}/vo/README.rst (100%) rename {tutorials => docs/tutorials}/vo/conesearch_tutorial.ipynb (100%) diff --git a/tutorials/Coordinates/Coordinates.ipynb b/docs/tutorials/Coordinates/Coordinates.ipynb similarity index 100% rename from tutorials/Coordinates/Coordinates.ipynb rename to docs/tutorials/Coordinates/Coordinates.ipynb diff --git a/tutorials/Coordinates/HCG7_2MASS.tbl b/docs/tutorials/Coordinates/HCG7_2MASS.tbl similarity index 100% rename from tutorials/Coordinates/HCG7_2MASS.tbl rename to docs/tutorials/Coordinates/HCG7_2MASS.tbl diff --git a/tutorials/Coordinates/HCG7_SDSS_cutout.jpg b/docs/tutorials/Coordinates/HCG7_SDSS_cutout.jpg similarity index 100% rename from tutorials/Coordinates/HCG7_SDSS_cutout.jpg rename to docs/tutorials/Coordinates/HCG7_SDSS_cutout.jpg diff --git a/tutorials/Coordinates/HCG7_SDSS_photo.dat b/docs/tutorials/Coordinates/HCG7_SDSS_photo.dat similarity index 100% rename from tutorials/Coordinates/HCG7_SDSS_photo.dat rename to docs/tutorials/Coordinates/HCG7_SDSS_photo.dat diff --git a/tutorials/Coordinates/requirements.txt b/docs/tutorials/Coordinates/requirements.txt similarity index 100% rename from tutorials/Coordinates/requirements.txt rename to docs/tutorials/Coordinates/requirements.txt diff --git a/tutorials/FITS-header/FITS-header.ipynb b/docs/tutorials/FITS-header/FITS-header.ipynb similarity index 100% rename from tutorials/FITS-header/FITS-header.ipynb rename to docs/tutorials/FITS-header/FITS-header.ipynb diff --git a/tutorials/FITS-header/input_file.fits b/docs/tutorials/FITS-header/input_file.fits similarity index 100% rename from tutorials/FITS-header/input_file.fits rename to docs/tutorials/FITS-header/input_file.fits diff --git a/tutorials/FITS-header/requirements.txt b/docs/tutorials/FITS-header/requirements.txt similarity index 100% rename from tutorials/FITS-header/requirements.txt rename to docs/tutorials/FITS-header/requirements.txt diff --git a/tutorials/FITS-images/FITS-images.ipynb b/docs/tutorials/FITS-images/FITS-images.ipynb similarity index 100% rename from tutorials/FITS-images/FITS-images.ipynb rename to docs/tutorials/FITS-images/FITS-images.ipynb diff --git a/tutorials/FITS-images/requirements.txt b/docs/tutorials/FITS-images/requirements.txt similarity index 100% rename from tutorials/FITS-images/requirements.txt rename to docs/tutorials/FITS-images/requirements.txt diff --git a/tutorials/FITS-tables/FITS-tables.ipynb b/docs/tutorials/FITS-tables/FITS-tables.ipynb similarity index 100% rename from tutorials/FITS-tables/FITS-tables.ipynb rename to docs/tutorials/FITS-tables/FITS-tables.ipynb diff --git a/tutorials/FITS-tables/requirements.txt b/docs/tutorials/FITS-tables/requirements.txt similarity index 100% rename from tutorials/FITS-tables/requirements.txt rename to docs/tutorials/FITS-tables/requirements.txt diff --git a/tutorials/Plot-Catalog/Young-Objects-Compilation.csv b/docs/tutorials/Plot-Catalog/Young-Objects-Compilation.csv similarity index 100% rename from tutorials/Plot-Catalog/Young-Objects-Compilation.csv rename to docs/tutorials/Plot-Catalog/Young-Objects-Compilation.csv diff --git a/tutorials/Plot-Catalog/plot-catalog.ipynb b/docs/tutorials/Plot-Catalog/plot-catalog.ipynb similarity index 100% rename from tutorials/Plot-Catalog/plot-catalog.ipynb rename to docs/tutorials/Plot-Catalog/plot-catalog.ipynb diff --git a/tutorials/Plot-Catalog/requirements.txt b/docs/tutorials/Plot-Catalog/requirements.txt similarity index 100% rename from tutorials/Plot-Catalog/requirements.txt rename to docs/tutorials/Plot-Catalog/requirements.txt diff --git a/tutorials/Plot-Catalog/simple_table.csv b/docs/tutorials/Plot-Catalog/simple_table.csv similarity index 100% rename from tutorials/Plot-Catalog/simple_table.csv rename to docs/tutorials/Plot-Catalog/simple_table.csv diff --git a/tutorials/Quantities/Quantities.ipynb b/docs/tutorials/Quantities/Quantities.ipynb similarity index 100% rename from tutorials/Quantities/Quantities.ipynb rename to docs/tutorials/Quantities/Quantities.ipynb diff --git a/tutorials/Quantities/requirements.txt b/docs/tutorials/Quantities/requirements.txt similarity index 100% rename from tutorials/Quantities/requirements.txt rename to docs/tutorials/Quantities/requirements.txt diff --git a/tutorials/UVES/CaII-1.png b/docs/tutorials/UVES/CaII-1.png similarity index 100% rename from tutorials/UVES/CaII-1.png rename to docs/tutorials/UVES/CaII-1.png diff --git a/tutorials/UVES/CaII-2.png b/docs/tutorials/UVES/CaII-2.png similarity index 100% rename from tutorials/UVES/CaII-2.png rename to docs/tutorials/UVES/CaII-2.png diff --git a/tutorials/UVES/CaII-3.png b/docs/tutorials/UVES/CaII-3.png similarity index 100% rename from tutorials/UVES/CaII-3.png rename to docs/tutorials/UVES/CaII-3.png diff --git a/tutorials/UVES/CaII-lines-all.png b/docs/tutorials/UVES/CaII-lines-all.png similarity index 100% rename from tutorials/UVES/CaII-lines-all.png rename to docs/tutorials/UVES/CaII-lines-all.png diff --git a/tutorials/UVES/CaII-lines-one.png b/docs/tutorials/UVES/CaII-lines-one.png similarity index 100% rename from tutorials/UVES/CaII-lines-one.png rename to docs/tutorials/UVES/CaII-lines-one.png diff --git a/tutorials/UVES/CaII.png b/docs/tutorials/UVES/CaII.png similarity index 100% rename from tutorials/UVES/CaII.png rename to docs/tutorials/UVES/CaII.png diff --git a/tutorials/UVES/UVES.ipynb b/docs/tutorials/UVES/UVES.ipynb similarity index 100% rename from tutorials/UVES/UVES.ipynb rename to docs/tutorials/UVES/UVES.ipynb diff --git a/tutorials/UVES/requirements.txt b/docs/tutorials/UVES/requirements.txt similarity index 100% rename from tutorials/UVES/requirements.txt rename to docs/tutorials/UVES/requirements.txt diff --git a/tutorials/redshift_plot/ang_dist.png b/docs/tutorials/redshift_plot/ang_dist.png similarity index 100% rename from tutorials/redshift_plot/ang_dist.png rename to docs/tutorials/redshift_plot/ang_dist.png diff --git a/tutorials/redshift_plot/redshift_plot.ipynb b/docs/tutorials/redshift_plot/redshift_plot.ipynb similarity index 100% rename from tutorials/redshift_plot/redshift_plot.ipynb rename to docs/tutorials/redshift_plot/redshift_plot.ipynb diff --git a/tutorials/redshift_plot/requirements.txt b/docs/tutorials/redshift_plot/requirements.txt similarity index 100% rename from tutorials/redshift_plot/requirements.txt rename to docs/tutorials/redshift_plot/requirements.txt diff --git a/tutorials/vo/README.rst b/docs/tutorials/vo/README.rst similarity index 100% rename from tutorials/vo/README.rst rename to docs/tutorials/vo/README.rst diff --git a/tutorials/vo/conesearch_tutorial.ipynb b/docs/tutorials/vo/conesearch_tutorial.ipynb similarity index 100% rename from tutorials/vo/conesearch_tutorial.ipynb rename to docs/tutorials/vo/conesearch_tutorial.ipynb From 8e7c1195109baddfa8c7f1e2f49dc5ae810623cc Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:40:47 -0400 Subject: [PATCH 003/113] add sphinx template files --- docs/Makefile | 133 ++++++++++++++++++++++++++++++++++++++ docs/conf.py | 150 +++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 0 docs/make.bat | 170 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 453 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 000000000..fb03f26e6 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,133 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest + +#This is needed with git because git doesn't create a dir if it's empty +$(shell [ -d "_static" ] || mkdir -p _static) + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + +clean: + -rm -rf $(BUILDDIR) + -rm -rf api + -rm -rf generated + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Astropy.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Astropy.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/Astropy" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Astropy" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + make -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + @echo "Run 'python setup.py test' in the root directory to run doctests " \ + @echo "in the documentation." diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000..a4a400ba5 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +# Astropy documentation build configuration file. + +import datetime +import os +import sys + +try: + import astropy_helpers +except ImportError: + # Building from inside the docs/ directory? + if os.path.basename(os.getcwd()) == 'docs': + a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) + if os.path.isdir(a_h_path): + sys.path.insert(1, a_h_path) + +# Load all of the global Astropy configuration +from astropy_helpers.sphinx.conf import * + +# Get configuration information from setup.cfg +try: + from ConfigParser import ConfigParser +except ImportError: + from configparser import ConfigParser +conf = ConfigParser() + +conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) +setup_cfg = dict(conf.items('metadata')) + +# -- General configuration ---------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.2' + +# To perform a Sphinx version check that needs to be more specific than +# major.minor, call `check_sphinx_version("x.y.z")` here. +# check_sphinx_version("1.2.1") + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# exclude_patterns.append('path') + +# This is added to the end of RST files - a good place to put substitutions to +# be used globally. +rst_epilog += """ +""" + +# -- Project information ------------------------------------------------------ + +# This does not *have* to match the package name, but typically does +project = setup_cfg['package_name'] +author = setup_cfg['author'] +copyright = '2013–{0}, {1}'.format( + datetime.datetime.now().year, setup_cfg['author']) + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. + +__import__(setup_cfg['package_name']) +package = sys.modules[setup_cfg['package_name']] + +# The short X.Y version. +version = package.__version__.split('-', 1)[0] +# The full version, including alpha/beta/rc tags. +release = package.__version__ + + +# -- Options for HTML output -------------------------------------------------- + +# A NOTE ON HTML THEMES +# The global astropy configuration uses a custom theme, 'bootstrap-astropy', +# which is installed along with astropy. A different theme can be used or +# the options for this theme can be modified by overriding some of the +# variables set in the global configuration. The variables set in the +# global configuration are listed below, commented out. + + +# Please update these texts to match the name of your package. +html_theme_options = { + 'logotext1': 'astro', # white, semi-bold + 'logotext2': 'py', # orange, light + 'logotext3': ':tutorials' # white, light + } + +# Add any paths that contain custom themes here, relative to this directory. +# To use a different custom theme, add the directory containing the theme. +#html_theme_path = [] + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. To override the custom theme, set this to the +# name of a builtin theme or the name of a custom theme in html_theme_path. +#html_theme = None + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = '' + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '' + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +html_title = '{0} v{1}'.format(project, release) + +# Output file base name for HTML help builder. +htmlhelp_basename = project + 'doc' + + +# -- Options for LaTeX output ------------------------------------------------- + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [('index', project + '.tex', project + u' Documentation', + author, 'manual')] + + +# -- Options for manual page output ------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [('index', project.lower(), project + u' Documentation', + [author], 1)] + + +# -- Options for the edit_on_github extension --------------------------------- + +if eval(setup_cfg.get('edit_on_github')): + extensions += ['astropy_helpers.sphinx.ext.edit_on_github'] + + versionmod = __import__(setup_cfg['package_name'] + '.version') + edit_on_github_project = setup_cfg['github_project'] + if versionmod.version.release: + edit_on_github_branch = "v" + versionmod.version.version + else: + edit_on_github_branch = "master" + + edit_on_github_source_root = "" + edit_on_github_doc_root = "docs" + +# -- Resolving issue number to links in changelog ----------------------------- +github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) + diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..e69de29bb diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 000000000..93dfe92b9 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,170 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Astropy.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Astropy.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end From 156f4593c15ff49cdbcc8f64d6d1aec3f4756007 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:40:57 -0400 Subject: [PATCH 004/113] copy in setup files --- setup.cfg | 51 ++++++++++++++++++++ setup.py | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 setup.cfg create mode 100755 setup.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..5696202cc --- /dev/null +++ b/setup.cfg @@ -0,0 +1,51 @@ +[build_sphinx] +source-dir = docs +build-dir = docs/_build +all_files = 1 + +[build_docs] +source-dir = docs +build-dir = docs/_build +all_files = 1 + +[upload_docs] +upload-dir = docs/_build/html +show-response = 1 + +[pytest] +minversion = 2.2 +norecursedirs = build docs/_build +doctest_plus = enabled + +[ah_bootstrap] +auto_use = True + +[pep8] +# E101 - mix of tabs and spaces +# W191 - use of tabs +# W291 - trailing whitespace +# W292 - no newline at end of file +# W293 - trailing whitespace +# W391 - blank line at end of file +# E111 - 4 spaces per indentation level +# E112 - 4 spaces per indentation level +# E113 - 4 spaces per indentation level +# E901 - SyntaxError or IndentationError +# E902 - IOError +select = E101,W191,W291,W292,W293,W391,E111,E112,E113,E901,E902 +exclude = extern,sphinx,*parsetab.py + +[metadata] +package_name = astropy-tutorials +description = Tutorials for the Astropy Project +author = The Astropy Developers +author_email = astropy.team@gmail.com +license = BSD +url = http://tutorials.astropy.org/ +edit_on_github = False +github_project = astropy/astropy-tutorials +install_requires = astropy +# version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) +version = 3.0.dev + +[entry_points] diff --git a/setup.py b/setup.py new file mode 100755 index 000000000..3691b3471 --- /dev/null +++ b/setup.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +import glob +import os +import sys + +import ah_bootstrap +from setuptools import setup + +#A dirty hack to get around some early import/configurations ambiguities +if sys.version_info[0] >= 3: + import builtins +else: + import __builtin__ as builtins +builtins._ASTROPY_SETUP_ = True + +from astropy_helpers.setup_helpers import (register_commands, get_debug_option, + get_package_info) +from astropy_helpers.git_helpers import get_git_devstr +from astropy_helpers.version_helpers import generate_version_py + +# Get some values from the setup.cfg +try: + from ConfigParser import ConfigParser +except ImportError: + from configparser import ConfigParser + +conf = ConfigParser() +conf.read(['setup.cfg']) +metadata = dict(conf.items('metadata')) + +PACKAGENAME = metadata.get('package_name', 'packagename') +DESCRIPTION = metadata.get('description', 'Astropy affiliated package') +AUTHOR = metadata.get('author', '') +AUTHOR_EMAIL = metadata.get('author_email', '') +LICENSE = metadata.get('license', 'unknown') +URL = metadata.get('url', 'http://astropy.org') + +# order of priority for long_description: +# (1) set in setup.cfg, +# (2) load LONG_DESCRIPTION.rst, +# (3) load README.rst, +# (4) package docstring +readme_glob = 'README*' +_cfg_long_description = metadata.get('long_description', '') +if _cfg_long_description: + LONG_DESCRIPTION = _cfg_long_description + +elif os.path.exists('LONG_DESCRIPTION.rst'): + with open('LONG_DESCRIPTION.rst') as f: + LONG_DESCRIPTION = f.read() + +elif len(glob.glob(readme_glob)) > 0: + with open(glob.glob(readme_glob)[0]) as f: + LONG_DESCRIPTION = f.read() + +else: + # Get the long description from the package's docstring + __import__(PACKAGENAME) + package = sys.modules[PACKAGENAME] + LONG_DESCRIPTION = package.__doc__ + +# Store the package name in a built-in variable so it's easy +# to get from other parts of the setup infrastructure +builtins._ASTROPY_PACKAGE_NAME_ = PACKAGENAME + +# VERSION should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) +VERSION = metadata.get('version', '0.0.dev') + +# Indicates if this version is a release version +RELEASE = 'dev' not in VERSION + +if not RELEASE: + VERSION += get_git_devstr(False) + +# Populate the dict of setup command overrides; this should be done before +# invoking any other functionality from distutils since it can potentially +# modify distutils' behavior. +cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE) + +# Freeze build information in version.py +generate_version_py(PACKAGENAME, VERSION, RELEASE, + get_debug_option(PACKAGENAME)) + +# Treat everything in scripts except README* as a script to be installed +scripts = [fname for fname in glob.glob(os.path.join('scripts', '*')) + if not os.path.basename(fname).startswith('README')] + + +# Get configuration information from all of the various subpackages. +# See the docstring for setup_helpers.update_package_files for more +# details. +package_info = get_package_info() + +# Add the project-global data +package_info['package_data'].setdefault(PACKAGENAME, []) +package_info['package_data'][PACKAGENAME].append('data/*') + +# Define entry points for command-line scripts +entry_points = {'console_scripts': []} + +entry_point_list = conf.items('entry_points') +for entry_point in entry_point_list: + entry_points['console_scripts'].append('{0} = {1}'.format(entry_point[0], + entry_point[1])) + +# Include all .c files, recursively, including those generated by +# Cython, since we can not do this in MANIFEST.in with a "dynamic" +# directory name. +c_files = [] +for root, dirs, files in os.walk(PACKAGENAME): + for filename in files: + if filename.endswith('.c'): + c_files.append( + os.path.join( + os.path.relpath(root, PACKAGENAME), filename)) +package_info['package_data'][PACKAGENAME].extend(c_files) + +# Note that requires and provides should not be included in the call to +# ``setup``, since these are now deprecated. See this link for more details: +# https://groups.google.com/forum/#!topic/astropy-dev/urYO8ckB2uM + +setup(name=PACKAGENAME, + version=VERSION, + description=DESCRIPTION, + scripts=scripts, + install_requires=metadata.get('install_requires', 'astropy').strip().split(), + author=AUTHOR, + author_email=AUTHOR_EMAIL, + license=LICENSE, + url=URL, + long_description=LONG_DESCRIPTION, + cmdclass=cmdclassd, + zip_safe=False, + use_2to3=False, + entry_points=entry_points, + **package_info +) From 0d5566bf03a6cbe4968f5dbd0160b9391108c290 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:55:33 -0400 Subject: [PATCH 005/113] move readme to RST --- README.md | 29 ----------------------------- README.rst | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 29 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index 99593be3a..000000000 --- a/README.md +++ /dev/null @@ -1,29 +0,0 @@ -Tutorials -========= - -This repository contains tutorials for the [Astropy](http://astropy.org) -project (also on [github](https://github.com/astropy/astropy)). - -Running Tutorials ------------------ -The easiest way to get started quickly is to use binder to run the tutorials in your web browser - when this loads, click the "tutorials" folder and you should see all the tutorials: -[![Binder](http://mybinder.org/badge.svg)](http://mybinder.org/repo/astropy/astropy-tutorials) - -To run the tutorials *locally*, you need jupyter notebook installed: - - jupyter notebook - -The tutorials are initially empty of any output. You can run them by pressing -"Run All" under the "Cell" menu in the notebook file. - -Dependencies ------------- - -To deploy the notebooks, you will need: - -* IPython -* Astropy -* runipy -* pandoc - -_Note, all except pandoc can be pip installed. To install pandoc, follow the instructions here: http://johnmacfarlane.net/pandoc/installing.html_. diff --git a/README.rst b/README.rst new file mode 100644 index 000000000..8bcd39e31 --- /dev/null +++ b/README.rst @@ -0,0 +1,24 @@ +# Astropy Tutorials + +This repository contains tutorials for the [Astropy](http://astropy.org) +project (also on [github](https://github.com/astropy/astropy)). + +## Running Tutorials + +.. image:: http://mybinder.org/badge.svg + :target: http://mybinder.org/repo/astropy/astropy-tutorials/docs/tutorials + +The easiest way to get started quickly is to use binder to run the tutorials in +your web browser - when this loads, click on a folder + +To run the tutorials *locally*, you need jupyter notebook installed:: + + jupyter notebook + +The tutorials are initially empty of any output. You can run them by pressing +"Run All" under the "Cell" menu in the notebook file. + +## Dependencies + +See the conda environment file or pip requirements file for a list of +dependencies. From cd5cca722e4c26b30601b99ca0d50667b2c75331 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:31:13 -0400 Subject: [PATCH 006/113] remove grabbing version from package --- docs/conf.py | 31 ++++++++++--------------------- setup.py | 29 +++-------------------------- 2 files changed, 13 insertions(+), 47 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a4a400ba5..bc196ce3b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -40,7 +40,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -# exclude_patterns.append('path') +exclude_patterns.append('**.ipynb_checkpoints') # This is added to the end of RST files - a good place to put substitutions to # be used globally. @@ -59,13 +59,11 @@ # |version| and |release|, also used in various other places throughout the # built documents. -__import__(setup_cfg['package_name']) -package = sys.modules[setup_cfg['package_name']] - # The short X.Y version. -version = package.__version__.split('-', 1)[0] +version = setup_cfg['version'].split('-', 1)[0] # The full version, including alpha/beta/rc tags. -release = package.__version__ +# release = package.__version__ +release = version # -- Options for HTML output -------------------------------------------------- @@ -130,21 +128,12 @@ [author], 1)] -# -- Options for the edit_on_github extension --------------------------------- - -if eval(setup_cfg.get('edit_on_github')): - extensions += ['astropy_helpers.sphinx.ext.edit_on_github'] - - versionmod = __import__(setup_cfg['package_name'] + '.version') - edit_on_github_project = setup_cfg['github_project'] - if versionmod.version.release: - edit_on_github_branch = "v" + versionmod.version.version - else: - edit_on_github_branch = "master" - - edit_on_github_source_root = "" - edit_on_github_doc_root = "docs" - # -- Resolving issue number to links in changelog ----------------------------- github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) +# We require nbsphinx +extensions += ['nbsphinx'] +extensions += ['IPython.sphinxext.ipython_console_highlighting'] + +# TODO: remove this when errors in tutorials are updated to be static text +nbsphinx_allow_errors = True diff --git a/setup.py b/setup.py index 3691b3471..c5a0405e7 100755 --- a/setup.py +++ b/setup.py @@ -37,29 +37,10 @@ LICENSE = metadata.get('license', 'unknown') URL = metadata.get('url', 'http://astropy.org') -# order of priority for long_description: -# (1) set in setup.cfg, -# (2) load LONG_DESCRIPTION.rst, -# (3) load README.rst, -# (4) package docstring -readme_glob = 'README*' -_cfg_long_description = metadata.get('long_description', '') -if _cfg_long_description: - LONG_DESCRIPTION = _cfg_long_description - -elif os.path.exists('LONG_DESCRIPTION.rst'): - with open('LONG_DESCRIPTION.rst') as f: - LONG_DESCRIPTION = f.read() - -elif len(glob.glob(readme_glob)) > 0: - with open(glob.glob(readme_glob)[0]) as f: - LONG_DESCRIPTION = f.read() -else: - # Get the long description from the package's docstring - __import__(PACKAGENAME) - package = sys.modules[PACKAGENAME] - LONG_DESCRIPTION = package.__doc__ +readme_glob = 'README.rst' +with open('README.rst') as f: + LONG_DESCRIPTION = f.read() # Store the package name in a built-in variable so it's easy # to get from other parts of the setup infrastructure @@ -79,10 +60,6 @@ # modify distutils' behavior. cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE) -# Freeze build information in version.py -generate_version_py(PACKAGENAME, VERSION, RELEASE, - get_debug_option(PACKAGENAME)) - # Treat everything in scripts except README* as a script to be installed scripts = [fname for fname in glob.glob(os.path.join('scripts', '*')) if not os.path.basename(fname).startswith('README')] From 0411dc7e6b6061d9ea0cd2709c784e1510e2b3d6 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:32:32 -0400 Subject: [PATCH 007/113] remove old html dir --- html/css/docs.css | 844 -------------------------------- html/css/style.css | 304 ------------ html/images/astropy_word_32.png | Bin 4692 -> 0 bytes 3 files changed, 1148 deletions(-) delete mode 100644 html/css/docs.css delete mode 100644 html/css/style.css delete mode 100644 html/images/astropy_word_32.png diff --git a/html/css/docs.css b/html/css/docs.css deleted file mode 100644 index 78993c444..000000000 --- a/html/css/docs.css +++ /dev/null @@ -1,844 +0,0 @@ -/* Add additional stylesheets below --------------------------------------------------- */ -/* - Bootstrap's documentation styles - Special styles for presenting Bootstrap's documentation and examples - - Note: if you want to make specific modifications for the tutorials' notebooks, - it's probably better to go into the style.css (look for the #notebook selectors). - That way we can mostly keep them in one place. -*/ - - -/* Body and structure --------------------------------------------------- */ -body { - position: relative; - background-color: #fff; - background-repeat: repeat-x; - background-position: 0 40px; - padding-top: 40px; -} - - -/* Tweak navbar brand link to be super sleek --------------------------------------------------- */ -.navbar-fixed-top .brand { - padding-right: 0; - padding-left: 0; - margin-left: 20px; - float: right; - font-weight: bold; - color: #000; - text-shadow: 0 1px 0 rgba(255,255,255,.1), 0 0 30px rgba(255,255,255,.125); - -webkit-transition: all .2s linear; - -moz-transition: all .2s linear; - transition: all .2s linear; -} -.navbar-fixed-top .brand:hover { - text-decoration: none; -} - - -/* Space out sub-sections more --------------------------------------------------- */ -section { - padding-top: 60px; -} - -/* Faded out hr */ -hr.soften { - height: 1px; - margin: 54px 0; - background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.1), rgba(0,0,0,0)); - background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.1), rgba(0,0,0,0)); - background-image: -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.1), rgba(0,0,0,0)); - background-image: -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.1), rgba(0,0,0,0)); - border: 0; -} - - -/* Jumbotrons --------------------------------------------------- */ -.jumbotron { - position: relative; -} -.jumbotron h1 { - margin-bottom: 9px; - font-size: 81px; - font-weight: bold; - letter-spacing: -1px; - line-height: 1; -} -.jumbotron p { - margin-bottom: 18px; - font-weight: 300; -} -.jumbotron .btn-large { - font-size: 20px; - font-weight: normal; - padding: 14px 24px; - margin-right: 10px; - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; -} -.jumbotron .btn-large small { - font-size: 14px; -} - -/* Masthead (docs home) */ -.masthead { - margin-bottom: 72px; -} -.masthead h1, -.masthead p { - text-align: center; -} -.masthead h1 { - margin-bottom: 18px; -} -.masthead p { - margin-left: 5%; - margin-right: 5%; - font-size: 30px; - line-height: 36px; -} - - -/* Specific jumbotrons -------------------------- */ -/* supporting docs pages */ -.subhead { - padding-bottom: 0; - margin-bottom: 9px; -} -.subhead h1 { - font-size: 54px; -} - -/* Subnav */ -.subnav { - width: 100%; - height: 36px; - background-color: #eeeeee; /* Old browsers */ - background-repeat: repeat-x; /* Repeat the gradient */ - background-image: -moz-linear-gradient(top, #f5f5f5 0%, #eeeeee 100%); /* FF3.6+ */ - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#eeeeee)); /* Chrome,Safari4+ */ - background-image: -webkit-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* Chrome 10+,Safari 5.1+ */ - background-image: -ms-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* IE10+ */ - background-image: -o-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* Opera 11.10+ */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#eeeeee',GradientType=0 ); /* IE6-9 */ - background-image: linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* W3C */ - border: 1px solid #e5e5e5; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -.subnav .nav { - margin-bottom: 0; -} -.subnav .nav > li > a { - margin: 0; - padding-top: 11px; - padding-bottom: 11px; - border-left: 1px solid #f5f5f5; - border-right: 1px solid #e5e5e5; - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; -} -.subnav .nav > .active > a, -.subnav .nav > .active > a:hover { - padding-left: 13px; - color: #777; - background-color: #e9e9e9; - border-right-color: #ddd; - border-left: 0; - -webkit-box-shadow: inset 0 3px 5px rgba(0,0,0,.05); - -moz-box-shadow: inset 0 3px 5px rgba(0,0,0,.05); - box-shadow: inset 0 3px 5px rgba(0,0,0,.05); -} -.subnav .nav > .active > a .caret, -.subnav .nav > .active > a:hover .caret { - border-top-color: #777; -} -.subnav .nav > li:first-child > a, -.subnav .nav > li:first-child > a:hover { - border-left: 0; - padding-left: 12px; - -webkit-border-radius: 4px 0 0 4px; - -moz-border-radius: 4px 0 0 4px; - border-radius: 4px 0 0 4px; -} -.subnav .nav > li:last-child > a { - border-right: 0; -} -.subnav .dropdown-menu { - -webkit-border-radius: 0 0 4px 4px; - -moz-border-radius: 0 0 4px 4px; - border-radius: 0 0 4px 4px; -} - -/* Fixed subnav on scroll, but only for 980px and up (sorry IE!) */ -@media (min-width: 980px) { - .subnav-fixed { - position: fixed; - top: 40px; - left: 0; - right: 0; - z-index: 1020; /* 10 less than .navbar-fixed to prevent any overlap */ - border-color: #d5d5d5; - border-width: 0 0 1px; /* drop the border on the fixed edges */ - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; - -webkit-box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1); - -moz-box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1); - box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); /* IE6-9 */ - } - .subnav-fixed .nav { - width: 938px; - margin: 0 auto; - padding: 0 1px; - } - .subnav .nav > li:first-child > a, - .subnav .nav > li:first-child > a:hover { - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; - } -} - - -/* Quick links --------------------------------------------------- */ -.bs-links { - margin: 36px 0; -} -.quick-links { - min-height: 30px; - margin: 0; - padding: 5px 20px; - list-style: none; - text-align: center; - overflow: hidden; -} -.quick-links:first-child { - min-height: 0; -} -.quick-links li { - display: inline; - margin: 0 8px; - color: #999; -} -.quick-links .github-btn, -.quick-links .tweet-btn, -.quick-links .follow-btn { - position: relative; - top: 5px; -} - - -/* Marketing section of Overview --------------------------------------------------- */ -.marketing .row { - margin-bottom: 9px; -} -.marketing h1 { - margin: 36px 0 27px; - font-size: 40px; - font-weight: 300; - text-align: center; -} -.marketing h2, -.marketing h3 { - font-weight: 300; -} -.marketing h2 { - font-size: 22px; -} -.marketing p { - margin-right: 10px; -} -.marketing .bs-icon { - float: left; - margin: 7px 10px 0 0; - opacity: .8; -} -.marketing .small-bs-icon { - float: left; - margin: 4px 5px 0 0; -} - - - -/* Footer --------------------------------------------------- */ -.footer { - margin-top: 45px; - padding: 35px 0 36px; - border-top: 1px solid #e5e5e5; -} -.footer p { - margin-bottom: 0; - color: #555; -} - - - -/* Special grid styles --------------------------------------------------- */ -.show-grid { - margin-top: 10px; - margin-bottom: 20px; -} -.show-grid [class*="span"] { - background-color: #eee; - text-align: center; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - min-height: 30px; - line-height: 30px; -} -.show-grid:hover [class*="span"] { - background: #ddd; -} -.show-grid .show-grid { - margin-top: 0; - margin-bottom: 0; -} -.show-grid .show-grid [class*="span"] { - background-color: #ccc; -} - - -/* Render mini layout previews --------------------------------------------------- */ -.mini-layout { - border: 1px solid #ddd; - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; - -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.075); - -moz-box-shadow: 0 1px 2px rgba(0,0,0,.075); - box-shadow: 0 1px 2px rgba(0,0,0,.075); -} -.mini-layout { - height: 240px; - margin-bottom: 20px; - padding: 9px; -} -.mini-layout div { - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; -} -.mini-layout .mini-layout-body { - background-color: #dceaf4; - margin: 0 auto; - width: 70%; - height: 240px; -} -.mini-layout.fluid .mini-layout-sidebar, -.mini-layout.fluid .mini-layout-header, -.mini-layout.fluid .mini-layout-body { - float: left; -} -.mini-layout.fluid .mini-layout-sidebar { - background-color: #bbd8e9; - width: 20%; - height: 240px; -} -.mini-layout.fluid .mini-layout-body { - width: 77.5%; - margin-left: 2.5%; -} - - -/* Popover docs --------------------------------------------------- */ -.popover-well { - min-height: 160px; -} -.popover-well .popover { - display: block; -} -.popover-well .popover-wrapper { - width: 50%; - height: 160px; - float: left; - margin-left: 55px; - position: relative; -} -.popover-well .popover-menu-wrapper { - height: 80px; -} -.large-bird { - margin: 5px 0 0 310px; - opacity: .1; -} - - -/* Download page --------------------------------------------------- */ -.download .page-header { - margin-top: 36px; -} -.page-header .toggle-all { - margin-top: 5px; -} - -/* Space out h3s when following a section */ -.download h3 { - margin-bottom: 5px; -} -.download-builder input + h3, -.download-builder .checkbox + h3 { - margin-top: 9px; -} - -/* Fields for variables */ -.download-builder input[type=text] { - margin-bottom: 9px; - font-family: Menlo, Monaco, "Courier New", monospace; - font-size: 12px; - color: #d14; -} -.download-builder input[type=text]:focus { - background-color: #fff; -} - -/* Custom, larger checkbox labels */ -.download .checkbox { - padding: 6px 10px 6px 25px; - color: #555; - background-color: #f9f9f9; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - cursor: pointer; -} -.download .checkbox:hover { - color: #333; - background-color: #f5f5f5; -} -.download .checkbox small { - font-size: 12px; - color: #777; -} - -/* Variables section */ -#variables label { - margin-bottom: 0; -} - -/* Giant download button */ -.download-btn { - margin: 36px 0 108px; -} -#download p, -#download h4 { - max-width: 50%; - margin: 0 auto; - color: #999; - text-align: center; -} -#download h4 { - margin-bottom: 0; -} -#download p { - margin-bottom: 18px; -} -.download-btn .btn { - display: block; - width: auto; - padding: 19px 24px; - margin-bottom: 27px; - font-size: 30px; - line-height: 1; - text-align: center; - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; -} - - - -/* Color swatches on LESS docs page --------------------------------------------------- */ -/* Sets the width of the td */ -.swatch-col { - width: 30px; -} -/* Le swatch */ -.swatch { - display: inline-block; - width: 30px; - height: 20px; - margin: -6px 0; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; -} -/* For white swatches, give a border */ -.swatch-bordered { - width: 28px; - height: 18px; - border: 1px solid #eee; -} - - -/* Misc --------------------------------------------------- */ - -/* Make tables spaced out a bit more */ -h2 + table, -h3 + table, -h4 + table, -h2 + .row { - margin-top: 5px; -} - -/* Example sites showcase */ -.example-sites img { - max-width: 100%; - margin: 0 auto; -} -.marketing-byline { - font-size: 18px; - font-weight: 300; - line-height: 24px; - color: #999; - text-align: center; -} - -.scrollspy-example { - height: 200px; - overflow: auto; - position: relative; -} - -/* Remove bottom margin on example forms in wells */ -form.well { - padding: 14px; -} - -/* Tighten up spacing */ -.well hr { - margin: 18px 0; -} - -/* Fake the :focus state to demo it */ -.focused { - border-color: rgba(82,168,236,.8); - -webkit-box-shadow: inset 0 1px 3px rgba(0,0,0,.1), 0 0 8px rgba(82,168,236,.6); - -moz-box-shadow: inset 0 1px 3px rgba(0,0,0,.1), 0 0 8px rgba(82,168,236,.6); - box-shadow: inset 0 1px 3px rgba(0,0,0,.1), 0 0 8px rgba(82,168,236,.6); - outline: 0; -} - -/* For input sizes, make them display block */ -.docs-input-sizes select, -.docs-input-sizes input[type=text] { - display: block; - margin-bottom: 9px; -} - -/* Icons -------------------------- */ -.the-icons { - margin-left: 0; - list-style: none; -} -.the-icons i:hover { - background-color: rgba(255,0,0,.25); -} - -/* Eaxmples page -------------------------- */ -.bootstrap-examples .thumbnail { - margin-bottom: 9px; - background-color: #fff; -} - -/* Responsive table -------------------------- */ -.responsive-utilities th small { - display: block; - font-weight: normal; - color: #999; -} -.responsive-utilities tbody th { - font-weight: normal; -} -.responsive-utilities td { - text-align: center; -} -.responsive-utilities td.is-visible { - color: #468847; - background-color: #dff0d8 !important; -} -.responsive-utilities td.is-hidden { - color: #ccc; - background-color: #f9f9f9 !important; -} - -/* Responsive tests -------------------------- */ -.responsive-utilities-test { - margin-top: 5px; - margin-left: 0; - list-style: none; - overflow: hidden; /* clear floats */ -} -.responsive-utilities-test li { - position: relative; - float: left; - width: 25%; - height: 43px; - font-size: 14px; - font-weight: bold; - line-height: 43px; - color: #999; - text-align: center; - border: 1px solid #ddd; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -.responsive-utilities-test li + li { - margin-left: 10px; -} -.responsive-utilities-test span { - position: absolute; - top: -1px; - left: -1px; - right: -1px; - bottom: -1px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -.responsive-utilities-test span { - color: #468847; - background-color: #dff0d8; - border: 1px solid #d6e9c6; -} - - -/* Responsive Docs --------------------------------------------------- */ -@media (max-width: 480px) { - - /* Change up some type stuff */ - h2 { - margin-top: 27px; - } - h2 small { - display: block; - line-height: 18px; - } - h3 { - margin-top: 18px; - } - - /* icons */ - .marketing .bs-icon { - margin: 0; - } - - /* Adjust the jumbotron */ - .jumbotron h1, - .jumbotron p { - text-align: center; - margin-right: 0; - } - .jumbotron h1 { - font-size: 45px; - margin-right: 0; - } - .jumbotron p { - margin-right: 0; - margin-left: 0; - font-size: 18px; - line-height: 24px; - } - .jumbotron .btn { - display: block; - font-size: 18px; - padding: 10px 14px; - margin: 0 auto 10px; - } - /* Masthead (home page jumbotron) */ - .masthead { - padding-top: 0; - } - - /* Don't space out quick links so much */ - .quick-links { - margin: 40px 0 0; - } - /* hide the bullets on mobile since our horizontal space is limited */ - .quick-links .divider { - display: none; - } - - /* center example sites */ - .example-sites { - margin-left: 0; - } - .example-sites > li { - float: none; - display: block; - max-width: 280px; - margin: 0 auto 18px; - text-align: center; - } - .example-sites .thumbnail > img { - max-width: 270px; - } - - table code { - white-space: normal; - word-wrap: break-word; - word-break: break-all; - } - - /* Modal example */ - .modal-example .modal { - position: relative; - top: auto; - right: auto; - bottom: auto; - left: auto; - } - -} - - -@media (max-width: 768px) { - - /* This was in the version copied from the main site, but it mucks up the ipython notebooks */ - /* Remove any padding from the body */ - /*body { - padding-top: 0; - }*/ - - /* Jumbotron buttons */ - .jumbotron .btn { - margin-bottom: 10px; - } - - /* Subnav */ - .subnav { - position: static; - top: auto; - z-index: auto; - width: auto; - height: auto; - background: #fff; /* whole background property since we use a background-image for gradient */ - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - } - .subnav .nav > li { - float: none; - } - .subnav .nav > li > a { - border: 0; - } - .subnav .nav > li + li > a { - border-top: 1px solid #e5e5e5; - } - .subnav .nav > li:first-child > a, - .subnav .nav > li:first-child > a:hover { - -webkit-border-radius: 4px 4px 0 0; - -moz-border-radius: 4px 4px 0 0; - border-radius: 4px 4px 0 0; - } - - /* Popovers */ - .large-bird { - display: none; - } - .popover-well .popover-wrapper { - margin-left: 0; - } - - /* Space out the show-grid examples */ - .show-grid [class*="span"] { - margin-bottom: 5px; - } - - /* Unfloat the back to top link in footer */ - .footer .pull-right { - float: none; - } - .footer p { - margin-bottom: 9px; - } - -} - - -@media (min-width: 480px) and (max-width: 768px) { - - /* Scale down the jumbotron content */ - .jumbotron h1 { - font-size: 54px; - } - .jumbotron p { - margin-right: 0; - margin-left: 0; - } - -} - - -@media (min-width: 768px) and (max-width: 980px) { - - /* This was in the version copied from the main site, but it mucks up the ipython notebooks */ - /* Remove any padding from the body */ - /*body { - padding-top: 0; - }*/ - - /* Scale down the jumbotron content */ - .jumbotron h1 { - font-size: 72px; - } - -} - - -@media (max-width: 980px) { - - /* Unfloat brand */ - .navbar-fixed-top .brand { - float: left; - margin-left: 0; - padding-left: 10px; - padding-right: 10px; - } - - /* Inline-block quick links for more spacing */ - .quick-links li { - display: inline-block; - margin: 5px; - } - -} - - -/* LARGE DESKTOP SCREENS */ -@media (min-width: 1210px) { - - /* Update subnav container */ - .subnav-fixed .nav { - width: 1168px; /* 2px less to account for left/right borders being removed when in fixed mode */ - } - -} diff --git a/html/css/style.css b/html/css/style.css deleted file mode 100644 index 3e8374490..000000000 --- a/html/css/style.css +++ /dev/null @@ -1,304 +0,0 @@ -/* Ripped from the main astropy website with some modifications*/ -/* http://meyerweb.com/eric/tools/css/reset/ - v2.0 | 20110126 - License: none (public domain) -*/ - -/* HTML5 display-role reset for older browsers */ -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} -body { - line-height: 1; -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; -} - -body{ - line-height: 1.25em; - font-size: 16px; - color:#333; - font-family: 'Open Sans', sans-serif; -} - -#wrapper{ - margin:0 auto; - max-width:960px; - padding:0 10px; - min-width: 320px; /* min-width of whole site */ -} - -a{ - color: #FF5000; - text-decoration: none; -} -a, svg{ - -webkit-transition: all 0.3s ease; - -moz-transition: all 0.3s ease; - -o-transition: all 0.3s ease; - -ms-transition: all 0.3s ease; - transition: all 0.3s ease; -} - -a:hover{ - color:#333; -} - -h1{ - font-size: 28px; - font-weight: bold; - margin-top: 10px; - margin-bottom: 20px; -} - -h2{ - font-size: 24px; - margin-bottom: 10px; -} - -h3{ - font-size: 20px; - margin: 20px 0px 10px 0px; - -} - -p{ - margin-bottom: 10px; - margin-top: 10px; - line-height: 1.5em; -} - -strong{ - font-weight: bold; - -} - -section{ - border-bottom: 1px #efefef solid; - padding: 20px 0 20px; - clear: both; -} - -section:first-of-type{ - margin-top:42px; -} - -section:last-of-type{ - border-bottom: 0px; -} - -section *:last-child{ - margin-bottom: 0px; -} - -ul li{ - list-style-type: square; - list-style-position: outside; - list-style-color: #FF5000; - line-height: 1.5em; - margin-bottom:0.5em; - margin-left: 30px; -} - -ul li:last-child{ - margin-bottom: 0px; -} - -cite{ - font-family: monospace; -} - -pre{ - background-color: #f5f5f5; - border: 1px solid #ddd; - padding: 10px; - color: black; - font-family: Monaco, Andale Mono, Courier New, monospace; - webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - margin-bottom: 5px; -} - -.button{ - padding: 8px; - display: inline-block; - background-image: -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0, #FC9468), - color-stop(0.89, #FF5100) - ); - background-image: -o-linear-gradient(bottom, #FC9468 0%, #FF5100 89%); - background-image: -moz-linear-gradient(bottom, #FC9468 0%, #FF5100 89%); - background-image: -webkit-linear-gradient(bottom, #FC9468 0%, #FF5100 89%); - background-image: -ms-linear-gradient(bottom, #FC9468 0%, #FF5100 89%); - background-image: linear-gradient(to bottom, #FC9468 0%, #FF5100 89%); -} - -a.button, .button a{ - color: white; -} - - -p .button{ - padding-top:0px; - padding-bottom:0px; - padding-right:4px; - padding-left:4px; -} - -.button:hover{ - cursor: pointer; - background-image: -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0, #FFA47D), - color-stop(1, #FF7D45) - ); - background-image: -o-linear-gradient(bottom, #FFA47D 0%, #FF7D45 100%); - background-image: -moz-linear-gradient(bottom, #FFA47D 0%, #FF7D45 100%); - background-image: -webkit-linear-gradient(bottom, #FFA47D 0%, #FF7D45 100%); - background-image: -ms-linear-gradient(bottom, #FFA47D 0%, #FF7D45 100%); - background-image: linear-gradient(to bottom, #FFA47D 0%, #FF7D45 100%); -} - - -.right{ - float: right; -} - -/* nav */ -nav{ - line-height: 42px; - position:absolute; - left:0px; - top:0px; - width:100%; - background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #222222),color-stop(0.89, #333333)); - background-image: -o-linear-gradient(bottom, #222222 0%, #333333 89%); - background-image: -moz-linear-gradient(bottom, #222222 0%, #333333 89%); - background-image: -webkit-linear-gradient(bottom, #222222 0%, #333333 89%); - background-image: -ms-linear-gradient(bottom, #222222 0%, #333333 89%); - background-image: linear-gradient(to bottom, #222222 0%, #333333 89%); -} - -nav > *{ - display:inline-block; - vertical-align:top; -} - -nav img{ - float: left; - margin-left: 20px; - margin-top: 5px; -} - -nav ul{ - max-width:960px; - margin: 0; - padding: 0; -} - -nav ul li{ - display:inline; - list-style: none; - display: block; - margin: 0; -} - -nav li a, nav li a:link{ - color:#fff; - font-size: 22px; - font-weight: 300; -} -nav li a:hover{ - color:#FF5000; -} - -nav li a.active{ - color:#FF5000; -} - -nav .pull-right{ - float: right; - margin-right:10px; -} - - -/* - IPython overrides -*/ - -/* Tweaks to make a bit more responsive in conjuction with astropy scheme */ - -@media (max-width: 355px) { - - #wrapper { - padding-left: 0px; - padding-right: 0px; - } - - body { - padding-left: 0px; - padding-right: 0px; - } - - .text_cell_render { - padding-left: 0px; - padding-right: 0px; - } - -} - -.container { - max-width: 900px; - font-size: 12pt; -} - -.tutorials li { - padding-top: 10px; - padding-bottom: 10px; - margin-bottom: 0; -} - - -/* - Notebook styling -*/ - -#notebook p { - font-size: 16px; - line-height: 20px; -} - -#notebook code, pre{ - padding:0 3px 2px; - font-family: monospace; - word-wrap: break-word; -} - -#notebook pre { - font-size:14px; - line-height: 17px; -} - -#notebook sub { - line-height: 1; -} \ No newline at end of file diff --git a/html/images/astropy_word_32.png b/html/images/astropy_word_32.png deleted file mode 100644 index 7125b632b8724f48656e33f233bbccb8f21532e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4692 zcmV-a607ZrP)X+uL$Nkc;* zP;zf(X>4Tx07wm;mUmQB*%pV-y*Itk5+Wca^cs2zAksTX6$DXM^`x7XQc?|s+0 z08spb1j2M!0f022SQPH-!CVp(%f$Br7!UytSOLJ{W@ZFO_(THK{JlMynW#v{v-a*T zfMmPdEWc1DbJqWVks>!kBnAKqMb$PuekK>?0+ds;#ThdH1j_W4DKdsJG8Ul;qO2n0 z#IJ1jr{*iW$(WZWsE0n`c;fQ!l&-AnmjxZO1uWyz`0VP>&nP`#itsL#`S=Q!g`M=rU9)45( zJ;-|dRq-b5&z?byo>|{)?5r=n76A4nTALlSzLiw~v~31J<>9PP?;rs31pu_(obw)r zY+jPY;tVGXi|p)da{-@gE-UCa`=5eu%D;v=_nFJ?`&K)q7e9d`Nfk3?MdhZarb|T3 z%nS~f&t(1g5dY)AIcd$w!z`Siz!&j_=v7hZlnI21XuE|xfmo0(WD10T)!}~_HYW!e zew}L+XmwuzeT6wtxJd`dZ#@7*BLgIEKY9Xv>st^p3dp{^Xswa2bB{85{^$B13tWnB z;Y>jyQ|9&zk7RNsqAVGs--K+z0uqo1bf5|}fi5rtEMN^BfHQCd-XH*kfJhJnmIE$G z0%<@5vOzxB0181d*a3EfYH$G5fqKvcPJ%XY23!PJzzuK<41h;K3WmW;Fah3yX$XSw z5EY_9s*o0>51B&N5F1(uc|$=^I1~fLLy3?Ol0f;;Ca4%HgQ}rJP(Ab`bQ-z{U4#0d z2hboi2K@njgb|nm(_szR0JebHusa+GN5aeCM0gdP2N%HG;Yzp`J`T6S7vUT504#-H z!jlL<$Or?`Mpy_N@kBz9SR?@vA#0H$qyni$nvf2p8@Y{0k#Xb$28W?xm>3qu8RLgp zjNxKdVb)?wFx8l2m{v>|<~C*!GlBVnrDD~wrdTJeKXwT=5u1%I#8zOBU|X=4u>;s) z>^mF|$G{ol9B_WP7+f-LHLe7=57&&lfa}8z;U@8Tyei%l?}87(bMRt(A-)QK9Dg3) zj~~XrCy)tR1Z#p1A(kK{Y$Q|=8VKhI{e%(1G*N-5Pjn)N5P8I0VkxnX*g?EW941ba z6iJ387g8iCnY4jaNopcpCOsy-A(P2EWJhusSwLP-t|XrzUnLKcKTwn?CKOLf97RIe zPB}`sKzTrUL#0v;sBY9)s+hW+T2H-1eM)^VN0T#`^Oxhvt&^*fYnAJldnHel*Ozyf zUoM{~Um<@={-*r60#U(0!Bc^wuvVc);k3d%g-J!4qLpHZVwz%!VuRu}#Ze`^l7W)9 z5>Kf>>9Eozr6C$Z)1`URxU@~QI@)F0FdauXr2Es8>BaOP=)Lp_WhG@>R;lZ?BJkMlIuMhw8ApiF&yDYW2hFJ?fJhni{?u z85&g@mo&yT8JcdI$(rSw=QPK(Xj%)k1X|@<=e1rim6`6$RAwc!i#egKuI;BS(LSWz zt39n_sIypSqfWEV6J3%nTQ@-4i zi$R;gsG*9XzhRzXqv2yCs*$VFDx+GXJH|L;wsDH_KI2;^u!)^Xl1YupO;gy^-c(?^ z&$Q1BYvyPsG^;hc$D**@Sy`+`)}T4VJji^bd7Jqw3q6Zii=7tT7GEswEK@D(EFW1Z zSp`^awCb?>!`j4}Yh7b~$A)U-W3$et-R8BesV(1jzwLcHnq9En7Q0Tn&-M=XBKs!$ zF$X<|c!#|X_tWYh)GZit z(Q)Cp9CDE^WG;+fcyOWARoj*0TI>4EP1lX*cEoMO-Pk?Z{kZ!p4@(b`M~lalr<3Oz z&kJ6Nm#vN_+kA5{dW4@^Vjg_`q%qU1ULk& z3Fr!>1V#i_2R;ij2@(Z$1jE4r!MlPVFVbHmT+|iPIq0wy5aS{>yK?9ZAjVh%SOwMWgFjair&;wpi!{CU}&@N=Eg#~ zLQ&zpEzVmGY{hI9Z0+4-0xS$$Xe-OToc?Y*V;rTcf_ zb_jRe-RZjXSeas3UfIyD;9afd%<`i0x4T#DzE)vdabOQ=k7SRuGN`h>O0Q~1)u-yD z>VX=Mn&!Rgd$;YK+Q-}1zu#?t(*cbG#Ronf6db&N$oEidtwC+YVcg-Y!_VuY>bk#Y ze_ww@?MU&F&qswvrN_dLb=5o6*Egs)ls3YRlE$&)amR1{;Ppd$6RYV^Go!iq1UMl% z@#4q$AMc(FJlT1QeX8jv{h#)>&{~RGq1N2iiMFIRX?sk2-|2wUogK~{EkB$8eDsX= znVPf8XG_nK&J~=SIiGia@9y}|z3FhX{g&gcj=lwb=lWgyFW&aLedUh- zof`v-2Kw$UzI*>(+&$@i-u=-BsSjR1%z8NeX#HdC`Hh-Z(6xI-`hmHDqv!v)W&&nrf>M(RhcN6(D;jNN*%^u_SYjF;2ng}*8Ow)d6M ztDk;%`@Lsk$;9w$(d(H%O5UixIr`T2ZRcd@P-1tmx`7GgmmR-zIkHW0AHM5F&G#)4Ro zNG!A?B8ml3FG^4&K|m2jR1`(J6uG_Tff^NvYFPeeLmbCfbBUwCnkb4!{>_)$y@#jR9{|zv-K`RJ{(%Q> z^AB9}UvbGja_@o}SBC8v&<@043Cn!}ydaUYC(h$RTd*B0B4;r?Ma0#^;EP=cy>Sq* zm7GfH*c-vr;wrIib+&!sUBO217WUs|_e4%>M{x%4rHgYu1y{Ti?~HvwHaXDbI@1~!0dP>9a+;}fvX1`9Ea^NwI%-!qVEKL6)t1OuG0wk4u{PL13+C6Qgf8MzzpJQ6dZdiaGYso z-eV>|fV_gcdqkx!H+oHEiW@Cg`5VK%|_0xkh6oTt?YvU$w&j(}@5jRG6M zy+99gJ5Zrjz?Z<@(xExv6wnC_0UBS_6O6P{&7Z~;wj!zs6%S9YB8ca%UeF##>)sbA|K0kn5A~XSQJmehG3n9W8x7Llm!>7Sc+mG~r<$ z1uaA8E|MSNzUJo{ODn?D)5QGd6>)UUtR>FY6n>_Y(=19oU)ER0Omj*L^Qk!`>oCt* zIW`vtwu~5=-p)3;h7UthY&j`bQ*bGm2)@Cz9*mdIQDZMSJ{qnTBDxN&Aa4@T9OZDaEc_Q+J*eJT@DW>n}htka@r?FQ>ov&jt8e+{)k zPpLNJjfFVNHKM3$KU%xmv$hun90iu=1{cza z-3DF)+WB>o`P#*5btLC!WS$`*f4#)8qXO5_3tbq*9~;P_7}`G%9Yy87=1^iXtEaB{ zB8-n_m~YT$gAOqpY<#{wc4}t-!rAT3FgBEZvHixk9p~II0J(LJo~X=PorATc6QU3c zP##VU>3qK|NJAXa+2yV0y&}Ml9`ow&>`08WVAz%L~_5t=`;mxsy zvw2aFzXI78TuXm6@hw3Ipqu?Oq_(%zC3J#MXN=CEJ<#&jiNLR(u}lL0|AI?N*pOKN zst3gJtvhO_ea7a&z?Bu(vQcKv;uq3TGA|}Jld=IdC3`d6oNoN;!0ng2{9Bz}Gk6m> zZTlcOL(#`NpO{vKHYy$e{LO3m9ZpUa+!A>&APjVB$Sx=DIT?sq2W#e>r(%EK$tgzM zNf_P+_C=?hS!DrY7slA)O*&`u=buZjWQpDMBJ%@WrySKnlj(hPwCNU&N%kQ>gyp=H zhY)VEicTm~O&bd4YnO_Z;%D}q$e#sX6+KE#Xi6n`cvdSVWH7Q zw}PcsO8@8~{}eHH1qtev`Nq>j>#Tf6SZMTI8iqj!gZnAdMELbUg`RDyO#ecK#;+|> zlOt2yYEB_uw$7SADySu9iHg++90@cN=YiSWs6PB0gsk>ZjXocq5I!A?dVnK9Q=sC1 z2r7up`TM$G?9ykfh96M#0gAArV7ZEV;q zrDk@OJ>srr+Vx|49RfB}#JSOQ`>n{QzSX8R$&=A-S|>CH*cUbCdIBT=>O(R z72B8t`7W|-XP%LNYI-wOW{|s-HFR*XneE%i&RlD^&WW|D#`bHZ>TqANLMzDkSIH$R zQUTjGe&kDFed< From 798d09957c8bd19f049e8f404204badbd23d2e6c Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:32:47 -0400 Subject: [PATCH 008/113] ignore generated stuff --- .gitignore | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 42a77883b..7b7042a14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ .ipynb_checkpoints/ -html/ +docs/_build/ runipy-* IPython-* -tutorials/*/_run_* -tutorials/*/*.fits -tutorials/*/*.pdf -tutorials/*/*.png +*.fits +*.pdf +*.png +*.jpg *.pyc +*.tex \ No newline at end of file From e2e5a42ff52ac74600c47e80fe6c156c06de51f1 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:40:21 -0400 Subject: [PATCH 009/113] rename conesearch tutorial --- docs/tutorials/vo/{conesearch_tutorial.ipynb => conesearch.ipynb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/tutorials/vo/{conesearch_tutorial.ipynb => conesearch.ipynb} (100%) diff --git a/docs/tutorials/vo/conesearch_tutorial.ipynb b/docs/tutorials/vo/conesearch.ipynb similarity index 100% rename from docs/tutorials/vo/conesearch_tutorial.ipynb rename to docs/tutorials/vo/conesearch.ipynb From ee18d3b348ccf9a1ae49190a428e1786d9062e26 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:40:35 -0400 Subject: [PATCH 010/113] add all tutorials to index --- docs/index.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index e69de29bb..8fd1041c1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -0,0 +1,16 @@ +Astropy Tutorials +================= + +.. toctree:: + :maxdepth: 1 + :glob: + + tutorials/Coordinates/Coordinates.ipynb + tutorials/FITS-header/FITS-header.ipynb + tutorials/FITS-images/FITS-images.ipynb + tutorials/FITS-tables/FITS-tables.ipynb + tutorials/Plot-Catalog/plot-catalog.ipynb + tutorials/Quantities/Quantities.ipynb + tutorials/redshift_plot/redshift_plot.ipynb + tutorials/UVES/UVES.ipynb + tutorials/vo/conesearch.ipynb From 902ea00a3cb8347b2a7db27340bae53fe43fb439 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:24:45 -0400 Subject: [PATCH 011/113] change timeout for nbconvert --- docs/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index bc196ce3b..199d63b7c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -135,5 +135,7 @@ extensions += ['nbsphinx'] extensions += ['IPython.sphinxext.ipython_console_highlighting'] +nbsphinx_timeout = 600 # Time in seconds; use -1 for no timeout + # TODO: remove this when errors in tutorials are updated to be static text nbsphinx_allow_errors = True From 5f1c3a79ed85439237347b816ac2080da2aaaa77 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:25:14 -0400 Subject: [PATCH 012/113] fix section header level --- docs/tutorials/Quantities/Quantities.ipynb | 202 +++++++++++++++------ 1 file changed, 151 insertions(+), 51 deletions(-) diff --git a/docs/tutorials/Quantities/Quantities.ipynb b/docs/tutorials/Quantities/Quantities.ipynb index 9189221ab..447939d94 100644 --- a/docs/tutorials/Quantities/Quantities.ipynb +++ b/docs/tutorials/Quantities/Quantities.ipynb @@ -33,7 +33,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import numpy as np\n", @@ -62,7 +64,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import astropy.units as u\n", @@ -93,7 +97,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "Reff = 29 * u.pc" @@ -109,7 +115,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "Reff = u.Quantity(29, unit=u.pc)" @@ -125,7 +133,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"\"\"Half light radius\n", @@ -143,7 +153,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"\"\"Half light radius\n", @@ -161,7 +173,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"{0:.3g}\".format(Reff.to(u.m)))" @@ -177,7 +191,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "vmean = 206\n", @@ -188,7 +204,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"\"\"First 10 radial velocity measurements: \n", @@ -199,7 +217,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "plt.figure()\n", @@ -218,7 +238,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sigma = np.sqrt(np.sum((v - np.mean(v))**2) / np.size(v))\n", @@ -235,7 +257,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sigma_scalar = np.sqrt(np.sum((v - np.mean(v))**2) / len(v))" @@ -258,7 +282,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "M = 4*sigma**2*Reff/G\n", @@ -275,7 +301,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "M.decompose()" @@ -291,7 +319,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"\"\"Galaxy mass\n", @@ -310,7 +340,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "np.log10(M / u.Msun)" @@ -326,7 +358,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "np.log10(M)" @@ -351,7 +385,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -365,7 +401,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -379,7 +417,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -414,7 +454,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "d = 250 * u.pc\n", @@ -431,7 +473,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Cloud's center\n", @@ -467,7 +511,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "data = data_gauss * u.K" @@ -483,7 +529,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Average pixel size\n", @@ -508,7 +556,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "intcloud = np.sum(data*dv, axis=2)\n", @@ -525,7 +575,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "#Note that we display RA in the convential way by going from max to min\n", @@ -576,7 +628,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "lambda13 = 2.60076 * u.mm\n", @@ -593,7 +647,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "nu13 = lambda13.to(u.Hz)" @@ -611,7 +667,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "nu13 = lambda13.to(u.Hz, equivalencies=u.spectral())\n", @@ -628,7 +686,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "A13 = 7.4e-8 / u.s\n", @@ -648,7 +708,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "B = h * nu18 / (k_B * Tex)" @@ -664,7 +726,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print('{0}\\n{1}'.format(B, B.decompose()))" @@ -680,7 +744,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "NCO = C * np.sum(data*dv, axis=2) / (1 - np.exp(-B))\n", @@ -705,7 +771,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "H2_CO_ratio = 5.9e6\n", @@ -731,7 +799,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "mH2 = 2 * 1.008 * u.Dalton #aka atomic mass unit/amu\n", @@ -748,7 +818,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "dap = dra * ddec\n", @@ -765,7 +837,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "da = dap * d**2 # don't actually do it this way - use the version below instead!\n", @@ -775,7 +849,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "dap.to(u.steradian).value * d**2" @@ -791,7 +867,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "da.to(u.cm**2)" @@ -807,7 +885,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "da = (dap * d**2).to(u.pc**2, equivalencies=u.dimensionless_angles())\n", @@ -817,7 +897,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "da.to(u.cm**2)" @@ -833,7 +915,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "M = np.sum(rho * da)\n", @@ -857,7 +941,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -871,7 +957,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -879,7 +967,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 3. Using Quantities with Functions" + "## 3. Using Quantities with Functions" ] }, { @@ -899,7 +987,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def response_func(xinarcsec, yinarcsec):\n", @@ -921,7 +1011,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "response_func(1.0, 1.2)" @@ -937,7 +1029,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def response_func(x, y):\n", @@ -959,7 +1053,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "response_func(1.0, 1.2)" @@ -975,7 +1071,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "response_func(1.0*u.arcmin, 1.2*u.arcmin)" @@ -1005,7 +1103,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] } From a95ddaff386c489335296c417a926425bc414fb3 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:37:32 -0400 Subject: [PATCH 013/113] change search region and fix column names --- docs/tutorials/vo/conesearch.ipynb | 33 +++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/tutorials/vo/conesearch.ipynb b/docs/tutorials/vo/conesearch.ipynb index 6bee59fcd..e98126af2 100644 --- a/docs/tutorials/vo/conesearch.ipynb +++ b/docs/tutorials/vo/conesearch.ipynb @@ -159,7 +159,7 @@ "outputs": [], "source": [ "row = result_tab[0]\n", - "simbad_obj = coord.SkyCoord(ra=row['RA']*u.deg, dec=row['DEC']*u.deg)\n", + "simbad_obj = coord.SkyCoord(ra=row['RAJ2000']*u.deg, dec=row['DEJ2000']*u.deg)\n", "print('Searching SIMBAD for\\n{}\\n'.format(simbad_obj))\n", "simbad_result = Simbad.query_region(simbad_obj, radius=5*u.arcsec)\n", "print(simbad_result)" @@ -297,7 +297,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "with warnings.catch_warnings():\n", @@ -387,7 +389,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let's predict the run time of performing Cone Search on `http://gsss.stsci.edu/webservices/vo/ConeSearch.aspx?CAT=GSC23&` with a radius of 0.5 degrees. For now, the prediction assumes a very simple linear model, which might or might not reflect the actual trend.\n", + "Let's predict the run time of performing Cone Search on `http://gsss.stsci.edu/webservices/vo/ConeSearch.aspx?CAT=GSC23&` with a radius of 0.1 degrees. For now, the prediction assumes a very simple linear model, which might or might not reflect the actual trend.\n", "\n", "This might take a while." ] @@ -402,7 +404,7 @@ " warnings.simplefilter('ignore')\n", " t_est, n_est = conesearch.predict_search(\n", " 'http://gsss.stsci.edu/webservices/vo/ConeSearch.aspx?CAT=GSC23&',\n", - " c, 0.5 * u.degree, verbose=False, plot=True)" + " c, 0.1 * u.degree, verbose=False, plot=True)" ] }, { @@ -431,7 +433,7 @@ "outputs": [], "source": [ "t_real, tab = conesearch.conesearch_timer(\n", - " c, 0.5 * u.degree,\n", + " c, 0.1 * u.degree,\n", " catalog_db='http://gsss.stsci.edu/webservices/vo/ConeSearch.aspx?CAT=GSC23&',\n", " verbose=False)" ] @@ -445,6 +447,15 @@ "print('Actual run time is', t_real, 'seconds')\n", "print('Actual number of rows is', tab.nrows)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] } ], "metadata": { @@ -460,6 +471,18 @@ "display_name": "Python [default]", "language": "python", "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" } }, "nbformat": 4, From b344bca99ec6905f99125656a3f35527f992e155 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:49:59 -0400 Subject: [PATCH 014/113] change to md so sphinx doesn't collect --- docs/tutorials/vo/{README.rst => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/tutorials/vo/{README.rst => README.md} (100%) diff --git a/docs/tutorials/vo/README.rst b/docs/tutorials/vo/README.md similarity index 100% rename from docs/tutorials/vo/README.rst rename to docs/tutorials/vo/README.md From 086a556cd253c99c832587a4f3276dc56b67b399 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:54:53 -0400 Subject: [PATCH 015/113] try to resolve title level warnings --- docs/tutorials/UVES/UVES.ipynb | 150 ++++++++++++++++++++++++--------- 1 file changed, 112 insertions(+), 38 deletions(-) diff --git a/docs/tutorials/UVES/UVES.ipynb b/docs/tutorials/UVES/UVES.ipynb index 3a2cffbef..2dbd4bbfd 100644 --- a/docs/tutorials/UVES/UVES.ipynb +++ b/docs/tutorials/UVES/UVES.ipynb @@ -81,7 +81,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import tarfile\n", @@ -138,7 +140,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from glob import glob\n", @@ -171,7 +175,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sp = fits.open(filelist[0])\n", @@ -193,7 +199,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "header = sp[0].header\n", @@ -218,7 +226,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "flux = sp[0].data" @@ -282,7 +292,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def read_spec(filename):\n", @@ -335,7 +347,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "help(read_spec)\n", @@ -366,7 +380,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def read_setup(filename):\n", @@ -409,7 +425,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "flux = np.zeros((len(filelist), len(wavelength)))\n", @@ -426,7 +444,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Units and constants in astropy" + "## Units and constants in astropy" ] }, { @@ -449,7 +467,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import astropy.units as u\n", @@ -503,7 +523,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "v_accr = (2.* G * M_MN_Lup/R_MN_Lup)**0.5 \n", @@ -525,7 +547,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "v_rot = vsini / np.sin(incl)\n", @@ -543,7 +567,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "(v_accr / v_rot).decompose()" @@ -579,7 +605,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "wavelength = wavelength * (1. + heliocentric/c)" @@ -601,7 +629,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "wavelength = wavelength * (1. * u.dimensionless_unscaled+ heliocentric/c)" @@ -622,7 +652,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "wavelength.to(u.keV, equivalencies=u.spectral())\n", @@ -663,7 +695,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(np.log10((G*M_MN_Lup/R_MN_Lup**2)/u.cm*u.second**2))" @@ -692,7 +726,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "waveclosetoHa = np.array([6562.,6563,6565.]) * u.AA" @@ -708,7 +744,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# This function uses the Doppler equivalency between wavelength and velocity\n", @@ -745,7 +783,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def w2vsini(wavelength_array, wavelength_line):\n", @@ -756,7 +796,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def w2vsini(w, w0):\n", @@ -789,7 +831,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astropy.time import Time\n", @@ -807,7 +851,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "t1\n", @@ -825,7 +871,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "t1.tt" @@ -841,7 +889,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "obs_times = Time(date, scale = 'utc')\n", @@ -861,7 +911,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "delta_p = delta_t.value * u.day / period" @@ -900,7 +952,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def region_around_line(w, flux, cont):\n", @@ -960,7 +1014,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "ew = fcaII[0,:] - 1.\n", @@ -978,7 +1034,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "delta_lam = np.diff(wcaII.to(u.AA).value)\n", @@ -1000,7 +1058,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astropy.table import Column, Table\n", @@ -1048,7 +1108,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "x = w2vsini(wcaII, 393.366 * u.nm).decompose()" @@ -1064,7 +1126,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# set reasonable figsize for 1-column figures\n", @@ -1106,7 +1170,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "yshift = np.arange((fcaII.shape[0])) * 0.5\n", @@ -1141,7 +1207,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "fmean = np.mean(fcaII, axis=0)\n", @@ -1160,7 +1228,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "fig = plt.figure()\n", @@ -1180,7 +1250,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "ind1 = delta_p < 1 * u.dimensionless_unscaled\n", @@ -1217,7 +1289,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# shift a little for plotting purposes\n", From 56252061b05a1ce8a8601bbf92215c1dfe637d0a Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Wed, 27 Sep 2017 20:55:17 -0400 Subject: [PATCH 016/113] Renaming for consistency --- .../{Coordinates => coordinates}/HCG7_2MASS.tbl | 0 .../HCG7_SDSS_cutout.jpg | Bin .../HCG7_SDSS_photo.dat | 0 .../coordinates.ipynb} | 0 .../{Coordinates => coordinates}/requirements.txt | 0 .../Young-Objects-Compilation.csv | 0 .../plot-catalog.ipynb | 0 .../{Plot-Catalog => plot-catalog}/requirements.txt | 0 .../{Plot-Catalog => plot-catalog}/simple_table.csv | 0 .../quantities.ipynb} | 0 .../{Quantities => quantities}/requirements.txt | 0 .../{redshift_plot => redshift-plot}/ang_dist.png | Bin .../redshift_plot.ipynb | 0 .../requirements.txt | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename docs/tutorials/{Coordinates => coordinates}/HCG7_2MASS.tbl (100%) rename docs/tutorials/{Coordinates => coordinates}/HCG7_SDSS_cutout.jpg (100%) rename docs/tutorials/{Coordinates => coordinates}/HCG7_SDSS_photo.dat (100%) rename docs/tutorials/{Coordinates/Coordinates.ipynb => coordinates/coordinates.ipynb} (100%) rename docs/tutorials/{Coordinates => coordinates}/requirements.txt (100%) rename docs/tutorials/{Plot-Catalog => plot-catalog}/Young-Objects-Compilation.csv (100%) rename docs/tutorials/{Plot-Catalog => plot-catalog}/plot-catalog.ipynb (100%) rename docs/tutorials/{Plot-Catalog => plot-catalog}/requirements.txt (100%) rename docs/tutorials/{Plot-Catalog => plot-catalog}/simple_table.csv (100%) rename docs/tutorials/{Quantities/Quantities.ipynb => quantities/quantities.ipynb} (100%) rename docs/tutorials/{Quantities => quantities}/requirements.txt (100%) rename docs/tutorials/{redshift_plot => redshift-plot}/ang_dist.png (100%) rename docs/tutorials/{redshift_plot => redshift-plot}/redshift_plot.ipynb (100%) rename docs/tutorials/{redshift_plot => redshift-plot}/requirements.txt (100%) diff --git a/docs/tutorials/Coordinates/HCG7_2MASS.tbl b/docs/tutorials/coordinates/HCG7_2MASS.tbl similarity index 100% rename from docs/tutorials/Coordinates/HCG7_2MASS.tbl rename to docs/tutorials/coordinates/HCG7_2MASS.tbl diff --git a/docs/tutorials/Coordinates/HCG7_SDSS_cutout.jpg b/docs/tutorials/coordinates/HCG7_SDSS_cutout.jpg similarity index 100% rename from docs/tutorials/Coordinates/HCG7_SDSS_cutout.jpg rename to docs/tutorials/coordinates/HCG7_SDSS_cutout.jpg diff --git a/docs/tutorials/Coordinates/HCG7_SDSS_photo.dat b/docs/tutorials/coordinates/HCG7_SDSS_photo.dat similarity index 100% rename from docs/tutorials/Coordinates/HCG7_SDSS_photo.dat rename to docs/tutorials/coordinates/HCG7_SDSS_photo.dat diff --git a/docs/tutorials/Coordinates/Coordinates.ipynb b/docs/tutorials/coordinates/coordinates.ipynb similarity index 100% rename from docs/tutorials/Coordinates/Coordinates.ipynb rename to docs/tutorials/coordinates/coordinates.ipynb diff --git a/docs/tutorials/Coordinates/requirements.txt b/docs/tutorials/coordinates/requirements.txt similarity index 100% rename from docs/tutorials/Coordinates/requirements.txt rename to docs/tutorials/coordinates/requirements.txt diff --git a/docs/tutorials/Plot-Catalog/Young-Objects-Compilation.csv b/docs/tutorials/plot-catalog/Young-Objects-Compilation.csv similarity index 100% rename from docs/tutorials/Plot-Catalog/Young-Objects-Compilation.csv rename to docs/tutorials/plot-catalog/Young-Objects-Compilation.csv diff --git a/docs/tutorials/Plot-Catalog/plot-catalog.ipynb b/docs/tutorials/plot-catalog/plot-catalog.ipynb similarity index 100% rename from docs/tutorials/Plot-Catalog/plot-catalog.ipynb rename to docs/tutorials/plot-catalog/plot-catalog.ipynb diff --git a/docs/tutorials/Plot-Catalog/requirements.txt b/docs/tutorials/plot-catalog/requirements.txt similarity index 100% rename from docs/tutorials/Plot-Catalog/requirements.txt rename to docs/tutorials/plot-catalog/requirements.txt diff --git a/docs/tutorials/Plot-Catalog/simple_table.csv b/docs/tutorials/plot-catalog/simple_table.csv similarity index 100% rename from docs/tutorials/Plot-Catalog/simple_table.csv rename to docs/tutorials/plot-catalog/simple_table.csv diff --git a/docs/tutorials/Quantities/Quantities.ipynb b/docs/tutorials/quantities/quantities.ipynb similarity index 100% rename from docs/tutorials/Quantities/Quantities.ipynb rename to docs/tutorials/quantities/quantities.ipynb diff --git a/docs/tutorials/Quantities/requirements.txt b/docs/tutorials/quantities/requirements.txt similarity index 100% rename from docs/tutorials/Quantities/requirements.txt rename to docs/tutorials/quantities/requirements.txt diff --git a/docs/tutorials/redshift_plot/ang_dist.png b/docs/tutorials/redshift-plot/ang_dist.png similarity index 100% rename from docs/tutorials/redshift_plot/ang_dist.png rename to docs/tutorials/redshift-plot/ang_dist.png diff --git a/docs/tutorials/redshift_plot/redshift_plot.ipynb b/docs/tutorials/redshift-plot/redshift_plot.ipynb similarity index 100% rename from docs/tutorials/redshift_plot/redshift_plot.ipynb rename to docs/tutorials/redshift-plot/redshift_plot.ipynb diff --git a/docs/tutorials/redshift_plot/requirements.txt b/docs/tutorials/redshift-plot/requirements.txt similarity index 100% rename from docs/tutorials/redshift_plot/requirements.txt rename to docs/tutorials/redshift-plot/requirements.txt From 86519e9dcf1190c442ca8b36c81bed2d4b777a41 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Wed, 27 Sep 2017 20:56:02 -0400 Subject: [PATCH 017/113] fix links in index --- docs/index.rst | 8 ++++---- .../{redshift_plot.ipynb => redshift-plot.ipynb} | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename docs/tutorials/redshift-plot/{redshift_plot.ipynb => redshift-plot.ipynb} (100%) diff --git a/docs/index.rst b/docs/index.rst index 8fd1041c1..aeab30b1e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,12 +5,12 @@ Astropy Tutorials :maxdepth: 1 :glob: - tutorials/Coordinates/Coordinates.ipynb + tutorials/coordinates/coordinates.ipynb tutorials/FITS-header/FITS-header.ipynb tutorials/FITS-images/FITS-images.ipynb tutorials/FITS-tables/FITS-tables.ipynb - tutorials/Plot-Catalog/plot-catalog.ipynb - tutorials/Quantities/Quantities.ipynb - tutorials/redshift_plot/redshift_plot.ipynb + tutorials/plot-catalog/plot-catalog.ipynb + tutorials/quantities/quantities.ipynb + tutorials/redshift-plot/redshift-plot.ipynb tutorials/UVES/UVES.ipynb tutorials/vo/conesearch.ipynb diff --git a/docs/tutorials/redshift-plot/redshift_plot.ipynb b/docs/tutorials/redshift-plot/redshift-plot.ipynb similarity index 100% rename from docs/tutorials/redshift-plot/redshift_plot.ipynb rename to docs/tutorials/redshift-plot/redshift-plot.ipynb From 098987cd1b91a1c7cd3a49e9317255fdc5779d65 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Wed, 27 Sep 2017 21:20:16 -0400 Subject: [PATCH 018/113] add link to tutorials in docs dir --- tutorials | 1 + 1 file changed, 1 insertion(+) create mode 120000 tutorials diff --git a/tutorials b/tutorials new file mode 120000 index 000000000..b27de659d --- /dev/null +++ b/tutorials @@ -0,0 +1 @@ +docs/tutorials/ \ No newline at end of file From fd3947a34451623167b3eb33c9dd0eaf5f48711e Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Wed, 27 Sep 2017 21:52:31 -0400 Subject: [PATCH 019/113] hide in/out prompts --- docs/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 199d63b7c..0028637f5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -139,3 +139,6 @@ # TODO: remove this when errors in tutorials are updated to be static text nbsphinx_allow_errors = True + +# This hides the In[] and Out[] prompts +nbsphinx_prompt_width = 0 From f3c5acbcf8449a32920889840d35ba5c87c74145 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:14:34 -0400 Subject: [PATCH 020/113] add astropy-helpers --- .gitmodules | 3 +++ astropy_helpers | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 astropy_helpers diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..aca5d4a73 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "astropy_helpers"] + path = astropy_helpers + url = git@github.com:astropy/astropy-helpers diff --git a/astropy_helpers b/astropy_helpers new file mode 160000 index 000000000..aaa450659 --- /dev/null +++ b/astropy_helpers @@ -0,0 +1 @@ +Subproject commit aaa4506595b88d46c2cffe06741e36947bb58a55 From 8662b8a090e60bb427bc6eb03cf4db07191c3fa2 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:40:21 -0400 Subject: [PATCH 021/113] move tutorials to docs subdir --- .../tutorials}/Coordinates/Coordinates.ipynb | 0 .../tutorials}/Coordinates/HCG7_2MASS.tbl | 0 .../tutorials}/Coordinates/HCG7_SDSS_cutout.jpg | Bin .../tutorials}/Coordinates/HCG7_SDSS_photo.dat | 0 .../tutorials}/Coordinates/requirements.txt | 0 .../tutorials}/FITS-header/FITS-header.ipynb | 0 .../tutorials}/FITS-header/input_file.fits | Bin .../tutorials}/FITS-header/requirements.txt | 0 .../tutorials}/FITS-images/FITS-images.ipynb | 0 .../tutorials}/FITS-images/requirements.txt | 0 .../tutorials}/FITS-tables/FITS-tables.ipynb | 0 .../tutorials}/FITS-tables/requirements.txt | 0 .../Plot-Catalog/Young-Objects-Compilation.csv | 0 .../tutorials}/Plot-Catalog/plot-catalog.ipynb | 0 .../tutorials}/Plot-Catalog/requirements.txt | 0 .../tutorials}/Plot-Catalog/simple_table.csv | 0 .../tutorials}/Quantities/Quantities.ipynb | 0 .../tutorials}/Quantities/requirements.txt | 0 {tutorials => docs/tutorials}/UVES/CaII-1.png | Bin {tutorials => docs/tutorials}/UVES/CaII-2.png | Bin {tutorials => docs/tutorials}/UVES/CaII-3.png | Bin .../tutorials}/UVES/CaII-lines-all.png | Bin .../tutorials}/UVES/CaII-lines-one.png | Bin {tutorials => docs/tutorials}/UVES/CaII.png | Bin {tutorials => docs/tutorials}/UVES/UVES.ipynb | 0 {tutorials => docs/tutorials}/UVES/requirements.txt | 0 .../tutorials}/redshift_plot/ang_dist.png | Bin .../tutorials}/redshift_plot/redshift_plot.ipynb | 0 .../tutorials}/redshift_plot/requirements.txt | 0 {tutorials => docs/tutorials}/vo/README.rst | 0 .../tutorials}/vo/conesearch_tutorial.ipynb | 0 31 files changed, 0 insertions(+), 0 deletions(-) rename {tutorials => docs/tutorials}/Coordinates/Coordinates.ipynb (100%) rename {tutorials => docs/tutorials}/Coordinates/HCG7_2MASS.tbl (100%) rename {tutorials => docs/tutorials}/Coordinates/HCG7_SDSS_cutout.jpg (100%) rename {tutorials => docs/tutorials}/Coordinates/HCG7_SDSS_photo.dat (100%) rename {tutorials => docs/tutorials}/Coordinates/requirements.txt (100%) rename {tutorials => docs/tutorials}/FITS-header/FITS-header.ipynb (100%) rename {tutorials => docs/tutorials}/FITS-header/input_file.fits (100%) rename {tutorials => docs/tutorials}/FITS-header/requirements.txt (100%) rename {tutorials => docs/tutorials}/FITS-images/FITS-images.ipynb (100%) rename {tutorials => docs/tutorials}/FITS-images/requirements.txt (100%) rename {tutorials => docs/tutorials}/FITS-tables/FITS-tables.ipynb (100%) rename {tutorials => docs/tutorials}/FITS-tables/requirements.txt (100%) rename {tutorials => docs/tutorials}/Plot-Catalog/Young-Objects-Compilation.csv (100%) rename {tutorials => docs/tutorials}/Plot-Catalog/plot-catalog.ipynb (100%) rename {tutorials => docs/tutorials}/Plot-Catalog/requirements.txt (100%) rename {tutorials => docs/tutorials}/Plot-Catalog/simple_table.csv (100%) rename {tutorials => docs/tutorials}/Quantities/Quantities.ipynb (100%) rename {tutorials => docs/tutorials}/Quantities/requirements.txt (100%) rename {tutorials => docs/tutorials}/UVES/CaII-1.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII-2.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII-3.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII-lines-all.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII-lines-one.png (100%) rename {tutorials => docs/tutorials}/UVES/CaII.png (100%) rename {tutorials => docs/tutorials}/UVES/UVES.ipynb (100%) rename {tutorials => docs/tutorials}/UVES/requirements.txt (100%) rename {tutorials => docs/tutorials}/redshift_plot/ang_dist.png (100%) rename {tutorials => docs/tutorials}/redshift_plot/redshift_plot.ipynb (100%) rename {tutorials => docs/tutorials}/redshift_plot/requirements.txt (100%) rename {tutorials => docs/tutorials}/vo/README.rst (100%) rename {tutorials => docs/tutorials}/vo/conesearch_tutorial.ipynb (100%) diff --git a/tutorials/Coordinates/Coordinates.ipynb b/docs/tutorials/Coordinates/Coordinates.ipynb similarity index 100% rename from tutorials/Coordinates/Coordinates.ipynb rename to docs/tutorials/Coordinates/Coordinates.ipynb diff --git a/tutorials/Coordinates/HCG7_2MASS.tbl b/docs/tutorials/Coordinates/HCG7_2MASS.tbl similarity index 100% rename from tutorials/Coordinates/HCG7_2MASS.tbl rename to docs/tutorials/Coordinates/HCG7_2MASS.tbl diff --git a/tutorials/Coordinates/HCG7_SDSS_cutout.jpg b/docs/tutorials/Coordinates/HCG7_SDSS_cutout.jpg similarity index 100% rename from tutorials/Coordinates/HCG7_SDSS_cutout.jpg rename to docs/tutorials/Coordinates/HCG7_SDSS_cutout.jpg diff --git a/tutorials/Coordinates/HCG7_SDSS_photo.dat b/docs/tutorials/Coordinates/HCG7_SDSS_photo.dat similarity index 100% rename from tutorials/Coordinates/HCG7_SDSS_photo.dat rename to docs/tutorials/Coordinates/HCG7_SDSS_photo.dat diff --git a/tutorials/Coordinates/requirements.txt b/docs/tutorials/Coordinates/requirements.txt similarity index 100% rename from tutorials/Coordinates/requirements.txt rename to docs/tutorials/Coordinates/requirements.txt diff --git a/tutorials/FITS-header/FITS-header.ipynb b/docs/tutorials/FITS-header/FITS-header.ipynb similarity index 100% rename from tutorials/FITS-header/FITS-header.ipynb rename to docs/tutorials/FITS-header/FITS-header.ipynb diff --git a/tutorials/FITS-header/input_file.fits b/docs/tutorials/FITS-header/input_file.fits similarity index 100% rename from tutorials/FITS-header/input_file.fits rename to docs/tutorials/FITS-header/input_file.fits diff --git a/tutorials/FITS-header/requirements.txt b/docs/tutorials/FITS-header/requirements.txt similarity index 100% rename from tutorials/FITS-header/requirements.txt rename to docs/tutorials/FITS-header/requirements.txt diff --git a/tutorials/FITS-images/FITS-images.ipynb b/docs/tutorials/FITS-images/FITS-images.ipynb similarity index 100% rename from tutorials/FITS-images/FITS-images.ipynb rename to docs/tutorials/FITS-images/FITS-images.ipynb diff --git a/tutorials/FITS-images/requirements.txt b/docs/tutorials/FITS-images/requirements.txt similarity index 100% rename from tutorials/FITS-images/requirements.txt rename to docs/tutorials/FITS-images/requirements.txt diff --git a/tutorials/FITS-tables/FITS-tables.ipynb b/docs/tutorials/FITS-tables/FITS-tables.ipynb similarity index 100% rename from tutorials/FITS-tables/FITS-tables.ipynb rename to docs/tutorials/FITS-tables/FITS-tables.ipynb diff --git a/tutorials/FITS-tables/requirements.txt b/docs/tutorials/FITS-tables/requirements.txt similarity index 100% rename from tutorials/FITS-tables/requirements.txt rename to docs/tutorials/FITS-tables/requirements.txt diff --git a/tutorials/Plot-Catalog/Young-Objects-Compilation.csv b/docs/tutorials/Plot-Catalog/Young-Objects-Compilation.csv similarity index 100% rename from tutorials/Plot-Catalog/Young-Objects-Compilation.csv rename to docs/tutorials/Plot-Catalog/Young-Objects-Compilation.csv diff --git a/tutorials/Plot-Catalog/plot-catalog.ipynb b/docs/tutorials/Plot-Catalog/plot-catalog.ipynb similarity index 100% rename from tutorials/Plot-Catalog/plot-catalog.ipynb rename to docs/tutorials/Plot-Catalog/plot-catalog.ipynb diff --git a/tutorials/Plot-Catalog/requirements.txt b/docs/tutorials/Plot-Catalog/requirements.txt similarity index 100% rename from tutorials/Plot-Catalog/requirements.txt rename to docs/tutorials/Plot-Catalog/requirements.txt diff --git a/tutorials/Plot-Catalog/simple_table.csv b/docs/tutorials/Plot-Catalog/simple_table.csv similarity index 100% rename from tutorials/Plot-Catalog/simple_table.csv rename to docs/tutorials/Plot-Catalog/simple_table.csv diff --git a/tutorials/Quantities/Quantities.ipynb b/docs/tutorials/Quantities/Quantities.ipynb similarity index 100% rename from tutorials/Quantities/Quantities.ipynb rename to docs/tutorials/Quantities/Quantities.ipynb diff --git a/tutorials/Quantities/requirements.txt b/docs/tutorials/Quantities/requirements.txt similarity index 100% rename from tutorials/Quantities/requirements.txt rename to docs/tutorials/Quantities/requirements.txt diff --git a/tutorials/UVES/CaII-1.png b/docs/tutorials/UVES/CaII-1.png similarity index 100% rename from tutorials/UVES/CaII-1.png rename to docs/tutorials/UVES/CaII-1.png diff --git a/tutorials/UVES/CaII-2.png b/docs/tutorials/UVES/CaII-2.png similarity index 100% rename from tutorials/UVES/CaII-2.png rename to docs/tutorials/UVES/CaII-2.png diff --git a/tutorials/UVES/CaII-3.png b/docs/tutorials/UVES/CaII-3.png similarity index 100% rename from tutorials/UVES/CaII-3.png rename to docs/tutorials/UVES/CaII-3.png diff --git a/tutorials/UVES/CaII-lines-all.png b/docs/tutorials/UVES/CaII-lines-all.png similarity index 100% rename from tutorials/UVES/CaII-lines-all.png rename to docs/tutorials/UVES/CaII-lines-all.png diff --git a/tutorials/UVES/CaII-lines-one.png b/docs/tutorials/UVES/CaII-lines-one.png similarity index 100% rename from tutorials/UVES/CaII-lines-one.png rename to docs/tutorials/UVES/CaII-lines-one.png diff --git a/tutorials/UVES/CaII.png b/docs/tutorials/UVES/CaII.png similarity index 100% rename from tutorials/UVES/CaII.png rename to docs/tutorials/UVES/CaII.png diff --git a/tutorials/UVES/UVES.ipynb b/docs/tutorials/UVES/UVES.ipynb similarity index 100% rename from tutorials/UVES/UVES.ipynb rename to docs/tutorials/UVES/UVES.ipynb diff --git a/tutorials/UVES/requirements.txt b/docs/tutorials/UVES/requirements.txt similarity index 100% rename from tutorials/UVES/requirements.txt rename to docs/tutorials/UVES/requirements.txt diff --git a/tutorials/redshift_plot/ang_dist.png b/docs/tutorials/redshift_plot/ang_dist.png similarity index 100% rename from tutorials/redshift_plot/ang_dist.png rename to docs/tutorials/redshift_plot/ang_dist.png diff --git a/tutorials/redshift_plot/redshift_plot.ipynb b/docs/tutorials/redshift_plot/redshift_plot.ipynb similarity index 100% rename from tutorials/redshift_plot/redshift_plot.ipynb rename to docs/tutorials/redshift_plot/redshift_plot.ipynb diff --git a/tutorials/redshift_plot/requirements.txt b/docs/tutorials/redshift_plot/requirements.txt similarity index 100% rename from tutorials/redshift_plot/requirements.txt rename to docs/tutorials/redshift_plot/requirements.txt diff --git a/tutorials/vo/README.rst b/docs/tutorials/vo/README.rst similarity index 100% rename from tutorials/vo/README.rst rename to docs/tutorials/vo/README.rst diff --git a/tutorials/vo/conesearch_tutorial.ipynb b/docs/tutorials/vo/conesearch_tutorial.ipynb similarity index 100% rename from tutorials/vo/conesearch_tutorial.ipynb rename to docs/tutorials/vo/conesearch_tutorial.ipynb From 5873989e8054fe85c3c19be2ce488462f954377c Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:40:47 -0400 Subject: [PATCH 022/113] add sphinx template files --- docs/Makefile | 133 ++++++++++++++++++++++++++++++++++++++ docs/conf.py | 150 +++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 0 docs/make.bat | 170 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 453 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 000000000..fb03f26e6 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,133 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest + +#This is needed with git because git doesn't create a dir if it's empty +$(shell [ -d "_static" ] || mkdir -p _static) + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + +clean: + -rm -rf $(BUILDDIR) + -rm -rf api + -rm -rf generated + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Astropy.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Astropy.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/Astropy" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Astropy" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + make -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + @echo "Run 'python setup.py test' in the root directory to run doctests " \ + @echo "in the documentation." diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000..a4a400ba5 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +# Astropy documentation build configuration file. + +import datetime +import os +import sys + +try: + import astropy_helpers +except ImportError: + # Building from inside the docs/ directory? + if os.path.basename(os.getcwd()) == 'docs': + a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) + if os.path.isdir(a_h_path): + sys.path.insert(1, a_h_path) + +# Load all of the global Astropy configuration +from astropy_helpers.sphinx.conf import * + +# Get configuration information from setup.cfg +try: + from ConfigParser import ConfigParser +except ImportError: + from configparser import ConfigParser +conf = ConfigParser() + +conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) +setup_cfg = dict(conf.items('metadata')) + +# -- General configuration ---------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.2' + +# To perform a Sphinx version check that needs to be more specific than +# major.minor, call `check_sphinx_version("x.y.z")` here. +# check_sphinx_version("1.2.1") + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# exclude_patterns.append('path') + +# This is added to the end of RST files - a good place to put substitutions to +# be used globally. +rst_epilog += """ +""" + +# -- Project information ------------------------------------------------------ + +# This does not *have* to match the package name, but typically does +project = setup_cfg['package_name'] +author = setup_cfg['author'] +copyright = '2013–{0}, {1}'.format( + datetime.datetime.now().year, setup_cfg['author']) + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. + +__import__(setup_cfg['package_name']) +package = sys.modules[setup_cfg['package_name']] + +# The short X.Y version. +version = package.__version__.split('-', 1)[0] +# The full version, including alpha/beta/rc tags. +release = package.__version__ + + +# -- Options for HTML output -------------------------------------------------- + +# A NOTE ON HTML THEMES +# The global astropy configuration uses a custom theme, 'bootstrap-astropy', +# which is installed along with astropy. A different theme can be used or +# the options for this theme can be modified by overriding some of the +# variables set in the global configuration. The variables set in the +# global configuration are listed below, commented out. + + +# Please update these texts to match the name of your package. +html_theme_options = { + 'logotext1': 'astro', # white, semi-bold + 'logotext2': 'py', # orange, light + 'logotext3': ':tutorials' # white, light + } + +# Add any paths that contain custom themes here, relative to this directory. +# To use a different custom theme, add the directory containing the theme. +#html_theme_path = [] + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. To override the custom theme, set this to the +# name of a builtin theme or the name of a custom theme in html_theme_path. +#html_theme = None + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = '' + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '' + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +html_title = '{0} v{1}'.format(project, release) + +# Output file base name for HTML help builder. +htmlhelp_basename = project + 'doc' + + +# -- Options for LaTeX output ------------------------------------------------- + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [('index', project + '.tex', project + u' Documentation', + author, 'manual')] + + +# -- Options for manual page output ------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [('index', project.lower(), project + u' Documentation', + [author], 1)] + + +# -- Options for the edit_on_github extension --------------------------------- + +if eval(setup_cfg.get('edit_on_github')): + extensions += ['astropy_helpers.sphinx.ext.edit_on_github'] + + versionmod = __import__(setup_cfg['package_name'] + '.version') + edit_on_github_project = setup_cfg['github_project'] + if versionmod.version.release: + edit_on_github_branch = "v" + versionmod.version.version + else: + edit_on_github_branch = "master" + + edit_on_github_source_root = "" + edit_on_github_doc_root = "docs" + +# -- Resolving issue number to links in changelog ----------------------------- +github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) + diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..e69de29bb diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 000000000..93dfe92b9 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,170 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Astropy.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Astropy.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end From 1b8930fba18b11d5df46b3e80085699f321582c9 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:40:57 -0400 Subject: [PATCH 023/113] copy in setup files --- setup.cfg | 51 ++++++++++++++++++++ setup.py | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 setup.cfg create mode 100755 setup.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..5696202cc --- /dev/null +++ b/setup.cfg @@ -0,0 +1,51 @@ +[build_sphinx] +source-dir = docs +build-dir = docs/_build +all_files = 1 + +[build_docs] +source-dir = docs +build-dir = docs/_build +all_files = 1 + +[upload_docs] +upload-dir = docs/_build/html +show-response = 1 + +[pytest] +minversion = 2.2 +norecursedirs = build docs/_build +doctest_plus = enabled + +[ah_bootstrap] +auto_use = True + +[pep8] +# E101 - mix of tabs and spaces +# W191 - use of tabs +# W291 - trailing whitespace +# W292 - no newline at end of file +# W293 - trailing whitespace +# W391 - blank line at end of file +# E111 - 4 spaces per indentation level +# E112 - 4 spaces per indentation level +# E113 - 4 spaces per indentation level +# E901 - SyntaxError or IndentationError +# E902 - IOError +select = E101,W191,W291,W292,W293,W391,E111,E112,E113,E901,E902 +exclude = extern,sphinx,*parsetab.py + +[metadata] +package_name = astropy-tutorials +description = Tutorials for the Astropy Project +author = The Astropy Developers +author_email = astropy.team@gmail.com +license = BSD +url = http://tutorials.astropy.org/ +edit_on_github = False +github_project = astropy/astropy-tutorials +install_requires = astropy +# version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) +version = 3.0.dev + +[entry_points] diff --git a/setup.py b/setup.py new file mode 100755 index 000000000..3691b3471 --- /dev/null +++ b/setup.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +import glob +import os +import sys + +import ah_bootstrap +from setuptools import setup + +#A dirty hack to get around some early import/configurations ambiguities +if sys.version_info[0] >= 3: + import builtins +else: + import __builtin__ as builtins +builtins._ASTROPY_SETUP_ = True + +from astropy_helpers.setup_helpers import (register_commands, get_debug_option, + get_package_info) +from astropy_helpers.git_helpers import get_git_devstr +from astropy_helpers.version_helpers import generate_version_py + +# Get some values from the setup.cfg +try: + from ConfigParser import ConfigParser +except ImportError: + from configparser import ConfigParser + +conf = ConfigParser() +conf.read(['setup.cfg']) +metadata = dict(conf.items('metadata')) + +PACKAGENAME = metadata.get('package_name', 'packagename') +DESCRIPTION = metadata.get('description', 'Astropy affiliated package') +AUTHOR = metadata.get('author', '') +AUTHOR_EMAIL = metadata.get('author_email', '') +LICENSE = metadata.get('license', 'unknown') +URL = metadata.get('url', 'http://astropy.org') + +# order of priority for long_description: +# (1) set in setup.cfg, +# (2) load LONG_DESCRIPTION.rst, +# (3) load README.rst, +# (4) package docstring +readme_glob = 'README*' +_cfg_long_description = metadata.get('long_description', '') +if _cfg_long_description: + LONG_DESCRIPTION = _cfg_long_description + +elif os.path.exists('LONG_DESCRIPTION.rst'): + with open('LONG_DESCRIPTION.rst') as f: + LONG_DESCRIPTION = f.read() + +elif len(glob.glob(readme_glob)) > 0: + with open(glob.glob(readme_glob)[0]) as f: + LONG_DESCRIPTION = f.read() + +else: + # Get the long description from the package's docstring + __import__(PACKAGENAME) + package = sys.modules[PACKAGENAME] + LONG_DESCRIPTION = package.__doc__ + +# Store the package name in a built-in variable so it's easy +# to get from other parts of the setup infrastructure +builtins._ASTROPY_PACKAGE_NAME_ = PACKAGENAME + +# VERSION should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) +VERSION = metadata.get('version', '0.0.dev') + +# Indicates if this version is a release version +RELEASE = 'dev' not in VERSION + +if not RELEASE: + VERSION += get_git_devstr(False) + +# Populate the dict of setup command overrides; this should be done before +# invoking any other functionality from distutils since it can potentially +# modify distutils' behavior. +cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE) + +# Freeze build information in version.py +generate_version_py(PACKAGENAME, VERSION, RELEASE, + get_debug_option(PACKAGENAME)) + +# Treat everything in scripts except README* as a script to be installed +scripts = [fname for fname in glob.glob(os.path.join('scripts', '*')) + if not os.path.basename(fname).startswith('README')] + + +# Get configuration information from all of the various subpackages. +# See the docstring for setup_helpers.update_package_files for more +# details. +package_info = get_package_info() + +# Add the project-global data +package_info['package_data'].setdefault(PACKAGENAME, []) +package_info['package_data'][PACKAGENAME].append('data/*') + +# Define entry points for command-line scripts +entry_points = {'console_scripts': []} + +entry_point_list = conf.items('entry_points') +for entry_point in entry_point_list: + entry_points['console_scripts'].append('{0} = {1}'.format(entry_point[0], + entry_point[1])) + +# Include all .c files, recursively, including those generated by +# Cython, since we can not do this in MANIFEST.in with a "dynamic" +# directory name. +c_files = [] +for root, dirs, files in os.walk(PACKAGENAME): + for filename in files: + if filename.endswith('.c'): + c_files.append( + os.path.join( + os.path.relpath(root, PACKAGENAME), filename)) +package_info['package_data'][PACKAGENAME].extend(c_files) + +# Note that requires and provides should not be included in the call to +# ``setup``, since these are now deprecated. See this link for more details: +# https://groups.google.com/forum/#!topic/astropy-dev/urYO8ckB2uM + +setup(name=PACKAGENAME, + version=VERSION, + description=DESCRIPTION, + scripts=scripts, + install_requires=metadata.get('install_requires', 'astropy').strip().split(), + author=AUTHOR, + author_email=AUTHOR_EMAIL, + license=LICENSE, + url=URL, + long_description=LONG_DESCRIPTION, + cmdclass=cmdclassd, + zip_safe=False, + use_2to3=False, + entry_points=entry_points, + **package_info +) From 0fe3467f39bed9f333672ba6f636904afb267c66 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 12:55:33 -0400 Subject: [PATCH 024/113] move readme to RST --- README.md | 29 ----------------------------- README.rst | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 29 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index 33c8c43ee..000000000 --- a/README.md +++ /dev/null @@ -1,29 +0,0 @@ -Tutorials -========= - -This repository contains tutorials for the [Astropy](http://astropy.org) -project (also on [github](https://github.com/astropy/astropy)). - -Running Tutorials ------------------ -The easiest way to get started quickly is to use binder to run the tutorials in your web browser - when this loads, click the "tutorials" folder and you should see all the tutorials: -[![Binder](http://mybinder.org/badge.svg)](https://beta.mybinder.org/v2/gh/astropy/astropy-tutorials/master) - -To run the tutorials *locally*, you need jupyter notebook installed: - - jupyter notebook - -The tutorials are initially empty of any output. You can run them by pressing -"Run All" under the "Cell" menu in the notebook file. - -Dependencies ------------- - -To deploy the notebooks, you will need: - -* IPython -* Astropy -* runipy -* pandoc - -_Note, all except pandoc can be pip installed. To install pandoc, follow the instructions here: http://johnmacfarlane.net/pandoc/installing.html_. diff --git a/README.rst b/README.rst new file mode 100644 index 000000000..0ca2839e5 --- /dev/null +++ b/README.rst @@ -0,0 +1,25 @@ +# Astropy Tutorials + +This repository contains tutorials for the [Astropy](http://astropy.org) +project (also on [github](https://github.com/astropy/astropy)). + +## Running Tutorials + +The easiest way to get started quickly is to use binder to run the tutorials in +your web browser - when this loads, click the "tutorials" folder and you should +see all the tutorials: + +.. image:: http://mybinder.org/badge.svg + :target: http://mybinder.org/repo/astropy/astropy-tutorials/docs/tutorials + +To run the tutorials *locally*, you need jupyter notebook installed:: + + jupyter notebook + +The tutorials are initially empty of any output. You can run them by pressing +"Run All" under the "Cell" menu in the notebook file. + +## Dependencies + +See the conda environment file or pip requirements file for a list of +dependencies. From d03c41a67b298d97d6d62199493277e0f877e844 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:31:13 -0400 Subject: [PATCH 025/113] remove grabbing version from package --- docs/conf.py | 31 ++++++++++--------------------- setup.py | 29 +++-------------------------- 2 files changed, 13 insertions(+), 47 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a4a400ba5..bc196ce3b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -40,7 +40,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -# exclude_patterns.append('path') +exclude_patterns.append('**.ipynb_checkpoints') # This is added to the end of RST files - a good place to put substitutions to # be used globally. @@ -59,13 +59,11 @@ # |version| and |release|, also used in various other places throughout the # built documents. -__import__(setup_cfg['package_name']) -package = sys.modules[setup_cfg['package_name']] - # The short X.Y version. -version = package.__version__.split('-', 1)[0] +version = setup_cfg['version'].split('-', 1)[0] # The full version, including alpha/beta/rc tags. -release = package.__version__ +# release = package.__version__ +release = version # -- Options for HTML output -------------------------------------------------- @@ -130,21 +128,12 @@ [author], 1)] -# -- Options for the edit_on_github extension --------------------------------- - -if eval(setup_cfg.get('edit_on_github')): - extensions += ['astropy_helpers.sphinx.ext.edit_on_github'] - - versionmod = __import__(setup_cfg['package_name'] + '.version') - edit_on_github_project = setup_cfg['github_project'] - if versionmod.version.release: - edit_on_github_branch = "v" + versionmod.version.version - else: - edit_on_github_branch = "master" - - edit_on_github_source_root = "" - edit_on_github_doc_root = "docs" - # -- Resolving issue number to links in changelog ----------------------------- github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) +# We require nbsphinx +extensions += ['nbsphinx'] +extensions += ['IPython.sphinxext.ipython_console_highlighting'] + +# TODO: remove this when errors in tutorials are updated to be static text +nbsphinx_allow_errors = True diff --git a/setup.py b/setup.py index 3691b3471..c5a0405e7 100755 --- a/setup.py +++ b/setup.py @@ -37,29 +37,10 @@ LICENSE = metadata.get('license', 'unknown') URL = metadata.get('url', 'http://astropy.org') -# order of priority for long_description: -# (1) set in setup.cfg, -# (2) load LONG_DESCRIPTION.rst, -# (3) load README.rst, -# (4) package docstring -readme_glob = 'README*' -_cfg_long_description = metadata.get('long_description', '') -if _cfg_long_description: - LONG_DESCRIPTION = _cfg_long_description - -elif os.path.exists('LONG_DESCRIPTION.rst'): - with open('LONG_DESCRIPTION.rst') as f: - LONG_DESCRIPTION = f.read() - -elif len(glob.glob(readme_glob)) > 0: - with open(glob.glob(readme_glob)[0]) as f: - LONG_DESCRIPTION = f.read() -else: - # Get the long description from the package's docstring - __import__(PACKAGENAME) - package = sys.modules[PACKAGENAME] - LONG_DESCRIPTION = package.__doc__ +readme_glob = 'README.rst' +with open('README.rst') as f: + LONG_DESCRIPTION = f.read() # Store the package name in a built-in variable so it's easy # to get from other parts of the setup infrastructure @@ -79,10 +60,6 @@ # modify distutils' behavior. cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE) -# Freeze build information in version.py -generate_version_py(PACKAGENAME, VERSION, RELEASE, - get_debug_option(PACKAGENAME)) - # Treat everything in scripts except README* as a script to be installed scripts = [fname for fname in glob.glob(os.path.join('scripts', '*')) if not os.path.basename(fname).startswith('README')] From d7685fc7e6d5bbccb19dd49e7d2c00a8d39c046b Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:32:32 -0400 Subject: [PATCH 026/113] remove old html dir --- html/css/docs.css | 844 -------------------------------- html/css/style.css | 304 ------------ html/images/astropy_word_32.png | Bin 4692 -> 0 bytes 3 files changed, 1148 deletions(-) delete mode 100644 html/css/docs.css delete mode 100644 html/css/style.css delete mode 100644 html/images/astropy_word_32.png diff --git a/html/css/docs.css b/html/css/docs.css deleted file mode 100644 index 78993c444..000000000 --- a/html/css/docs.css +++ /dev/null @@ -1,844 +0,0 @@ -/* Add additional stylesheets below --------------------------------------------------- */ -/* - Bootstrap's documentation styles - Special styles for presenting Bootstrap's documentation and examples - - Note: if you want to make specific modifications for the tutorials' notebooks, - it's probably better to go into the style.css (look for the #notebook selectors). - That way we can mostly keep them in one place. -*/ - - -/* Body and structure --------------------------------------------------- */ -body { - position: relative; - background-color: #fff; - background-repeat: repeat-x; - background-position: 0 40px; - padding-top: 40px; -} - - -/* Tweak navbar brand link to be super sleek --------------------------------------------------- */ -.navbar-fixed-top .brand { - padding-right: 0; - padding-left: 0; - margin-left: 20px; - float: right; - font-weight: bold; - color: #000; - text-shadow: 0 1px 0 rgba(255,255,255,.1), 0 0 30px rgba(255,255,255,.125); - -webkit-transition: all .2s linear; - -moz-transition: all .2s linear; - transition: all .2s linear; -} -.navbar-fixed-top .brand:hover { - text-decoration: none; -} - - -/* Space out sub-sections more --------------------------------------------------- */ -section { - padding-top: 60px; -} - -/* Faded out hr */ -hr.soften { - height: 1px; - margin: 54px 0; - background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.1), rgba(0,0,0,0)); - background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.1), rgba(0,0,0,0)); - background-image: -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.1), rgba(0,0,0,0)); - background-image: -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.1), rgba(0,0,0,0)); - border: 0; -} - - -/* Jumbotrons --------------------------------------------------- */ -.jumbotron { - position: relative; -} -.jumbotron h1 { - margin-bottom: 9px; - font-size: 81px; - font-weight: bold; - letter-spacing: -1px; - line-height: 1; -} -.jumbotron p { - margin-bottom: 18px; - font-weight: 300; -} -.jumbotron .btn-large { - font-size: 20px; - font-weight: normal; - padding: 14px 24px; - margin-right: 10px; - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; -} -.jumbotron .btn-large small { - font-size: 14px; -} - -/* Masthead (docs home) */ -.masthead { - margin-bottom: 72px; -} -.masthead h1, -.masthead p { - text-align: center; -} -.masthead h1 { - margin-bottom: 18px; -} -.masthead p { - margin-left: 5%; - margin-right: 5%; - font-size: 30px; - line-height: 36px; -} - - -/* Specific jumbotrons -------------------------- */ -/* supporting docs pages */ -.subhead { - padding-bottom: 0; - margin-bottom: 9px; -} -.subhead h1 { - font-size: 54px; -} - -/* Subnav */ -.subnav { - width: 100%; - height: 36px; - background-color: #eeeeee; /* Old browsers */ - background-repeat: repeat-x; /* Repeat the gradient */ - background-image: -moz-linear-gradient(top, #f5f5f5 0%, #eeeeee 100%); /* FF3.6+ */ - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#eeeeee)); /* Chrome,Safari4+ */ - background-image: -webkit-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* Chrome 10+,Safari 5.1+ */ - background-image: -ms-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* IE10+ */ - background-image: -o-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* Opera 11.10+ */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#eeeeee',GradientType=0 ); /* IE6-9 */ - background-image: linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* W3C */ - border: 1px solid #e5e5e5; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -.subnav .nav { - margin-bottom: 0; -} -.subnav .nav > li > a { - margin: 0; - padding-top: 11px; - padding-bottom: 11px; - border-left: 1px solid #f5f5f5; - border-right: 1px solid #e5e5e5; - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; -} -.subnav .nav > .active > a, -.subnav .nav > .active > a:hover { - padding-left: 13px; - color: #777; - background-color: #e9e9e9; - border-right-color: #ddd; - border-left: 0; - -webkit-box-shadow: inset 0 3px 5px rgba(0,0,0,.05); - -moz-box-shadow: inset 0 3px 5px rgba(0,0,0,.05); - box-shadow: inset 0 3px 5px rgba(0,0,0,.05); -} -.subnav .nav > .active > a .caret, -.subnav .nav > .active > a:hover .caret { - border-top-color: #777; -} -.subnav .nav > li:first-child > a, -.subnav .nav > li:first-child > a:hover { - border-left: 0; - padding-left: 12px; - -webkit-border-radius: 4px 0 0 4px; - -moz-border-radius: 4px 0 0 4px; - border-radius: 4px 0 0 4px; -} -.subnav .nav > li:last-child > a { - border-right: 0; -} -.subnav .dropdown-menu { - -webkit-border-radius: 0 0 4px 4px; - -moz-border-radius: 0 0 4px 4px; - border-radius: 0 0 4px 4px; -} - -/* Fixed subnav on scroll, but only for 980px and up (sorry IE!) */ -@media (min-width: 980px) { - .subnav-fixed { - position: fixed; - top: 40px; - left: 0; - right: 0; - z-index: 1020; /* 10 less than .navbar-fixed to prevent any overlap */ - border-color: #d5d5d5; - border-width: 0 0 1px; /* drop the border on the fixed edges */ - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; - -webkit-box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1); - -moz-box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1); - box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); /* IE6-9 */ - } - .subnav-fixed .nav { - width: 938px; - margin: 0 auto; - padding: 0 1px; - } - .subnav .nav > li:first-child > a, - .subnav .nav > li:first-child > a:hover { - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; - } -} - - -/* Quick links --------------------------------------------------- */ -.bs-links { - margin: 36px 0; -} -.quick-links { - min-height: 30px; - margin: 0; - padding: 5px 20px; - list-style: none; - text-align: center; - overflow: hidden; -} -.quick-links:first-child { - min-height: 0; -} -.quick-links li { - display: inline; - margin: 0 8px; - color: #999; -} -.quick-links .github-btn, -.quick-links .tweet-btn, -.quick-links .follow-btn { - position: relative; - top: 5px; -} - - -/* Marketing section of Overview --------------------------------------------------- */ -.marketing .row { - margin-bottom: 9px; -} -.marketing h1 { - margin: 36px 0 27px; - font-size: 40px; - font-weight: 300; - text-align: center; -} -.marketing h2, -.marketing h3 { - font-weight: 300; -} -.marketing h2 { - font-size: 22px; -} -.marketing p { - margin-right: 10px; -} -.marketing .bs-icon { - float: left; - margin: 7px 10px 0 0; - opacity: .8; -} -.marketing .small-bs-icon { - float: left; - margin: 4px 5px 0 0; -} - - - -/* Footer --------------------------------------------------- */ -.footer { - margin-top: 45px; - padding: 35px 0 36px; - border-top: 1px solid #e5e5e5; -} -.footer p { - margin-bottom: 0; - color: #555; -} - - - -/* Special grid styles --------------------------------------------------- */ -.show-grid { - margin-top: 10px; - margin-bottom: 20px; -} -.show-grid [class*="span"] { - background-color: #eee; - text-align: center; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - min-height: 30px; - line-height: 30px; -} -.show-grid:hover [class*="span"] { - background: #ddd; -} -.show-grid .show-grid { - margin-top: 0; - margin-bottom: 0; -} -.show-grid .show-grid [class*="span"] { - background-color: #ccc; -} - - -/* Render mini layout previews --------------------------------------------------- */ -.mini-layout { - border: 1px solid #ddd; - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; - -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.075); - -moz-box-shadow: 0 1px 2px rgba(0,0,0,.075); - box-shadow: 0 1px 2px rgba(0,0,0,.075); -} -.mini-layout { - height: 240px; - margin-bottom: 20px; - padding: 9px; -} -.mini-layout div { - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; -} -.mini-layout .mini-layout-body { - background-color: #dceaf4; - margin: 0 auto; - width: 70%; - height: 240px; -} -.mini-layout.fluid .mini-layout-sidebar, -.mini-layout.fluid .mini-layout-header, -.mini-layout.fluid .mini-layout-body { - float: left; -} -.mini-layout.fluid .mini-layout-sidebar { - background-color: #bbd8e9; - width: 20%; - height: 240px; -} -.mini-layout.fluid .mini-layout-body { - width: 77.5%; - margin-left: 2.5%; -} - - -/* Popover docs --------------------------------------------------- */ -.popover-well { - min-height: 160px; -} -.popover-well .popover { - display: block; -} -.popover-well .popover-wrapper { - width: 50%; - height: 160px; - float: left; - margin-left: 55px; - position: relative; -} -.popover-well .popover-menu-wrapper { - height: 80px; -} -.large-bird { - margin: 5px 0 0 310px; - opacity: .1; -} - - -/* Download page --------------------------------------------------- */ -.download .page-header { - margin-top: 36px; -} -.page-header .toggle-all { - margin-top: 5px; -} - -/* Space out h3s when following a section */ -.download h3 { - margin-bottom: 5px; -} -.download-builder input + h3, -.download-builder .checkbox + h3 { - margin-top: 9px; -} - -/* Fields for variables */ -.download-builder input[type=text] { - margin-bottom: 9px; - font-family: Menlo, Monaco, "Courier New", monospace; - font-size: 12px; - color: #d14; -} -.download-builder input[type=text]:focus { - background-color: #fff; -} - -/* Custom, larger checkbox labels */ -.download .checkbox { - padding: 6px 10px 6px 25px; - color: #555; - background-color: #f9f9f9; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - cursor: pointer; -} -.download .checkbox:hover { - color: #333; - background-color: #f5f5f5; -} -.download .checkbox small { - font-size: 12px; - color: #777; -} - -/* Variables section */ -#variables label { - margin-bottom: 0; -} - -/* Giant download button */ -.download-btn { - margin: 36px 0 108px; -} -#download p, -#download h4 { - max-width: 50%; - margin: 0 auto; - color: #999; - text-align: center; -} -#download h4 { - margin-bottom: 0; -} -#download p { - margin-bottom: 18px; -} -.download-btn .btn { - display: block; - width: auto; - padding: 19px 24px; - margin-bottom: 27px; - font-size: 30px; - line-height: 1; - text-align: center; - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; -} - - - -/* Color swatches on LESS docs page --------------------------------------------------- */ -/* Sets the width of the td */ -.swatch-col { - width: 30px; -} -/* Le swatch */ -.swatch { - display: inline-block; - width: 30px; - height: 20px; - margin: -6px 0; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; -} -/* For white swatches, give a border */ -.swatch-bordered { - width: 28px; - height: 18px; - border: 1px solid #eee; -} - - -/* Misc --------------------------------------------------- */ - -/* Make tables spaced out a bit more */ -h2 + table, -h3 + table, -h4 + table, -h2 + .row { - margin-top: 5px; -} - -/* Example sites showcase */ -.example-sites img { - max-width: 100%; - margin: 0 auto; -} -.marketing-byline { - font-size: 18px; - font-weight: 300; - line-height: 24px; - color: #999; - text-align: center; -} - -.scrollspy-example { - height: 200px; - overflow: auto; - position: relative; -} - -/* Remove bottom margin on example forms in wells */ -form.well { - padding: 14px; -} - -/* Tighten up spacing */ -.well hr { - margin: 18px 0; -} - -/* Fake the :focus state to demo it */ -.focused { - border-color: rgba(82,168,236,.8); - -webkit-box-shadow: inset 0 1px 3px rgba(0,0,0,.1), 0 0 8px rgba(82,168,236,.6); - -moz-box-shadow: inset 0 1px 3px rgba(0,0,0,.1), 0 0 8px rgba(82,168,236,.6); - box-shadow: inset 0 1px 3px rgba(0,0,0,.1), 0 0 8px rgba(82,168,236,.6); - outline: 0; -} - -/* For input sizes, make them display block */ -.docs-input-sizes select, -.docs-input-sizes input[type=text] { - display: block; - margin-bottom: 9px; -} - -/* Icons -------------------------- */ -.the-icons { - margin-left: 0; - list-style: none; -} -.the-icons i:hover { - background-color: rgba(255,0,0,.25); -} - -/* Eaxmples page -------------------------- */ -.bootstrap-examples .thumbnail { - margin-bottom: 9px; - background-color: #fff; -} - -/* Responsive table -------------------------- */ -.responsive-utilities th small { - display: block; - font-weight: normal; - color: #999; -} -.responsive-utilities tbody th { - font-weight: normal; -} -.responsive-utilities td { - text-align: center; -} -.responsive-utilities td.is-visible { - color: #468847; - background-color: #dff0d8 !important; -} -.responsive-utilities td.is-hidden { - color: #ccc; - background-color: #f9f9f9 !important; -} - -/* Responsive tests -------------------------- */ -.responsive-utilities-test { - margin-top: 5px; - margin-left: 0; - list-style: none; - overflow: hidden; /* clear floats */ -} -.responsive-utilities-test li { - position: relative; - float: left; - width: 25%; - height: 43px; - font-size: 14px; - font-weight: bold; - line-height: 43px; - color: #999; - text-align: center; - border: 1px solid #ddd; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -.responsive-utilities-test li + li { - margin-left: 10px; -} -.responsive-utilities-test span { - position: absolute; - top: -1px; - left: -1px; - right: -1px; - bottom: -1px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -.responsive-utilities-test span { - color: #468847; - background-color: #dff0d8; - border: 1px solid #d6e9c6; -} - - -/* Responsive Docs --------------------------------------------------- */ -@media (max-width: 480px) { - - /* Change up some type stuff */ - h2 { - margin-top: 27px; - } - h2 small { - display: block; - line-height: 18px; - } - h3 { - margin-top: 18px; - } - - /* icons */ - .marketing .bs-icon { - margin: 0; - } - - /* Adjust the jumbotron */ - .jumbotron h1, - .jumbotron p { - text-align: center; - margin-right: 0; - } - .jumbotron h1 { - font-size: 45px; - margin-right: 0; - } - .jumbotron p { - margin-right: 0; - margin-left: 0; - font-size: 18px; - line-height: 24px; - } - .jumbotron .btn { - display: block; - font-size: 18px; - padding: 10px 14px; - margin: 0 auto 10px; - } - /* Masthead (home page jumbotron) */ - .masthead { - padding-top: 0; - } - - /* Don't space out quick links so much */ - .quick-links { - margin: 40px 0 0; - } - /* hide the bullets on mobile since our horizontal space is limited */ - .quick-links .divider { - display: none; - } - - /* center example sites */ - .example-sites { - margin-left: 0; - } - .example-sites > li { - float: none; - display: block; - max-width: 280px; - margin: 0 auto 18px; - text-align: center; - } - .example-sites .thumbnail > img { - max-width: 270px; - } - - table code { - white-space: normal; - word-wrap: break-word; - word-break: break-all; - } - - /* Modal example */ - .modal-example .modal { - position: relative; - top: auto; - right: auto; - bottom: auto; - left: auto; - } - -} - - -@media (max-width: 768px) { - - /* This was in the version copied from the main site, but it mucks up the ipython notebooks */ - /* Remove any padding from the body */ - /*body { - padding-top: 0; - }*/ - - /* Jumbotron buttons */ - .jumbotron .btn { - margin-bottom: 10px; - } - - /* Subnav */ - .subnav { - position: static; - top: auto; - z-index: auto; - width: auto; - height: auto; - background: #fff; /* whole background property since we use a background-image for gradient */ - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - } - .subnav .nav > li { - float: none; - } - .subnav .nav > li > a { - border: 0; - } - .subnav .nav > li + li > a { - border-top: 1px solid #e5e5e5; - } - .subnav .nav > li:first-child > a, - .subnav .nav > li:first-child > a:hover { - -webkit-border-radius: 4px 4px 0 0; - -moz-border-radius: 4px 4px 0 0; - border-radius: 4px 4px 0 0; - } - - /* Popovers */ - .large-bird { - display: none; - } - .popover-well .popover-wrapper { - margin-left: 0; - } - - /* Space out the show-grid examples */ - .show-grid [class*="span"] { - margin-bottom: 5px; - } - - /* Unfloat the back to top link in footer */ - .footer .pull-right { - float: none; - } - .footer p { - margin-bottom: 9px; - } - -} - - -@media (min-width: 480px) and (max-width: 768px) { - - /* Scale down the jumbotron content */ - .jumbotron h1 { - font-size: 54px; - } - .jumbotron p { - margin-right: 0; - margin-left: 0; - } - -} - - -@media (min-width: 768px) and (max-width: 980px) { - - /* This was in the version copied from the main site, but it mucks up the ipython notebooks */ - /* Remove any padding from the body */ - /*body { - padding-top: 0; - }*/ - - /* Scale down the jumbotron content */ - .jumbotron h1 { - font-size: 72px; - } - -} - - -@media (max-width: 980px) { - - /* Unfloat brand */ - .navbar-fixed-top .brand { - float: left; - margin-left: 0; - padding-left: 10px; - padding-right: 10px; - } - - /* Inline-block quick links for more spacing */ - .quick-links li { - display: inline-block; - margin: 5px; - } - -} - - -/* LARGE DESKTOP SCREENS */ -@media (min-width: 1210px) { - - /* Update subnav container */ - .subnav-fixed .nav { - width: 1168px; /* 2px less to account for left/right borders being removed when in fixed mode */ - } - -} diff --git a/html/css/style.css b/html/css/style.css deleted file mode 100644 index 3e8374490..000000000 --- a/html/css/style.css +++ /dev/null @@ -1,304 +0,0 @@ -/* Ripped from the main astropy website with some modifications*/ -/* http://meyerweb.com/eric/tools/css/reset/ - v2.0 | 20110126 - License: none (public domain) -*/ - -/* HTML5 display-role reset for older browsers */ -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} -body { - line-height: 1; -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; -} - -body{ - line-height: 1.25em; - font-size: 16px; - color:#333; - font-family: 'Open Sans', sans-serif; -} - -#wrapper{ - margin:0 auto; - max-width:960px; - padding:0 10px; - min-width: 320px; /* min-width of whole site */ -} - -a{ - color: #FF5000; - text-decoration: none; -} -a, svg{ - -webkit-transition: all 0.3s ease; - -moz-transition: all 0.3s ease; - -o-transition: all 0.3s ease; - -ms-transition: all 0.3s ease; - transition: all 0.3s ease; -} - -a:hover{ - color:#333; -} - -h1{ - font-size: 28px; - font-weight: bold; - margin-top: 10px; - margin-bottom: 20px; -} - -h2{ - font-size: 24px; - margin-bottom: 10px; -} - -h3{ - font-size: 20px; - margin: 20px 0px 10px 0px; - -} - -p{ - margin-bottom: 10px; - margin-top: 10px; - line-height: 1.5em; -} - -strong{ - font-weight: bold; - -} - -section{ - border-bottom: 1px #efefef solid; - padding: 20px 0 20px; - clear: both; -} - -section:first-of-type{ - margin-top:42px; -} - -section:last-of-type{ - border-bottom: 0px; -} - -section *:last-child{ - margin-bottom: 0px; -} - -ul li{ - list-style-type: square; - list-style-position: outside; - list-style-color: #FF5000; - line-height: 1.5em; - margin-bottom:0.5em; - margin-left: 30px; -} - -ul li:last-child{ - margin-bottom: 0px; -} - -cite{ - font-family: monospace; -} - -pre{ - background-color: #f5f5f5; - border: 1px solid #ddd; - padding: 10px; - color: black; - font-family: Monaco, Andale Mono, Courier New, monospace; - webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - margin-bottom: 5px; -} - -.button{ - padding: 8px; - display: inline-block; - background-image: -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0, #FC9468), - color-stop(0.89, #FF5100) - ); - background-image: -o-linear-gradient(bottom, #FC9468 0%, #FF5100 89%); - background-image: -moz-linear-gradient(bottom, #FC9468 0%, #FF5100 89%); - background-image: -webkit-linear-gradient(bottom, #FC9468 0%, #FF5100 89%); - background-image: -ms-linear-gradient(bottom, #FC9468 0%, #FF5100 89%); - background-image: linear-gradient(to bottom, #FC9468 0%, #FF5100 89%); -} - -a.button, .button a{ - color: white; -} - - -p .button{ - padding-top:0px; - padding-bottom:0px; - padding-right:4px; - padding-left:4px; -} - -.button:hover{ - cursor: pointer; - background-image: -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0, #FFA47D), - color-stop(1, #FF7D45) - ); - background-image: -o-linear-gradient(bottom, #FFA47D 0%, #FF7D45 100%); - background-image: -moz-linear-gradient(bottom, #FFA47D 0%, #FF7D45 100%); - background-image: -webkit-linear-gradient(bottom, #FFA47D 0%, #FF7D45 100%); - background-image: -ms-linear-gradient(bottom, #FFA47D 0%, #FF7D45 100%); - background-image: linear-gradient(to bottom, #FFA47D 0%, #FF7D45 100%); -} - - -.right{ - float: right; -} - -/* nav */ -nav{ - line-height: 42px; - position:absolute; - left:0px; - top:0px; - width:100%; - background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #222222),color-stop(0.89, #333333)); - background-image: -o-linear-gradient(bottom, #222222 0%, #333333 89%); - background-image: -moz-linear-gradient(bottom, #222222 0%, #333333 89%); - background-image: -webkit-linear-gradient(bottom, #222222 0%, #333333 89%); - background-image: -ms-linear-gradient(bottom, #222222 0%, #333333 89%); - background-image: linear-gradient(to bottom, #222222 0%, #333333 89%); -} - -nav > *{ - display:inline-block; - vertical-align:top; -} - -nav img{ - float: left; - margin-left: 20px; - margin-top: 5px; -} - -nav ul{ - max-width:960px; - margin: 0; - padding: 0; -} - -nav ul li{ - display:inline; - list-style: none; - display: block; - margin: 0; -} - -nav li a, nav li a:link{ - color:#fff; - font-size: 22px; - font-weight: 300; -} -nav li a:hover{ - color:#FF5000; -} - -nav li a.active{ - color:#FF5000; -} - -nav .pull-right{ - float: right; - margin-right:10px; -} - - -/* - IPython overrides -*/ - -/* Tweaks to make a bit more responsive in conjuction with astropy scheme */ - -@media (max-width: 355px) { - - #wrapper { - padding-left: 0px; - padding-right: 0px; - } - - body { - padding-left: 0px; - padding-right: 0px; - } - - .text_cell_render { - padding-left: 0px; - padding-right: 0px; - } - -} - -.container { - max-width: 900px; - font-size: 12pt; -} - -.tutorials li { - padding-top: 10px; - padding-bottom: 10px; - margin-bottom: 0; -} - - -/* - Notebook styling -*/ - -#notebook p { - font-size: 16px; - line-height: 20px; -} - -#notebook code, pre{ - padding:0 3px 2px; - font-family: monospace; - word-wrap: break-word; -} - -#notebook pre { - font-size:14px; - line-height: 17px; -} - -#notebook sub { - line-height: 1; -} \ No newline at end of file diff --git a/html/images/astropy_word_32.png b/html/images/astropy_word_32.png deleted file mode 100644 index 7125b632b8724f48656e33f233bbccb8f21532e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4692 zcmV-a607ZrP)X+uL$Nkc;* zP;zf(X>4Tx07wm;mUmQB*%pV-y*Itk5+Wca^cs2zAksTX6$DXM^`x7XQc?|s+0 z08spb1j2M!0f022SQPH-!CVp(%f$Br7!UytSOLJ{W@ZFO_(THK{JlMynW#v{v-a*T zfMmPdEWc1DbJqWVks>!kBnAKqMb$PuekK>?0+ds;#ThdH1j_W4DKdsJG8Ul;qO2n0 z#IJ1jr{*iW$(WZWsE0n`c;fQ!l&-AnmjxZO1uWyz`0VP>&nP`#itsL#`S=Q!g`M=rU9)45( zJ;-|dRq-b5&z?byo>|{)?5r=n76A4nTALlSzLiw~v~31J<>9PP?;rs31pu_(obw)r zY+jPY;tVGXi|p)da{-@gE-UCa`=5eu%D;v=_nFJ?`&K)q7e9d`Nfk3?MdhZarb|T3 z%nS~f&t(1g5dY)AIcd$w!z`Siz!&j_=v7hZlnI21XuE|xfmo0(WD10T)!}~_HYW!e zew}L+XmwuzeT6wtxJd`dZ#@7*BLgIEKY9Xv>st^p3dp{^Xswa2bB{85{^$B13tWnB z;Y>jyQ|9&zk7RNsqAVGs--K+z0uqo1bf5|}fi5rtEMN^BfHQCd-XH*kfJhJnmIE$G z0%<@5vOzxB0181d*a3EfYH$G5fqKvcPJ%XY23!PJzzuK<41h;K3WmW;Fah3yX$XSw z5EY_9s*o0>51B&N5F1(uc|$=^I1~fLLy3?Ol0f;;Ca4%HgQ}rJP(Ab`bQ-z{U4#0d z2hboi2K@njgb|nm(_szR0JebHusa+GN5aeCM0gdP2N%HG;Yzp`J`T6S7vUT504#-H z!jlL<$Or?`Mpy_N@kBz9SR?@vA#0H$qyni$nvf2p8@Y{0k#Xb$28W?xm>3qu8RLgp zjNxKdVb)?wFx8l2m{v>|<~C*!GlBVnrDD~wrdTJeKXwT=5u1%I#8zOBU|X=4u>;s) z>^mF|$G{ol9B_WP7+f-LHLe7=57&&lfa}8z;U@8Tyei%l?}87(bMRt(A-)QK9Dg3) zj~~XrCy)tR1Z#p1A(kK{Y$Q|=8VKhI{e%(1G*N-5Pjn)N5P8I0VkxnX*g?EW941ba z6iJ387g8iCnY4jaNopcpCOsy-A(P2EWJhusSwLP-t|XrzUnLKcKTwn?CKOLf97RIe zPB}`sKzTrUL#0v;sBY9)s+hW+T2H-1eM)^VN0T#`^Oxhvt&^*fYnAJldnHel*Ozyf zUoM{~Um<@={-*r60#U(0!Bc^wuvVc);k3d%g-J!4qLpHZVwz%!VuRu}#Ze`^l7W)9 z5>Kf>>9Eozr6C$Z)1`URxU@~QI@)F0FdauXr2Es8>BaOP=)Lp_WhG@>R;lZ?BJkMlIuMhw8ApiF&yDYW2hFJ?fJhni{?u z85&g@mo&yT8JcdI$(rSw=QPK(Xj%)k1X|@<=e1rim6`6$RAwc!i#egKuI;BS(LSWz zt39n_sIypSqfWEV6J3%nTQ@-4i zi$R;gsG*9XzhRzXqv2yCs*$VFDx+GXJH|L;wsDH_KI2;^u!)^Xl1YupO;gy^-c(?^ z&$Q1BYvyPsG^;hc$D**@Sy`+`)}T4VJji^bd7Jqw3q6Zii=7tT7GEswEK@D(EFW1Z zSp`^awCb?>!`j4}Yh7b~$A)U-W3$et-R8BesV(1jzwLcHnq9En7Q0Tn&-M=XBKs!$ zF$X<|c!#|X_tWYh)GZit z(Q)Cp9CDE^WG;+fcyOWARoj*0TI>4EP1lX*cEoMO-Pk?Z{kZ!p4@(b`M~lalr<3Oz z&kJ6Nm#vN_+kA5{dW4@^Vjg_`q%qU1ULk& z3Fr!>1V#i_2R;ij2@(Z$1jE4r!MlPVFVbHmT+|iPIq0wy5aS{>yK?9ZAjVh%SOwMWgFjair&;wpi!{CU}&@N=Eg#~ zLQ&zpEzVmGY{hI9Z0+4-0xS$$Xe-OToc?Y*V;rTcf_ zb_jRe-RZjXSeas3UfIyD;9afd%<`i0x4T#DzE)vdabOQ=k7SRuGN`h>O0Q~1)u-yD z>VX=Mn&!Rgd$;YK+Q-}1zu#?t(*cbG#Ronf6db&N$oEidtwC+YVcg-Y!_VuY>bk#Y ze_ww@?MU&F&qswvrN_dLb=5o6*Egs)ls3YRlE$&)amR1{;Ppd$6RYV^Go!iq1UMl% z@#4q$AMc(FJlT1QeX8jv{h#)>&{~RGq1N2iiMFIRX?sk2-|2wUogK~{EkB$8eDsX= znVPf8XG_nK&J~=SIiGia@9y}|z3FhX{g&gcj=lwb=lWgyFW&aLedUh- zof`v-2Kw$UzI*>(+&$@i-u=-BsSjR1%z8NeX#HdC`Hh-Z(6xI-`hmHDqv!v)W&&nrf>M(RhcN6(D;jNN*%^u_SYjF;2ng}*8Ow)d6M ztDk;%`@Lsk$;9w$(d(H%O5UixIr`T2ZRcd@P-1tmx`7GgmmR-zIkHW0AHM5F&G#)4Ro zNG!A?B8ml3FG^4&K|m2jR1`(J6uG_Tff^NvYFPeeLmbCfbBUwCnkb4!{>_)$y@#jR9{|zv-K`RJ{(%Q> z^AB9}UvbGja_@o}SBC8v&<@043Cn!}ydaUYC(h$RTd*B0B4;r?Ma0#^;EP=cy>Sq* zm7GfH*c-vr;wrIib+&!sUBO217WUs|_e4%>M{x%4rHgYu1y{Ti?~HvwHaXDbI@1~!0dP>9a+;}fvX1`9Ea^NwI%-!qVEKL6)t1OuG0wk4u{PL13+C6Qgf8MzzpJQ6dZdiaGYso z-eV>|fV_gcdqkx!H+oHEiW@Cg`5VK%|_0xkh6oTt?YvU$w&j(}@5jRG6M zy+99gJ5Zrjz?Z<@(xExv6wnC_0UBS_6O6P{&7Z~;wj!zs6%S9YB8ca%UeF##>)sbA|K0kn5A~XSQJmehG3n9W8x7Llm!>7Sc+mG~r<$ z1uaA8E|MSNzUJo{ODn?D)5QGd6>)UUtR>FY6n>_Y(=19oU)ER0Omj*L^Qk!`>oCt* zIW`vtwu~5=-p)3;h7UthY&j`bQ*bGm2)@Cz9*mdIQDZMSJ{qnTBDxN&Aa4@T9OZDaEc_Q+J*eJT@DW>n}htka@r?FQ>ov&jt8e+{)k zPpLNJjfFVNHKM3$KU%xmv$hun90iu=1{cza z-3DF)+WB>o`P#*5btLC!WS$`*f4#)8qXO5_3tbq*9~;P_7}`G%9Yy87=1^iXtEaB{ zB8-n_m~YT$gAOqpY<#{wc4}t-!rAT3FgBEZvHixk9p~II0J(LJo~X=PorATc6QU3c zP##VU>3qK|NJAXa+2yV0y&}Ml9`ow&>`08WVAz%L~_5t=`;mxsy zvw2aFzXI78TuXm6@hw3Ipqu?Oq_(%zC3J#MXN=CEJ<#&jiNLR(u}lL0|AI?N*pOKN zst3gJtvhO_ea7a&z?Bu(vQcKv;uq3TGA|}Jld=IdC3`d6oNoN;!0ng2{9Bz}Gk6m> zZTlcOL(#`NpO{vKHYy$e{LO3m9ZpUa+!A>&APjVB$Sx=DIT?sq2W#e>r(%EK$tgzM zNf_P+_C=?hS!DrY7slA)O*&`u=buZjWQpDMBJ%@WrySKnlj(hPwCNU&N%kQ>gyp=H zhY)VEicTm~O&bd4YnO_Z;%D}q$e#sX6+KE#Xi6n`cvdSVWH7Q zw}PcsO8@8~{}eHH1qtev`Nq>j>#Tf6SZMTI8iqj!gZnAdMELbUg`RDyO#ecK#;+|> zlOt2yYEB_uw$7SADySu9iHg++90@cN=YiSWs6PB0gsk>ZjXocq5I!A?dVnK9Q=sC1 z2r7up`TM$G?9ykfh96M#0gAArV7ZEV;q zrDk@OJ>srr+Vx|49RfB}#JSOQ`>n{QzSX8R$&=A-S|>CH*cUbCdIBT=>O(R z72B8t`7W|-XP%LNYI-wOW{|s-HFR*XneE%i&RlD^&WW|D#`bHZ>TqANLMzDkSIH$R zQUTjGe&kDFed< From 17f0e94c29ae430792ab17ad0e616d361c1976c7 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:32:47 -0400 Subject: [PATCH 027/113] ignore generated stuff --- .gitignore | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 42a77883b..7b7042a14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ .ipynb_checkpoints/ -html/ +docs/_build/ runipy-* IPython-* -tutorials/*/_run_* -tutorials/*/*.fits -tutorials/*/*.pdf -tutorials/*/*.png +*.fits +*.pdf +*.png +*.jpg *.pyc +*.tex \ No newline at end of file From 8bf776f0695c3caa683f2931fd6f2b016965838b Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:40:21 -0400 Subject: [PATCH 028/113] rename conesearch tutorial --- docs/tutorials/vo/{conesearch_tutorial.ipynb => conesearch.ipynb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/tutorials/vo/{conesearch_tutorial.ipynb => conesearch.ipynb} (100%) diff --git a/docs/tutorials/vo/conesearch_tutorial.ipynb b/docs/tutorials/vo/conesearch.ipynb similarity index 100% rename from docs/tutorials/vo/conesearch_tutorial.ipynb rename to docs/tutorials/vo/conesearch.ipynb From 052ee89539d30741cde797519c38ac0161dea00c Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 13:40:35 -0400 Subject: [PATCH 029/113] add all tutorials to index --- docs/index.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index e69de29bb..8fd1041c1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -0,0 +1,16 @@ +Astropy Tutorials +================= + +.. toctree:: + :maxdepth: 1 + :glob: + + tutorials/Coordinates/Coordinates.ipynb + tutorials/FITS-header/FITS-header.ipynb + tutorials/FITS-images/FITS-images.ipynb + tutorials/FITS-tables/FITS-tables.ipynb + tutorials/Plot-Catalog/plot-catalog.ipynb + tutorials/Quantities/Quantities.ipynb + tutorials/redshift_plot/redshift_plot.ipynb + tutorials/UVES/UVES.ipynb + tutorials/vo/conesearch.ipynb From a582b0ee3ea8498e6153811c98ee30b7af87eafd Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:24:45 -0400 Subject: [PATCH 030/113] change timeout for nbconvert --- docs/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index bc196ce3b..199d63b7c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -135,5 +135,7 @@ extensions += ['nbsphinx'] extensions += ['IPython.sphinxext.ipython_console_highlighting'] +nbsphinx_timeout = 600 # Time in seconds; use -1 for no timeout + # TODO: remove this when errors in tutorials are updated to be static text nbsphinx_allow_errors = True From 9391a7a3302f4647afb99e38b38f9c8ca98a47db Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:25:14 -0400 Subject: [PATCH 031/113] fix section header level --- docs/tutorials/Quantities/Quantities.ipynb | 202 +++++++++++++++------ 1 file changed, 151 insertions(+), 51 deletions(-) diff --git a/docs/tutorials/Quantities/Quantities.ipynb b/docs/tutorials/Quantities/Quantities.ipynb index 9189221ab..447939d94 100644 --- a/docs/tutorials/Quantities/Quantities.ipynb +++ b/docs/tutorials/Quantities/Quantities.ipynb @@ -33,7 +33,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import numpy as np\n", @@ -62,7 +64,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import astropy.units as u\n", @@ -93,7 +97,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "Reff = 29 * u.pc" @@ -109,7 +115,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "Reff = u.Quantity(29, unit=u.pc)" @@ -125,7 +133,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"\"\"Half light radius\n", @@ -143,7 +153,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"\"\"Half light radius\n", @@ -161,7 +173,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"{0:.3g}\".format(Reff.to(u.m)))" @@ -177,7 +191,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "vmean = 206\n", @@ -188,7 +204,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"\"\"First 10 radial velocity measurements: \n", @@ -199,7 +217,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "plt.figure()\n", @@ -218,7 +238,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sigma = np.sqrt(np.sum((v - np.mean(v))**2) / np.size(v))\n", @@ -235,7 +257,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sigma_scalar = np.sqrt(np.sum((v - np.mean(v))**2) / len(v))" @@ -258,7 +282,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "M = 4*sigma**2*Reff/G\n", @@ -275,7 +301,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "M.decompose()" @@ -291,7 +319,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"\"\"Galaxy mass\n", @@ -310,7 +340,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "np.log10(M / u.Msun)" @@ -326,7 +358,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "np.log10(M)" @@ -351,7 +385,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -365,7 +401,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -379,7 +417,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -414,7 +454,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "d = 250 * u.pc\n", @@ -431,7 +473,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Cloud's center\n", @@ -467,7 +511,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "data = data_gauss * u.K" @@ -483,7 +529,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Average pixel size\n", @@ -508,7 +556,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "intcloud = np.sum(data*dv, axis=2)\n", @@ -525,7 +575,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "#Note that we display RA in the convential way by going from max to min\n", @@ -576,7 +628,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "lambda13 = 2.60076 * u.mm\n", @@ -593,7 +647,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "nu13 = lambda13.to(u.Hz)" @@ -611,7 +667,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "nu13 = lambda13.to(u.Hz, equivalencies=u.spectral())\n", @@ -628,7 +686,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "A13 = 7.4e-8 / u.s\n", @@ -648,7 +708,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "B = h * nu18 / (k_B * Tex)" @@ -664,7 +726,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print('{0}\\n{1}'.format(B, B.decompose()))" @@ -680,7 +744,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "NCO = C * np.sum(data*dv, axis=2) / (1 - np.exp(-B))\n", @@ -705,7 +771,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "H2_CO_ratio = 5.9e6\n", @@ -731,7 +799,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "mH2 = 2 * 1.008 * u.Dalton #aka atomic mass unit/amu\n", @@ -748,7 +818,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "dap = dra * ddec\n", @@ -765,7 +837,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "da = dap * d**2 # don't actually do it this way - use the version below instead!\n", @@ -775,7 +849,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "dap.to(u.steradian).value * d**2" @@ -791,7 +867,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "da.to(u.cm**2)" @@ -807,7 +885,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "da = (dap * d**2).to(u.pc**2, equivalencies=u.dimensionless_angles())\n", @@ -817,7 +897,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "da.to(u.cm**2)" @@ -833,7 +915,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "M = np.sum(rho * da)\n", @@ -857,7 +941,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -871,7 +957,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -879,7 +967,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 3. Using Quantities with Functions" + "## 3. Using Quantities with Functions" ] }, { @@ -899,7 +987,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def response_func(xinarcsec, yinarcsec):\n", @@ -921,7 +1011,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "response_func(1.0, 1.2)" @@ -937,7 +1029,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def response_func(x, y):\n", @@ -959,7 +1053,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "response_func(1.0, 1.2)" @@ -975,7 +1071,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "response_func(1.0*u.arcmin, 1.2*u.arcmin)" @@ -1005,7 +1103,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] } From 284d9ce4a7d5c8f19676c837e5f8ed9177bc8d19 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:37:32 -0400 Subject: [PATCH 032/113] change search region and fix column names --- docs/tutorials/vo/conesearch.ipynb | 33 +++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/tutorials/vo/conesearch.ipynb b/docs/tutorials/vo/conesearch.ipynb index 6bee59fcd..e98126af2 100644 --- a/docs/tutorials/vo/conesearch.ipynb +++ b/docs/tutorials/vo/conesearch.ipynb @@ -159,7 +159,7 @@ "outputs": [], "source": [ "row = result_tab[0]\n", - "simbad_obj = coord.SkyCoord(ra=row['RA']*u.deg, dec=row['DEC']*u.deg)\n", + "simbad_obj = coord.SkyCoord(ra=row['RAJ2000']*u.deg, dec=row['DEJ2000']*u.deg)\n", "print('Searching SIMBAD for\\n{}\\n'.format(simbad_obj))\n", "simbad_result = Simbad.query_region(simbad_obj, radius=5*u.arcsec)\n", "print(simbad_result)" @@ -297,7 +297,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "with warnings.catch_warnings():\n", @@ -387,7 +389,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let's predict the run time of performing Cone Search on `http://gsss.stsci.edu/webservices/vo/ConeSearch.aspx?CAT=GSC23&` with a radius of 0.5 degrees. For now, the prediction assumes a very simple linear model, which might or might not reflect the actual trend.\n", + "Let's predict the run time of performing Cone Search on `http://gsss.stsci.edu/webservices/vo/ConeSearch.aspx?CAT=GSC23&` with a radius of 0.1 degrees. For now, the prediction assumes a very simple linear model, which might or might not reflect the actual trend.\n", "\n", "This might take a while." ] @@ -402,7 +404,7 @@ " warnings.simplefilter('ignore')\n", " t_est, n_est = conesearch.predict_search(\n", " 'http://gsss.stsci.edu/webservices/vo/ConeSearch.aspx?CAT=GSC23&',\n", - " c, 0.5 * u.degree, verbose=False, plot=True)" + " c, 0.1 * u.degree, verbose=False, plot=True)" ] }, { @@ -431,7 +433,7 @@ "outputs": [], "source": [ "t_real, tab = conesearch.conesearch_timer(\n", - " c, 0.5 * u.degree,\n", + " c, 0.1 * u.degree,\n", " catalog_db='http://gsss.stsci.edu/webservices/vo/ConeSearch.aspx?CAT=GSC23&',\n", " verbose=False)" ] @@ -445,6 +447,15 @@ "print('Actual run time is', t_real, 'seconds')\n", "print('Actual number of rows is', tab.nrows)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] } ], "metadata": { @@ -460,6 +471,18 @@ "display_name": "Python [default]", "language": "python", "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" } }, "nbformat": 4, From 0182091ddf4b0eac93b0cfac7d95c3bbc7ef2c9f Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:49:59 -0400 Subject: [PATCH 033/113] change to md so sphinx doesn't collect --- docs/tutorials/vo/{README.rst => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/tutorials/vo/{README.rst => README.md} (100%) diff --git a/docs/tutorials/vo/README.rst b/docs/tutorials/vo/README.md similarity index 100% rename from docs/tutorials/vo/README.rst rename to docs/tutorials/vo/README.md From 570fc0103ef859b4b0dde57cb4d6546629a37d8a Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 22 Sep 2017 14:54:53 -0400 Subject: [PATCH 034/113] try to resolve title level warnings --- docs/tutorials/UVES/UVES.ipynb | 150 ++++++++++++++++++++++++--------- 1 file changed, 112 insertions(+), 38 deletions(-) diff --git a/docs/tutorials/UVES/UVES.ipynb b/docs/tutorials/UVES/UVES.ipynb index 3a2cffbef..2dbd4bbfd 100644 --- a/docs/tutorials/UVES/UVES.ipynb +++ b/docs/tutorials/UVES/UVES.ipynb @@ -81,7 +81,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import tarfile\n", @@ -138,7 +140,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from glob import glob\n", @@ -171,7 +175,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sp = fits.open(filelist[0])\n", @@ -193,7 +199,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "header = sp[0].header\n", @@ -218,7 +226,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "flux = sp[0].data" @@ -282,7 +292,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def read_spec(filename):\n", @@ -335,7 +347,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "help(read_spec)\n", @@ -366,7 +380,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def read_setup(filename):\n", @@ -409,7 +425,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "flux = np.zeros((len(filelist), len(wavelength)))\n", @@ -426,7 +444,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Units and constants in astropy" + "## Units and constants in astropy" ] }, { @@ -449,7 +467,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import astropy.units as u\n", @@ -503,7 +523,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "v_accr = (2.* G * M_MN_Lup/R_MN_Lup)**0.5 \n", @@ -525,7 +547,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "v_rot = vsini / np.sin(incl)\n", @@ -543,7 +567,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "(v_accr / v_rot).decompose()" @@ -579,7 +605,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "wavelength = wavelength * (1. + heliocentric/c)" @@ -601,7 +629,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "wavelength = wavelength * (1. * u.dimensionless_unscaled+ heliocentric/c)" @@ -622,7 +652,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "wavelength.to(u.keV, equivalencies=u.spectral())\n", @@ -663,7 +695,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(np.log10((G*M_MN_Lup/R_MN_Lup**2)/u.cm*u.second**2))" @@ -692,7 +726,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "waveclosetoHa = np.array([6562.,6563,6565.]) * u.AA" @@ -708,7 +744,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# This function uses the Doppler equivalency between wavelength and velocity\n", @@ -745,7 +783,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def w2vsini(wavelength_array, wavelength_line):\n", @@ -756,7 +796,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def w2vsini(w, w0):\n", @@ -789,7 +831,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astropy.time import Time\n", @@ -807,7 +851,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "t1\n", @@ -825,7 +871,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "t1.tt" @@ -841,7 +889,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "obs_times = Time(date, scale = 'utc')\n", @@ -861,7 +911,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "delta_p = delta_t.value * u.day / period" @@ -900,7 +952,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def region_around_line(w, flux, cont):\n", @@ -960,7 +1014,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "ew = fcaII[0,:] - 1.\n", @@ -978,7 +1034,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "delta_lam = np.diff(wcaII.to(u.AA).value)\n", @@ -1000,7 +1058,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astropy.table import Column, Table\n", @@ -1048,7 +1108,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "x = w2vsini(wcaII, 393.366 * u.nm).decompose()" @@ -1064,7 +1126,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# set reasonable figsize for 1-column figures\n", @@ -1106,7 +1170,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "yshift = np.arange((fcaII.shape[0])) * 0.5\n", @@ -1141,7 +1207,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "fmean = np.mean(fcaII, axis=0)\n", @@ -1160,7 +1228,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "fig = plt.figure()\n", @@ -1180,7 +1250,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "ind1 = delta_p < 1 * u.dimensionless_unscaled\n", @@ -1217,7 +1289,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# shift a little for plotting purposes\n", From bcbb8aff0a3cc1d73eff9d1f9c2565dc7fe5d22b Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Wed, 27 Sep 2017 20:55:17 -0400 Subject: [PATCH 035/113] Renaming for consistency --- .../{Coordinates => coordinates}/HCG7_2MASS.tbl | 0 .../HCG7_SDSS_cutout.jpg | Bin .../HCG7_SDSS_photo.dat | 0 .../coordinates.ipynb} | 0 .../{Coordinates => coordinates}/requirements.txt | 0 .../Young-Objects-Compilation.csv | 0 .../plot-catalog.ipynb | 0 .../{Plot-Catalog => plot-catalog}/requirements.txt | 0 .../{Plot-Catalog => plot-catalog}/simple_table.csv | 0 .../quantities.ipynb} | 0 .../{Quantities => quantities}/requirements.txt | 0 .../{redshift_plot => redshift-plot}/ang_dist.png | Bin .../redshift_plot.ipynb | 0 .../requirements.txt | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename docs/tutorials/{Coordinates => coordinates}/HCG7_2MASS.tbl (100%) rename docs/tutorials/{Coordinates => coordinates}/HCG7_SDSS_cutout.jpg (100%) rename docs/tutorials/{Coordinates => coordinates}/HCG7_SDSS_photo.dat (100%) rename docs/tutorials/{Coordinates/Coordinates.ipynb => coordinates/coordinates.ipynb} (100%) rename docs/tutorials/{Coordinates => coordinates}/requirements.txt (100%) rename docs/tutorials/{Plot-Catalog => plot-catalog}/Young-Objects-Compilation.csv (100%) rename docs/tutorials/{Plot-Catalog => plot-catalog}/plot-catalog.ipynb (100%) rename docs/tutorials/{Plot-Catalog => plot-catalog}/requirements.txt (100%) rename docs/tutorials/{Plot-Catalog => plot-catalog}/simple_table.csv (100%) rename docs/tutorials/{Quantities/Quantities.ipynb => quantities/quantities.ipynb} (100%) rename docs/tutorials/{Quantities => quantities}/requirements.txt (100%) rename docs/tutorials/{redshift_plot => redshift-plot}/ang_dist.png (100%) rename docs/tutorials/{redshift_plot => redshift-plot}/redshift_plot.ipynb (100%) rename docs/tutorials/{redshift_plot => redshift-plot}/requirements.txt (100%) diff --git a/docs/tutorials/Coordinates/HCG7_2MASS.tbl b/docs/tutorials/coordinates/HCG7_2MASS.tbl similarity index 100% rename from docs/tutorials/Coordinates/HCG7_2MASS.tbl rename to docs/tutorials/coordinates/HCG7_2MASS.tbl diff --git a/docs/tutorials/Coordinates/HCG7_SDSS_cutout.jpg b/docs/tutorials/coordinates/HCG7_SDSS_cutout.jpg similarity index 100% rename from docs/tutorials/Coordinates/HCG7_SDSS_cutout.jpg rename to docs/tutorials/coordinates/HCG7_SDSS_cutout.jpg diff --git a/docs/tutorials/Coordinates/HCG7_SDSS_photo.dat b/docs/tutorials/coordinates/HCG7_SDSS_photo.dat similarity index 100% rename from docs/tutorials/Coordinates/HCG7_SDSS_photo.dat rename to docs/tutorials/coordinates/HCG7_SDSS_photo.dat diff --git a/docs/tutorials/Coordinates/Coordinates.ipynb b/docs/tutorials/coordinates/coordinates.ipynb similarity index 100% rename from docs/tutorials/Coordinates/Coordinates.ipynb rename to docs/tutorials/coordinates/coordinates.ipynb diff --git a/docs/tutorials/Coordinates/requirements.txt b/docs/tutorials/coordinates/requirements.txt similarity index 100% rename from docs/tutorials/Coordinates/requirements.txt rename to docs/tutorials/coordinates/requirements.txt diff --git a/docs/tutorials/Plot-Catalog/Young-Objects-Compilation.csv b/docs/tutorials/plot-catalog/Young-Objects-Compilation.csv similarity index 100% rename from docs/tutorials/Plot-Catalog/Young-Objects-Compilation.csv rename to docs/tutorials/plot-catalog/Young-Objects-Compilation.csv diff --git a/docs/tutorials/Plot-Catalog/plot-catalog.ipynb b/docs/tutorials/plot-catalog/plot-catalog.ipynb similarity index 100% rename from docs/tutorials/Plot-Catalog/plot-catalog.ipynb rename to docs/tutorials/plot-catalog/plot-catalog.ipynb diff --git a/docs/tutorials/Plot-Catalog/requirements.txt b/docs/tutorials/plot-catalog/requirements.txt similarity index 100% rename from docs/tutorials/Plot-Catalog/requirements.txt rename to docs/tutorials/plot-catalog/requirements.txt diff --git a/docs/tutorials/Plot-Catalog/simple_table.csv b/docs/tutorials/plot-catalog/simple_table.csv similarity index 100% rename from docs/tutorials/Plot-Catalog/simple_table.csv rename to docs/tutorials/plot-catalog/simple_table.csv diff --git a/docs/tutorials/Quantities/Quantities.ipynb b/docs/tutorials/quantities/quantities.ipynb similarity index 100% rename from docs/tutorials/Quantities/Quantities.ipynb rename to docs/tutorials/quantities/quantities.ipynb diff --git a/docs/tutorials/Quantities/requirements.txt b/docs/tutorials/quantities/requirements.txt similarity index 100% rename from docs/tutorials/Quantities/requirements.txt rename to docs/tutorials/quantities/requirements.txt diff --git a/docs/tutorials/redshift_plot/ang_dist.png b/docs/tutorials/redshift-plot/ang_dist.png similarity index 100% rename from docs/tutorials/redshift_plot/ang_dist.png rename to docs/tutorials/redshift-plot/ang_dist.png diff --git a/docs/tutorials/redshift_plot/redshift_plot.ipynb b/docs/tutorials/redshift-plot/redshift_plot.ipynb similarity index 100% rename from docs/tutorials/redshift_plot/redshift_plot.ipynb rename to docs/tutorials/redshift-plot/redshift_plot.ipynb diff --git a/docs/tutorials/redshift_plot/requirements.txt b/docs/tutorials/redshift-plot/requirements.txt similarity index 100% rename from docs/tutorials/redshift_plot/requirements.txt rename to docs/tutorials/redshift-plot/requirements.txt From caf5c445ff842b065287299f6ffb7811ef670bf3 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Wed, 27 Sep 2017 20:56:02 -0400 Subject: [PATCH 036/113] fix links in index --- docs/index.rst | 8 ++++---- .../{redshift_plot.ipynb => redshift-plot.ipynb} | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename docs/tutorials/redshift-plot/{redshift_plot.ipynb => redshift-plot.ipynb} (100%) diff --git a/docs/index.rst b/docs/index.rst index 8fd1041c1..aeab30b1e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,12 +5,12 @@ Astropy Tutorials :maxdepth: 1 :glob: - tutorials/Coordinates/Coordinates.ipynb + tutorials/coordinates/coordinates.ipynb tutorials/FITS-header/FITS-header.ipynb tutorials/FITS-images/FITS-images.ipynb tutorials/FITS-tables/FITS-tables.ipynb - tutorials/Plot-Catalog/plot-catalog.ipynb - tutorials/Quantities/Quantities.ipynb - tutorials/redshift_plot/redshift_plot.ipynb + tutorials/plot-catalog/plot-catalog.ipynb + tutorials/quantities/quantities.ipynb + tutorials/redshift-plot/redshift-plot.ipynb tutorials/UVES/UVES.ipynb tutorials/vo/conesearch.ipynb diff --git a/docs/tutorials/redshift-plot/redshift_plot.ipynb b/docs/tutorials/redshift-plot/redshift-plot.ipynb similarity index 100% rename from docs/tutorials/redshift-plot/redshift_plot.ipynb rename to docs/tutorials/redshift-plot/redshift-plot.ipynb From 9f5710ec06a1eb359401d0689d915e8b50f02a58 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Wed, 27 Sep 2017 21:20:16 -0400 Subject: [PATCH 037/113] add link to tutorials in docs dir --- tutorials | 1 + 1 file changed, 1 insertion(+) create mode 120000 tutorials diff --git a/tutorials b/tutorials new file mode 120000 index 000000000..b27de659d --- /dev/null +++ b/tutorials @@ -0,0 +1 @@ +docs/tutorials/ \ No newline at end of file From 403faa6573b2c087132ed28f906b5f5882401b30 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Mon, 2 Oct 2017 22:21:49 -0400 Subject: [PATCH 038/113] set prompt width to 0 --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index 199d63b7c..2d206cd10 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -136,6 +136,7 @@ extensions += ['IPython.sphinxext.ipython_console_highlighting'] nbsphinx_timeout = 600 # Time in seconds; use -1 for no timeout +nbsphinx_prompt_width = 0 # TODO: remove this when errors in tutorials are updated to be static text nbsphinx_allow_errors = True From abe2dd4472fc5c6a43869d879f4a34f310e4ab34 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Mon, 2 Oct 2017 22:21:59 -0400 Subject: [PATCH 039/113] ah bootstrap file was missing --- ah_bootstrap.py | 987 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 987 insertions(+) create mode 100644 ah_bootstrap.py diff --git a/ah_bootstrap.py b/ah_bootstrap.py new file mode 100644 index 000000000..0dc50071b --- /dev/null +++ b/ah_bootstrap.py @@ -0,0 +1,987 @@ +""" +This bootstrap module contains code for ensuring that the astropy_helpers +package will be importable by the time the setup.py script runs. It also +includes some workarounds to ensure that a recent-enough version of setuptools +is being used for the installation. + +This module should be the first thing imported in the setup.py of distributions +that make use of the utilities in astropy_helpers. If the distribution ships +with its own copy of astropy_helpers, this module will first attempt to import +from the shipped copy. However, it will also check PyPI to see if there are +any bug-fix releases on top of the current version that may be useful to get +past platform-specific bugs that have been fixed. When running setup.py, use +the ``--offline`` command-line option to disable the auto-upgrade checks. + +When this module is imported or otherwise executed it automatically calls a +main function that attempts to read the project's setup.cfg file, which it +checks for a configuration section called ``[ah_bootstrap]`` the presences of +that section, and options therein, determine the next step taken: If it +contains an option called ``auto_use`` with a value of ``True``, it will +automatically call the main function of this module called +`use_astropy_helpers` (see that function's docstring for full details). +Otherwise no further action is taken (however, +``ah_bootstrap.use_astropy_helpers`` may be called manually from within the +setup.py script). + +Additional options in the ``[ah_boostrap]`` section of setup.cfg have the same +names as the arguments to `use_astropy_helpers`, and can be used to configure +the bootstrap script when ``auto_use = True``. + +See https://github.com/astropy/astropy-helpers for more details, and for the +latest version of this module. +""" + +import contextlib +import errno +import imp +import io +import locale +import os +import re +import subprocess as sp +import sys + +try: + from ConfigParser import ConfigParser, RawConfigParser +except ImportError: + from configparser import ConfigParser, RawConfigParser + + +if sys.version_info[0] < 3: + _str_types = (str, unicode) + _text_type = unicode + PY3 = False +else: + _str_types = (str, bytes) + _text_type = str + PY3 = True + + +# What follows are several import statements meant to deal with install-time +# issues with either missing or misbehaving pacakges (including making sure +# setuptools itself is installed): + + +# Some pre-setuptools checks to ensure that either distribute or setuptools >= +# 0.7 is used (over pre-distribute setuptools) if it is available on the path; +# otherwise the latest setuptools will be downloaded and bootstrapped with +# ``ez_setup.py``. This used to be included in a separate file called +# setuptools_bootstrap.py; but it was combined into ah_bootstrap.py +try: + import pkg_resources + _setuptools_req = pkg_resources.Requirement.parse('setuptools>=0.7') + # This may raise a DistributionNotFound in which case no version of + # setuptools or distribute is properly installed + _setuptools = pkg_resources.get_distribution('setuptools') + if _setuptools not in _setuptools_req: + # Older version of setuptools; check if we have distribute; again if + # this results in DistributionNotFound we want to give up + _distribute = pkg_resources.get_distribution('distribute') + if _setuptools != _distribute: + # It's possible on some pathological systems to have an old version + # of setuptools and distribute on sys.path simultaneously; make + # sure distribute is the one that's used + sys.path.insert(1, _distribute.location) + _distribute.activate() + imp.reload(pkg_resources) +except: + # There are several types of exceptions that can occur here; if all else + # fails bootstrap and use the bootstrapped version + from ez_setup import use_setuptools + use_setuptools() + + +# Note: The following import is required as a workaround to +# https://github.com/astropy/astropy-helpers/issues/89; if we don't import this +# module now, it will get cleaned up after `run_setup` is called, but that will +# later cause the TemporaryDirectory class defined in it to stop working when +# used later on by setuptools +try: + import setuptools.py31compat +except ImportError: + pass + + +# matplotlib can cause problems if it is imported from within a call of +# run_setup(), because in some circumstances it will try to write to the user's +# home directory, resulting in a SandboxViolation. See +# https://github.com/matplotlib/matplotlib/pull/4165 +# Making sure matplotlib, if it is available, is imported early in the setup +# process can mitigate this (note importing matplotlib.pyplot has the same +# issue) +try: + import matplotlib + matplotlib.use('Agg') + import matplotlib.pyplot +except: + # Ignore if this fails for *any* reason* + pass + + +# End compatibility imports... + + +# In case it didn't successfully import before the ez_setup checks +import pkg_resources + +from setuptools import Distribution +from setuptools.package_index import PackageIndex +from setuptools.sandbox import run_setup + +from distutils import log +from distutils.debug import DEBUG + + +# TODO: Maybe enable checking for a specific version of astropy_helpers? +DIST_NAME = 'astropy-helpers' +PACKAGE_NAME = 'astropy_helpers' + +# Defaults for other options +DOWNLOAD_IF_NEEDED = True +INDEX_URL = 'https://pypi.python.org/simple' +USE_GIT = True +OFFLINE = False +AUTO_UPGRADE = True + +# A list of all the configuration options and their required types +CFG_OPTIONS = [ + ('auto_use', bool), ('path', str), ('download_if_needed', bool), + ('index_url', str), ('use_git', bool), ('offline', bool), + ('auto_upgrade', bool) +] + + +class _Bootstrapper(object): + """ + Bootstrapper implementation. See ``use_astropy_helpers`` for parameter + documentation. + """ + + def __init__(self, path=None, index_url=None, use_git=None, offline=None, + download_if_needed=None, auto_upgrade=None): + + if path is None: + path = PACKAGE_NAME + + if not (isinstance(path, _str_types) or path is False): + raise TypeError('path must be a string or False') + + if PY3 and not isinstance(path, _text_type): + fs_encoding = sys.getfilesystemencoding() + path = path.decode(fs_encoding) # path to unicode + + self.path = path + + # Set other option attributes, using defaults where necessary + self.index_url = index_url if index_url is not None else INDEX_URL + self.offline = offline if offline is not None else OFFLINE + + # If offline=True, override download and auto-upgrade + if self.offline: + download_if_needed = False + auto_upgrade = False + + self.download = (download_if_needed + if download_if_needed is not None + else DOWNLOAD_IF_NEEDED) + self.auto_upgrade = (auto_upgrade + if auto_upgrade is not None else AUTO_UPGRADE) + + # If this is a release then the .git directory will not exist so we + # should not use git. + git_dir_exists = os.path.exists(os.path.join(os.path.dirname(__file__), '.git')) + if use_git is None and not git_dir_exists: + use_git = False + + self.use_git = use_git if use_git is not None else USE_GIT + # Declared as False by default--later we check if astropy-helpers can be + # upgraded from PyPI, but only if not using a source distribution (as in + # the case of import from a git submodule) + self.is_submodule = False + + @classmethod + def main(cls, argv=None): + if argv is None: + argv = sys.argv + + config = cls.parse_config() + config.update(cls.parse_command_line(argv)) + + auto_use = config.pop('auto_use', False) + bootstrapper = cls(**config) + + if auto_use: + # Run the bootstrapper, otherwise the setup.py is using the old + # use_astropy_helpers() interface, in which case it will run the + # bootstrapper manually after reconfiguring it. + bootstrapper.run() + + return bootstrapper + + @classmethod + def parse_config(cls): + if not os.path.exists('setup.cfg'): + return {} + + cfg = ConfigParser() + + try: + cfg.read('setup.cfg') + except Exception as e: + if DEBUG: + raise + + log.error( + "Error reading setup.cfg: {0!r}\n{1} will not be " + "automatically bootstrapped and package installation may fail." + "\n{2}".format(e, PACKAGE_NAME, _err_help_msg)) + return {} + + if not cfg.has_section('ah_bootstrap'): + return {} + + config = {} + + for option, type_ in CFG_OPTIONS: + if not cfg.has_option('ah_bootstrap', option): + continue + + if type_ is bool: + value = cfg.getboolean('ah_bootstrap', option) + else: + value = cfg.get('ah_bootstrap', option) + + config[option] = value + + return config + + @classmethod + def parse_command_line(cls, argv=None): + if argv is None: + argv = sys.argv + + config = {} + + # For now we just pop recognized ah_bootstrap options out of the + # arg list. This is imperfect; in the unlikely case that a setup.py + # custom command or even custom Distribution class defines an argument + # of the same name then we will break that. However there's a catch22 + # here that we can't just do full argument parsing right here, because + # we don't yet know *how* to parse all possible command-line arguments. + if '--no-git' in argv: + config['use_git'] = False + argv.remove('--no-git') + + if '--offline' in argv: + config['offline'] = True + argv.remove('--offline') + + return config + + def run(self): + strategies = ['local_directory', 'local_file', 'index'] + dist = None + + # First, remove any previously imported versions of astropy_helpers; + # this is necessary for nested installs where one package's installer + # is installing another package via setuptools.sandbox.run_setup, as in + # the case of setup_requires + for key in list(sys.modules): + try: + if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'): + del sys.modules[key] + except AttributeError: + # Sometimes mysterious non-string things can turn up in + # sys.modules + continue + + # Check to see if the path is a submodule + self.is_submodule = self._check_submodule() + + for strategy in strategies: + method = getattr(self, 'get_{0}_dist'.format(strategy)) + dist = method() + if dist is not None: + break + else: + raise _AHBootstrapSystemExit( + "No source found for the {0!r} package; {0} must be " + "available and importable as a prerequisite to building " + "or installing this package.".format(PACKAGE_NAME)) + + # This is a bit hacky, but if astropy_helpers was loaded from a + # directory/submodule its Distribution object gets a "precedence" of + # "DEVELOP_DIST". However, in other cases it gets a precedence of + # "EGG_DIST". However, when activing the distribution it will only be + # placed early on sys.path if it is treated as an EGG_DIST, so always + # do that + dist = dist.clone(precedence=pkg_resources.EGG_DIST) + + # Otherwise we found a version of astropy-helpers, so we're done + # Just active the found distribution on sys.path--if we did a + # download this usually happens automatically but it doesn't hurt to + # do it again + # Note: Adding the dist to the global working set also activates it + # (makes it importable on sys.path) by default. + + try: + pkg_resources.working_set.add(dist, replace=True) + except TypeError: + # Some (much) older versions of setuptools do not have the + # replace=True option here. These versions are old enough that all + # bets may be off anyways, but it's easy enough to work around just + # in case... + if dist.key in pkg_resources.working_set.by_key: + del pkg_resources.working_set.by_key[dist.key] + pkg_resources.working_set.add(dist) + + @property + def config(self): + """ + A `dict` containing the options this `_Bootstrapper` was configured + with. + """ + + return dict((optname, getattr(self, optname)) + for optname, _ in CFG_OPTIONS if hasattr(self, optname)) + + def get_local_directory_dist(self): + """ + Handle importing a vendored package from a subdirectory of the source + distribution. + """ + + if not os.path.isdir(self.path): + return + + log.info('Attempting to import astropy_helpers from {0} {1!r}'.format( + 'submodule' if self.is_submodule else 'directory', + self.path)) + + dist = self._directory_import() + + if dist is None: + log.warn( + 'The requested path {0!r} for importing {1} does not ' + 'exist, or does not contain a copy of the {1} ' + 'package.'.format(self.path, PACKAGE_NAME)) + elif self.auto_upgrade and not self.is_submodule: + # A version of astropy-helpers was found on the available path, but + # check to see if a bugfix release is available on PyPI + upgrade = self._do_upgrade(dist) + if upgrade is not None: + dist = upgrade + + return dist + + def get_local_file_dist(self): + """ + Handle importing from a source archive; this also uses setup_requires + but points easy_install directly to the source archive. + """ + + if not os.path.isfile(self.path): + return + + log.info('Attempting to unpack and import astropy_helpers from ' + '{0!r}'.format(self.path)) + + try: + dist = self._do_download(find_links=[self.path]) + except Exception as e: + if DEBUG: + raise + + log.warn( + 'Failed to import {0} from the specified archive {1!r}: ' + '{2}'.format(PACKAGE_NAME, self.path, str(e))) + dist = None + + if dist is not None and self.auto_upgrade: + # A version of astropy-helpers was found on the available path, but + # check to see if a bugfix release is available on PyPI + upgrade = self._do_upgrade(dist) + if upgrade is not None: + dist = upgrade + + return dist + + def get_index_dist(self): + if not self.download: + log.warn('Downloading {0!r} disabled.'.format(DIST_NAME)) + return None + + log.warn( + "Downloading {0!r}; run setup.py with the --offline option to " + "force offline installation.".format(DIST_NAME)) + + try: + dist = self._do_download() + except Exception as e: + if DEBUG: + raise + log.warn( + 'Failed to download and/or install {0!r} from {1!r}:\n' + '{2}'.format(DIST_NAME, self.index_url, str(e))) + dist = None + + # No need to run auto-upgrade here since we've already presumably + # gotten the most up-to-date version from the package index + return dist + + def _directory_import(self): + """ + Import astropy_helpers from the given path, which will be added to + sys.path. + + Must return True if the import succeeded, and False otherwise. + """ + + # Return True on success, False on failure but download is allowed, and + # otherwise raise SystemExit + path = os.path.abspath(self.path) + + # Use an empty WorkingSet rather than the man + # pkg_resources.working_set, since on older versions of setuptools this + # will invoke a VersionConflict when trying to install an upgrade + ws = pkg_resources.WorkingSet([]) + ws.add_entry(path) + dist = ws.by_key.get(DIST_NAME) + + if dist is None: + # We didn't find an egg-info/dist-info in the given path, but if a + # setup.py exists we can generate it + setup_py = os.path.join(path, 'setup.py') + if os.path.isfile(setup_py): + with _silence(): + run_setup(os.path.join(path, 'setup.py'), + ['egg_info']) + + for dist in pkg_resources.find_distributions(path, True): + # There should be only one... + return dist + + return dist + + def _do_download(self, version='', find_links=None): + if find_links: + allow_hosts = '' + index_url = None + else: + allow_hosts = None + index_url = self.index_url + + # Annoyingly, setuptools will not handle other arguments to + # Distribution (such as options) before handling setup_requires, so it + # is not straightforward to programmatically augment the arguments which + # are passed to easy_install + class _Distribution(Distribution): + def get_option_dict(self, command_name): + opts = Distribution.get_option_dict(self, command_name) + if command_name == 'easy_install': + if find_links is not None: + opts['find_links'] = ('setup script', find_links) + if index_url is not None: + opts['index_url'] = ('setup script', index_url) + if allow_hosts is not None: + opts['allow_hosts'] = ('setup script', allow_hosts) + return opts + + if version: + req = '{0}=={1}'.format(DIST_NAME, version) + else: + req = DIST_NAME + + attrs = {'setup_requires': [req]} + + try: + if DEBUG: + _Distribution(attrs=attrs) + else: + with _silence(): + _Distribution(attrs=attrs) + + # If the setup_requires succeeded it will have added the new dist to + # the main working_set + return pkg_resources.working_set.by_key.get(DIST_NAME) + except Exception as e: + if DEBUG: + raise + + msg = 'Error retrieving {0} from {1}:\n{2}' + if find_links: + source = find_links[0] + elif index_url != INDEX_URL: + source = index_url + else: + source = 'PyPI' + + raise Exception(msg.format(DIST_NAME, source, repr(e))) + + def _do_upgrade(self, dist): + # Build up a requirement for a higher bugfix release but a lower minor + # release (so API compatibility is guaranteed) + next_version = _next_version(dist.parsed_version) + + req = pkg_resources.Requirement.parse( + '{0}>{1},<{2}'.format(DIST_NAME, dist.version, next_version)) + + package_index = PackageIndex(index_url=self.index_url) + + upgrade = package_index.obtain(req) + + if upgrade is not None: + return self._do_download(version=upgrade.version) + + def _check_submodule(self): + """ + Check if the given path is a git submodule. + + See the docstrings for ``_check_submodule_using_git`` and + ``_check_submodule_no_git`` for further details. + """ + + if (self.path is None or + (os.path.exists(self.path) and not os.path.isdir(self.path))): + return False + + if self.use_git: + return self._check_submodule_using_git() + else: + return self._check_submodule_no_git() + + def _check_submodule_using_git(self): + """ + Check if the given path is a git submodule. If so, attempt to initialize + and/or update the submodule if needed. + + This function makes calls to the ``git`` command in subprocesses. The + ``_check_submodule_no_git`` option uses pure Python to check if the given + path looks like a git submodule, but it cannot perform updates. + """ + + cmd = ['git', 'submodule', 'status', '--', self.path] + + try: + log.info('Running `{0}`; use the --no-git option to disable git ' + 'commands'.format(' '.join(cmd))) + returncode, stdout, stderr = run_cmd(cmd) + except _CommandNotFound: + # The git command simply wasn't found; this is most likely the + # case on user systems that don't have git and are simply + # trying to install the package from PyPI or a source + # distribution. Silently ignore this case and simply don't try + # to use submodules + return False + + stderr = stderr.strip() + + if returncode != 0 and stderr: + # Unfortunately the return code alone cannot be relied on, as + # earlier versions of git returned 0 even if the requested submodule + # does not exist + + # This is a warning that occurs in perl (from running git submodule) + # which only occurs with a malformatted locale setting which can + # happen sometimes on OSX. See again + # https://github.com/astropy/astropy/issues/2749 + perl_warning = ('perl: warning: Falling back to the standard locale ' + '("C").') + if not stderr.strip().endswith(perl_warning): + # Some other unknown error condition occurred + log.warn('git submodule command failed ' + 'unexpectedly:\n{0}'.format(stderr)) + return False + + # Output of `git submodule status` is as follows: + # + # 1: Status indicator: '-' for submodule is uninitialized, '+' if + # submodule is initialized but is not at the commit currently indicated + # in .gitmodules (and thus needs to be updated), or 'U' if the + # submodule is in an unstable state (i.e. has merge conflicts) + # + # 2. SHA-1 hash of the current commit of the submodule (we don't really + # need this information but it's useful for checking that the output is + # correct) + # + # 3. The output of `git describe` for the submodule's current commit + # hash (this includes for example what branches the commit is on) but + # only if the submodule is initialized. We ignore this information for + # now + _git_submodule_status_re = re.compile( + '^(?P[+-U ])(?P[0-9a-f]{40}) ' + '(?P\S+)( .*)?$') + + # The stdout should only contain one line--the status of the + # requested submodule + m = _git_submodule_status_re.match(stdout) + if m: + # Yes, the path *is* a git submodule + self._update_submodule(m.group('submodule'), m.group('status')) + return True + else: + log.warn( + 'Unexpected output from `git submodule status`:\n{0}\n' + 'Will attempt import from {1!r} regardless.'.format( + stdout, self.path)) + return False + + def _check_submodule_no_git(self): + """ + Like ``_check_submodule_using_git``, but simply parses the .gitmodules file + to determine if the supplied path is a git submodule, and does not exec any + subprocesses. + + This can only determine if a path is a submodule--it does not perform + updates, etc. This function may need to be updated if the format of the + .gitmodules file is changed between git versions. + """ + + gitmodules_path = os.path.abspath('.gitmodules') + + if not os.path.isfile(gitmodules_path): + return False + + # This is a minimal reader for gitconfig-style files. It handles a few of + # the quirks that make gitconfig files incompatible with ConfigParser-style + # files, but does not support the full gitconfig syntax (just enough + # needed to read a .gitmodules file). + gitmodules_fileobj = io.StringIO() + + # Must use io.open for cross-Python-compatible behavior wrt unicode + with io.open(gitmodules_path) as f: + for line in f: + # gitconfig files are more flexible with leading whitespace; just + # go ahead and remove it + line = line.lstrip() + + # comments can start with either # or ; + if line and line[0] in (':', ';'): + continue + + gitmodules_fileobj.write(line) + + gitmodules_fileobj.seek(0) + + cfg = RawConfigParser() + + try: + cfg.readfp(gitmodules_fileobj) + except Exception as exc: + log.warn('Malformatted .gitmodules file: {0}\n' + '{1} cannot be assumed to be a git submodule.'.format( + exc, self.path)) + return False + + for section in cfg.sections(): + if not cfg.has_option(section, 'path'): + continue + + submodule_path = cfg.get(section, 'path').rstrip(os.sep) + + if submodule_path == self.path.rstrip(os.sep): + return True + + return False + + def _update_submodule(self, submodule, status): + if status == ' ': + # The submodule is up to date; no action necessary + return + elif status == '-': + if self.offline: + raise _AHBootstrapSystemExit( + "Cannot initialize the {0} submodule in --offline mode; " + "this requires being able to clone the submodule from an " + "online repository.".format(submodule)) + cmd = ['update', '--init'] + action = 'Initializing' + elif status == '+': + cmd = ['update'] + action = 'Updating' + if self.offline: + cmd.append('--no-fetch') + elif status == 'U': + raise _AHBoostrapSystemExit( + 'Error: Submodule {0} contains unresolved merge conflicts. ' + 'Please complete or abandon any changes in the submodule so that ' + 'it is in a usable state, then try again.'.format(submodule)) + else: + log.warn('Unknown status {0!r} for git submodule {1!r}. Will ' + 'attempt to use the submodule as-is, but try to ensure ' + 'that the submodule is in a clean state and contains no ' + 'conflicts or errors.\n{2}'.format(status, submodule, + _err_help_msg)) + return + + err_msg = None + cmd = ['git', 'submodule'] + cmd + ['--', submodule] + log.warn('{0} {1} submodule with: `{2}`'.format( + action, submodule, ' '.join(cmd))) + + try: + log.info('Running `{0}`; use the --no-git option to disable git ' + 'commands'.format(' '.join(cmd))) + returncode, stdout, stderr = run_cmd(cmd) + except OSError as e: + err_msg = str(e) + else: + if returncode != 0: + err_msg = stderr + + if err_msg is not None: + log.warn('An unexpected error occurred updating the git submodule ' + '{0!r}:\n{1}\n{2}'.format(submodule, err_msg, + _err_help_msg)) + +class _CommandNotFound(OSError): + """ + An exception raised when a command run with run_cmd is not found on the + system. + """ + + +def run_cmd(cmd): + """ + Run a command in a subprocess, given as a list of command-line + arguments. + + Returns a ``(returncode, stdout, stderr)`` tuple. + """ + + try: + p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE) + # XXX: May block if either stdout or stderr fill their buffers; + # however for the commands this is currently used for that is + # unlikely (they should have very brief output) + stdout, stderr = p.communicate() + except OSError as e: + if DEBUG: + raise + + if e.errno == errno.ENOENT: + msg = 'Command not found: `{0}`'.format(' '.join(cmd)) + raise _CommandNotFound(msg, cmd) + else: + raise _AHBoostrapSystemExit( + 'An unexpected error occurred when running the ' + '`{0}` command:\n{1}'.format(' '.join(cmd), str(e))) + + + # Can fail of the default locale is not configured properly. See + # https://github.com/astropy/astropy/issues/2749. For the purposes under + # consideration 'latin1' is an acceptable fallback. + try: + stdio_encoding = locale.getdefaultlocale()[1] or 'latin1' + except ValueError: + # Due to an OSX oddity locale.getdefaultlocale() can also crash + # depending on the user's locale/language settings. See: + # http://bugs.python.org/issue18378 + stdio_encoding = 'latin1' + + # Unlikely to fail at this point but even then let's be flexible + if not isinstance(stdout, _text_type): + stdout = stdout.decode(stdio_encoding, 'replace') + if not isinstance(stderr, _text_type): + stderr = stderr.decode(stdio_encoding, 'replace') + + return (p.returncode, stdout, stderr) + + +def _next_version(version): + """ + Given a parsed version from pkg_resources.parse_version, returns a new + version string with the next minor version. + + Examples + ======== + >>> _next_version(pkg_resources.parse_version('1.2.3')) + '1.3.0' + """ + + if hasattr(version, 'base_version'): + # New version parsing from setuptools >= 8.0 + if version.base_version: + parts = version.base_version.split('.') + else: + parts = [] + else: + parts = [] + for part in version: + if part.startswith('*'): + break + parts.append(part) + + parts = [int(p) for p in parts] + + if len(parts) < 3: + parts += [0] * (3 - len(parts)) + + major, minor, micro = parts[:3] + + return '{0}.{1}.{2}'.format(major, minor + 1, 0) + + +class _DummyFile(object): + """A noop writeable object.""" + + errors = '' # Required for Python 3.x + encoding = 'utf-8' + + def write(self, s): + pass + + def flush(self): + pass + + +@contextlib.contextmanager +def _silence(): + """A context manager that silences sys.stdout and sys.stderr.""" + + old_stdout = sys.stdout + old_stderr = sys.stderr + sys.stdout = _DummyFile() + sys.stderr = _DummyFile() + exception_occurred = False + try: + yield + except: + exception_occurred = True + # Go ahead and clean up so that exception handling can work normally + sys.stdout = old_stdout + sys.stderr = old_stderr + raise + + if not exception_occurred: + sys.stdout = old_stdout + sys.stderr = old_stderr + + +_err_help_msg = """ +If the problem persists consider installing astropy_helpers manually using pip +(`pip install astropy_helpers`) or by manually downloading the source archive, +extracting it, and installing by running `python setup.py install` from the +root of the extracted source code. +""" + + +class _AHBootstrapSystemExit(SystemExit): + def __init__(self, *args): + if not args: + msg = 'An unknown problem occurred bootstrapping astropy_helpers.' + else: + msg = args[0] + + msg += '\n' + _err_help_msg + + super(_AHBootstrapSystemExit, self).__init__(msg, *args[1:]) + + +if sys.version_info[:2] < (2, 7): + # In Python 2.6 the distutils log does not log warnings, errors, etc. to + # stderr so we have to wrap it to ensure consistency at least in this + # module + import distutils + + class log(object): + def __getattr__(self, attr): + return getattr(distutils.log, attr) + + def warn(self, msg, *args): + self._log_to_stderr(distutils.log.WARN, msg, *args) + + def error(self, msg): + self._log_to_stderr(distutils.log.ERROR, msg, *args) + + def fatal(self, msg): + self._log_to_stderr(distutils.log.FATAL, msg, *args) + + def log(self, level, msg, *args): + if level in (distutils.log.WARN, distutils.log.ERROR, + distutils.log.FATAL): + self._log_to_stderr(level, msg, *args) + else: + distutils.log.log(level, msg, *args) + + def _log_to_stderr(self, level, msg, *args): + # This is the only truly 'public' way to get the current threshold + # of the log + current_threshold = distutils.log.set_threshold(distutils.log.WARN) + distutils.log.set_threshold(current_threshold) + if level >= current_threshold: + if args: + msg = msg % args + sys.stderr.write('%s\n' % msg) + sys.stderr.flush() + + log = log() + + +BOOTSTRAPPER = _Bootstrapper.main() + + +def use_astropy_helpers(**kwargs): + """ + Ensure that the `astropy_helpers` module is available and is importable. + This supports automatic submodule initialization if astropy_helpers is + included in a project as a git submodule, or will download it from PyPI if + necessary. + + Parameters + ---------- + + path : str or None, optional + A filesystem path relative to the root of the project's source code + that should be added to `sys.path` so that `astropy_helpers` can be + imported from that path. + + If the path is a git submodule it will automatically be initialized + and/or updated. + + The path may also be to a ``.tar.gz`` archive of the astropy_helpers + source distribution. In this case the archive is automatically + unpacked and made temporarily available on `sys.path` as a ``.egg`` + archive. + + If `None` skip straight to downloading. + + download_if_needed : bool, optional + If the provided filesystem path is not found an attempt will be made to + download astropy_helpers from PyPI. It will then be made temporarily + available on `sys.path` as a ``.egg`` archive (using the + ``setup_requires`` feature of setuptools. If the ``--offline`` option + is given at the command line the value of this argument is overridden + to `False`. + + index_url : str, optional + If provided, use a different URL for the Python package index than the + main PyPI server. + + use_git : bool, optional + If `False` no git commands will be used--this effectively disables + support for git submodules. If the ``--no-git`` option is given at the + command line the value of this argument is overridden to `False`. + + auto_upgrade : bool, optional + By default, when installing a package from a non-development source + distribution ah_boostrap will try to automatically check for patch + releases to astropy-helpers on PyPI and use the patched version over + any bundled versions. Setting this to `False` will disable that + functionality. If the ``--offline`` option is given at the command line + the value of this argument is overridden to `False`. + + offline : bool, optional + If `False` disable all actions that require an internet connection, + including downloading packages from the package index and fetching + updates to any git submodule. Defaults to `True`. + """ + + global BOOTSTRAPPER + + config = BOOTSTRAPPER.config + config.update(**kwargs) + + # Create a new bootstrapper with the updated configuration and run it + BOOTSTRAPPER = _Bootstrapper(**config) + BOOTSTRAPPER.run() From 74c7a6cb06ebdf27b13147687fe3a30719579f7b Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Mon, 9 Oct 2017 20:32:01 -0400 Subject: [PATCH 040/113] the most hacky of hacks to monkey-patch the RST template hard-coded in nbsphinx --- docs/_static/astropy.tpl | 203 +++++++++++++++++++++++++++++++++++++++ docs/conf.py | 6 ++ 2 files changed, 209 insertions(+) create mode 100644 docs/_static/astropy.tpl diff --git a/docs/_static/astropy.tpl b/docs/_static/astropy.tpl new file mode 100644 index 000000000..aedb23e4f --- /dev/null +++ b/docs/_static/astropy.tpl @@ -0,0 +1,203 @@ + +{% extends 'rst.tpl' %} + + +{% macro insert_empty_lines(text) %} +{%- set before, after = text | get_empty_lines %} +{%- if before %} + :empty-lines-before: {{ before }} +{%- endif %} +{%- if after %} + :empty-lines-after: {{ after }} +{%- endif %} +{%- endmacro %} + + +{% block any_cell %} +{%- if cell.metadata.nbsphinx != 'hidden' %} +{{ super() }} +{% endif %} +{%- endblock any_cell %} + + +{% block input -%} +.. nbinput:: {% if cell.metadata.magics_language -%} +{{ cell.metadata.magics_language }} +{%- elif nb.metadata.language_info -%} +{{ nb.metadata.language_info.pygments_lexer or nb.metadata.language_info.name }} +{%- else -%} +{{ resources.codecell_lexer }} +{%- endif -%} +{{ insert_empty_lines(cell.source) }} +{%- if cell.execution_count %} + :execution-count: {{ cell.execution_count }} +{%- endif %} +{%- if not cell.outputs %} + :no-output: +{%- endif %} +{%- if cell.source.strip() %} + +{{ cell.source.strip(' +') | indent }} +{%- endif %} +{% endblock input %} + + +{% macro insert_nboutput(datatype, output, cell) -%} +.. nboutput:: +{%- if datatype == 'text/plain' %}{# nothing #} +{%- else %} rst +{%- endif %} +{%- if output.output_type == 'execute_result' and cell.execution_count %} + :execution-count: {{ cell.execution_count }} +{%- endif %} +{%- if output != cell.outputs[-1] %} + :more-to-come: +{%- endif %} +{%- if output.name == 'stderr' %} + :class: stderr +{%- endif %} +{%- if datatype == 'text/plain' -%} +{{ insert_empty_lines(output.data[datatype]) }} + +{{ output.data[datatype].strip( +) | indent }} +{%- elif datatype in ['image/svg+xml', 'image/png', 'image/jpeg', 'application/pdf'] %} + + .. image:: {{ output.metadata.filenames[datatype] | posix_path }} +{%- elif datatype in ['text/markdown'] %} + +{{ output.data['text/markdown'] | markdown2rst | indent }} +{%- elif datatype in ['text/latex'] %} + + .. math:: + :nowrap: + +{{ output.data['text/latex'] | indent | indent }} +{%- elif datatype == 'text/html' %} + + .. raw:: html + +{{ output.data['text/html'] | indent | indent }} +{%- elif datatype == 'application/javascript' %} +{% set div_id = uuid4() %} + + .. raw:: html + +
+ +{%- elif datatype.startswith('application') and datatype.endswith('+json') %} + + .. raw:: html + + +{%- elif datatype == 'ansi' %} + + .. rst-class:: highlight + + .. raw:: html + +
+{{ output.data[datatype] | ansi2html | indent | indent }}
+        
+ + .. raw:: latex + + % + \begin{OriginalVerbatim}[commandchars=\\\{\}] +{{ output.data[datatype] | ansi2latex | indent | indent }} + \end{OriginalVerbatim} + % The following \relax is needed to avoid problems with adjacent ANSI + % cells and some other stuff (e.g. bullet lists) following ANSI cells. + % See https://github.com/sphinx-doc/sphinx/issues/3594 + \relax +{% else %} + + .. nbwarning:: Data type cannot be displayed: {{ datatype }} +{%- endif %} +{% endmacro %} + + +{% block nboutput -%} +{%- set html_datatype, latex_datatype = output | get_output_type %} +{%- if html_datatype == latex_datatype %} +{{ insert_nboutput(html_datatype, output, cell) }} +{%- else %} +.. only:: html + +{{ insert_nboutput(html_datatype, output, cell) | indent }} +.. only:: latex + +{{ insert_nboutput(latex_datatype, output, cell) | indent }} +{%- endif %} +{% endblock nboutput %} + + +{% block execute_result %}{{ self.nboutput() }}{% endblock execute_result %} +{% block display_data %}{{ self.nboutput() }}{% endblock display_data %} +{% block stream %}{{ self.nboutput() }}{% endblock stream %} +{% block error %}{{ self.nboutput() }}{% endblock error %} + + +{% block markdowncell %} +{%- if 'nbsphinx-toctree' in cell.metadata %} +{{ cell | extract_toctree }} +{%- else %} +{{ super() }} +{% endif %} +{% endblock markdowncell %} + + +{% block rawcell %} +{%- set raw_mimetype = cell.metadata.get('raw_mimetype', '').lower() %} +{%- if raw_mimetype == '' %} +.. raw:: html + +{{ cell.source | indent }} + +.. raw:: latex + + % +{{ cell.source | indent }} +{%- elif raw_mimetype == 'text/html' %} +.. raw:: html + +{{ cell.source | indent }} +{%- elif raw_mimetype == 'text/latex' %} +.. raw:: latex + + % +{{ cell.source | indent }} +{%- elif raw_mimetype == 'text/markdown' %} +{{ cell.source | markdown2rst }} +{%- elif raw_mimetype == 'text/restructuredtext' %} +{{ cell.source }} +{% endif %} +{% endblock rawcell %} + + +{% block footer %} + +{% if 'application/vnd.jupyter.widget-state+json' in nb.metadata.widgets %} + +.. raw:: html + + +{% endif %} + +{# This is where the custom astropy-tutorials stuff begins: #} +.. raw:: html + +
+ +{% set base_url = "https://github.com/astropy/astropy-tutorials/tree/master" %} +{% set nb_name = "{0}.ipynb".format("_".join(resources.unique_key.split('_')[2:])) %} +{{ "/".join([base_url] + resources.unique_key.split('_')[:2] + [nb_name]) }} + +{{ super() }} +{% endblock footer %} diff --git a/docs/conf.py b/docs/conf.py index 2d206cd10..302f1bd8a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,6 +6,7 @@ import datetime import os import sys +from os import path try: import astropy_helpers @@ -140,3 +141,8 @@ # TODO: remove this when errors in tutorials are updated to be static text nbsphinx_allow_errors = True + +import nbsphinx + +with open(path.join(path.dirname(__file__), '_static', 'astropy.tpl'), 'r') as f: + nbsphinx.RST_TEMPLATE = f.read() From c58695435de2370eb3bdd943a9278f0edd2cffb4 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Mon, 9 Oct 2017 20:39:35 -0400 Subject: [PATCH 041/113] added a link --- docs/_static/astropy.tpl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/_static/astropy.tpl b/docs/_static/astropy.tpl index aedb23e4f..9859341ec 100644 --- a/docs/_static/astropy.tpl +++ b/docs/_static/astropy.tpl @@ -190,14 +190,15 @@ {% endif %} -{# This is where the custom astropy-tutorials stuff begins: #} +{# This is where the custom astropy-tutorials modifications begin: #} +{% set base_url = "https://github.com/astropy/astropy-tutorials/tree/master" %} +{% set nb_name = "{0}.ipynb".format("_".join(resources.unique_key.split('_')[2:])) %} +{% set nb_url = "/".join([base_url] + resources.unique_key.split('_')[:2] + [nb_name]) %} + .. raw:: html
- -{% set base_url = "https://github.com/astropy/astropy-tutorials/tree/master" %} -{% set nb_name = "{0}.ipynb".format("_".join(resources.unique_key.split('_')[2:])) %} -{{ "/".join([base_url] + resources.unique_key.split('_')[:2] + [nb_name]) }} +

Source notebook

{{ super() }} {% endblock footer %} From bd3da1d0d8d3c46b2675288d4813be1bbec4b1f2 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Mon, 9 Oct 2017 20:58:20 -0400 Subject: [PATCH 042/113] fix css, link, and conf --- docs/_static/astropy.tpl | 4 ++-- docs/conf.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/_static/astropy.tpl b/docs/_static/astropy.tpl index 9859341ec..b6a598636 100644 --- a/docs/_static/astropy.tpl +++ b/docs/_static/astropy.tpl @@ -191,13 +191,13 @@ {% endif %} {# This is where the custom astropy-tutorials modifications begin: #} -{% set base_url = "https://github.com/astropy/astropy-tutorials/tree/master" %} +{% set base_url = "https://github.com/astropy/astropy-tutorials/tree/master/docs/" %} {% set nb_name = "{0}.ipynb".format("_".join(resources.unique_key.split('_')[2:])) %} {% set nb_url = "/".join([base_url] + resources.unique_key.split('_')[:2] + [nb_name]) %} .. raw:: html -
+

Source notebook

{{ super() }} diff --git a/docs/conf.py b/docs/conf.py index 302f1bd8a..bd513c6f7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -133,8 +133,8 @@ github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) # We require nbsphinx -extensions += ['nbsphinx'] -extensions += ['IPython.sphinxext.ipython_console_highlighting'] +extensions.append('nbsphinx') +extensions.append('IPython.sphinxext.ipython_console_highlighting') nbsphinx_timeout = 600 # Time in seconds; use -1 for no timeout nbsphinx_prompt_width = 0 From f400ab144b3652e976e79ed34c708e3e9506ebc4 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Mon, 9 Oct 2017 21:07:34 -0400 Subject: [PATCH 043/113] fix astropy-helpers url --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index aca5d4a73..6a20fa6e5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "astropy_helpers"] path = astropy_helpers - url = git@github.com:astropy/astropy-helpers + url = https://github.com/astropy/astropy-helpers.git From 2d1a2f1ee8bf1cf82d8bf7ff8c8116f60d9a1ee7 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 10 Oct 2017 09:06:30 -0400 Subject: [PATCH 044/113] modify deploy script --- deploy | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/deploy b/deploy index f9844faad..196a3b522 100755 --- a/deploy +++ b/deploy @@ -12,8 +12,8 @@ : ${INTERACTIVE=true} : ${CURRENT_BRANCH_NAME="$(git symbolic-ref --quiet --short HEAD)"} -if [ -z "$CURRENT_BRANCH_NAME" ]; then - echo "Could not determine current branch. Cannot continue with deployment." +if [ -z "$CURRENT_BRANCH_NAME" ]; then + echo "Could not determine current branch. Cannot continue with deployment." exit 1 fi @@ -23,13 +23,13 @@ giveup_message () { echo "To get back to normal you can run the following:" echo " git checkout -f $CURRENT_BRANCH_NAME" echo " git clean -f" - echo " git branch -D $GH_PAGESBRANCH" + echo " git branch -D $GH_PAGESBRANCH" } promptifinteractive () { # first argument is message, second is non-interactive answer, all others passed to read if [ "$INTERACTIVE" = true ] ; then - read -p "$1" -r "${@:3}" + read -p "$1" -r "${@:3}" else echo $1 $2 REPLY=$2 @@ -49,21 +49,13 @@ echo if [[ $REPLY =~ ^[Yy]$ ]] then # first run the notebooks - OUTPUT=`python prepare_deploy.py run` + OUTPUT=`python setup.py build_sphinx` if [[ $OUTPUT == *ERROR* ]] then echo "Error running notebook files!"; exit; fi - # then convert the notebooks to HTML - OUTPUT=`python prepare_deploy.py convert` - if [[ $OUTPUT == *ERROR* ]] - then - echo "Error converting notebook files to HTML!"; - exit; - fi - # remove the old $GH_PAGESBRANCH branch OUTPUT=`git branch -D $GH_PAGESBRANCH` if [[ $OUTPUT == *fatal* ]] @@ -77,7 +69,7 @@ then git checkout --orphan $GH_PAGESBRANCH # Copy the built files to a tmp location - cp -R html _tmp + cp -R docs/_build/html _tmp # This will delete all of the git-managed files here git rm -rf . @@ -86,9 +78,7 @@ then cp -R _tmp/* . rm -rf _tmp - git add *.html - git add images - git add css + git add * git commit -m "Generated from sources" promptifinteractive "Would you like to preview the rendered HTML? [y/N] " N -n 1 @@ -109,7 +99,7 @@ then promptifinteractive "Could not communicate with remote '$GH_REMOTE'. Enter an alternate remote name (or 'quit' to give up):" quit if [[ $REPLY = "quit" ]]; then giveup_message - exit + exit fi GH_REMOTE=$REPLY From a7a44781f872851200e38bd25a96f19a234adbed Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 10 Oct 2017 09:08:01 -0400 Subject: [PATCH 045/113] no longer need prepare deploy script --- prepare_deploy.py | 203 ---------------------------------------------- 1 file changed, 203 deletions(-) delete mode 100644 prepare_deploy.py diff --git a/prepare_deploy.py b/prepare_deploy.py deleted file mode 100644 index 3b79a163b..000000000 --- a/prepare_deploy.py +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -""" Build all notebook files into HTML pages. """ - -from __future__ import division, print_function - -# Standard library -import os -import re -import sys -import shutil -import check_env - -# protect for 2.* vs. 3.* -try: - import configparser - cp = configparser -except ImportError: - import ConfigParser - cp = ConfigParser - -from astropy import log as logger -from IPython.nbformat.current import read, write - -# A template for the index page -with open("templates/index_template.html") as f: - INDEX_TEMPLATE = f.read() - -def walk_through_tutorials(only_published=True, selected_nb_re=None): - """ Generator for walking through the tutorials directory structure. - This returns tuples of (full_tutorial_path, tutorial_name) for - each tutorial. If published is set to True, this will only return - the published tutorials. - """ - nbre = re.compile(selected_nb_re) if selected_nb_re else None - - current_directory = os.getcwd() - tutorials_base = os.path.join(current_directory,'tutorials') - - if not os.path.exists(tutorials_base): - err = ("Can't find 'tutorials' path! You must run this script from the" - " top-level astropy-tutorials directory.") - raise IOError(err) - - # walk through each directory in tutorials/ to find all .ipynb file - for tutorial_name in os.listdir(tutorials_base): - tutorial_path = os.path.join(tutorials_base, tutorial_name) - if not os.path.isdir(tutorial_path): - # skip files / things that are not directories - continue - - for filename in os.listdir(tutorial_path): - base,ext = os.path.splitext(filename) - - if ext.lower() == ".ipynb" and "checkpoint" not in base: - full_filename = os.path.join(tutorial_path, filename) - notebook = read(open(full_filename), 'json') - is_published = notebook['metadata']['astropy-tutorials'].get('published', False) - if not is_published and only_published: - continue - - if nbre and nbre.match(base) is None: - continue - - yield full_filename,notebook - -def run_notebooks(selected_nb_re=None): - """ Run the tutorial notebooks. """ - from runipy.notebook_runner import NotebookRunner - - _orig_path = os.getcwd() - - # walk through each directory in tutorials/ to find all .ipynb file - for tutorial_filename,nb in walk_through_tutorials(only_published=True, - selected_nb_re=selected_nb_re): - path,filename = os.path.split(tutorial_filename) - - if filename.startswith("_run_"): - continue - - logger.info("Running tutorial: {}".format(filename)) - - # notebook file - output_filename = os.path.join(path,"_run_{}" - .format(filename)) - - # prepend _run_ to the notebook names to create new files - # so the user isn't left with a bunch of modified files. - os.chdir(path) - r = NotebookRunner(nb, mpl_inline=True) - r.run_notebook(skip_exceptions=True) - write(r.nb, open(output_filename, 'w'), 'json') - - os.chdir(_orig_path) - -def convert_notebooks(selected_nb_re=None): - """ Convert the tutorials (IPython notebook files) located in tutorials/* - into static HTML pages. - """ - from IPython.nbconvert.nbconvertapp import NbConvertApp - - current_directory = os.getcwd() - html_base = os.path.join(current_directory,"html") - if not os.path.exists(html_base): - os.mkdir(html_base) - template_path = os.path.join(current_directory, 'templates') - - app = NbConvertApp() - app.initialize(argv=[]) # hack - app.export_format = 'html' - app.config.Exporter.template_path = ['templates', template_path] - app.config.Exporter.template_file = 'astropy' - - # walk through each directory in tutorials/ to find all .ipynb file - index_list = [] - re_str = ('_run_' + selected_nb_re) if selected_nb_re else None - for tutorial_filename,nb in walk_through_tutorials(only_published=True, - selected_nb_re=re_str): - path,filename = os.path.split(tutorial_filename) - if not filename.startswith("_run_"): - continue - - # remove _run_ from base filename - base = os.path.splitext(filename)[0] - cleanbase = base.lstrip("_run_") - - app.output_base = os.path.join(html_base,cleanbase) - app.notebooks = [os.path.join(path,filename)] - app.start() - - # HACK to set title and other things in rendered notebook - html_filename = "{}.html".format(os.path.join(html_base,cleanbase)) - with open(html_filename, 'rb') as f: - html_file_data = f.read() - - with open(html_filename, 'wb') as f: - html_file_data = html_file_data.decode("utf-8") - html_file_data = html_file_data.replace("{title}",nb['metadata']['astropy-tutorials']['link_name']) - html_file_data = html_file_data.replace("{author}",nb['metadata']['astropy-tutorials']['author']) - html_file_data = html_file_data.replace("{date}",nb['metadata']['astropy-tutorials']['date']) - html_file_data = html_file_data.replace("{abspageurl}","{}".format(cleanbase)) - html_file_data = html_file_data.replace("{pageurl}","{}.html".format(cleanbase)) - f.write(html_file_data.encode("utf8")) - - index_listing = dict() - index_listing["link_path"] = "{}.html".format(cleanbase) - index_listing["link_name"] = nb['metadata']['astropy-tutorials']['link_name'] - index_listing["description"] = nb['metadata']['astropy-tutorials']['description'] - index_list.append(index_listing) - - # Make an index of all notes - entries = [] - for page in sorted(index_list, key=lambda x: x['link_name']): # sort on tutorial name - entry_html = "
  • " - entry_html += "{0[link_name]}".format(page) - entry_html += "
    {0[description]}".format(page) - entry_html += "
  • " - entries.append(entry_html) - - with open(os.path.join(current_directory,'html','index.html'), 'w') as f: - f.write(INDEX_TEMPLATE.format(entries='\n'.join(entries))) - - -if __name__ == "__main__": - from argparse import ArgumentParser - - # Define parser object - parser = ArgumentParser(description="Prepare the tutorials for deployment.") - parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", - default=False, help="Be chatty! (default = False)") - parser.add_argument("-q", "--quiet", action="store_true", dest="quiet", - default=False, help="Be quiet! (default = False)") - parser.add_argument("-n", "--nameregex", default=None, - help="A regular expression to select the names of the " - "notebooks to be processed. If not given, all " - "notebooks will be used.") - - parser.add_argument('action', nargs='+', choices=['run', 'convert','check'], - help='The action(s) to take when running the script. ' - '"run" means to just run the notebooks, while ' - '"convert" will use nbconvert to turn them to ' - 'convert them to HTML.' - '"check" will use check_env.py to check the ' - 'environment for any missing or outdated packages') - - args = parser.parse_args() - - # Set logger level based on verbose flags - if args.verbose: - logger.setLevel('DEBUG') - elif args.quiet: - logger.setLevel('ERROR') - else: - logger.setLevel('INFO') - - for action in args.action: - if action == 'run': - run_notebooks(args.nameregex) - elif action == 'convert': - convert_notebooks(args.nameregex) - elif action == 'check': - check_env.check_environment(args.nameregex) From 6142f6f26ce51bcc390b0457dd0f82ad64fe7aa3 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 10 Oct 2017 09:53:52 -0400 Subject: [PATCH 046/113] move text to index --- docs/_static/astropy.tpl | 4 +- docs/index.rst | 29 +++++++++++ templates/astropy.tpl | 91 ----------------------------------- templates/index_template.html | 60 ----------------------- 4 files changed, 32 insertions(+), 152 deletions(-) delete mode 100644 templates/astropy.tpl delete mode 100644 templates/index_template.html diff --git a/docs/_static/astropy.tpl b/docs/_static/astropy.tpl index b6a598636..f99dcbb5d 100644 --- a/docs/_static/astropy.tpl +++ b/docs/_static/astropy.tpl @@ -198,7 +198,9 @@ .. raw:: html
    -

    Source notebook

    +

    + Source notebook +

    {{ super() }} {% endblock footer %} diff --git a/docs/index.rst b/docs/index.rst index aeab30b1e..a1921977a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,8 +1,14 @@ Astropy Tutorials ================= +The tutorials on this site walk through some typical software tasks and +demonstrate the features in Astropy sub-packages in the context of a story or +standard workflow. See the `Astropy documentation `_ +for a structured view of the functionality within the Astropy project. + .. toctree:: :maxdepth: 1 + :caption: List of tutorials :glob: tutorials/coordinates/coordinates.ipynb @@ -14,3 +20,26 @@ Astropy Tutorials tutorials/redshift-plot/redshift-plot.ipynb tutorials/UVES/UVES.ipynb tutorials/vo/conesearch.ipynb + +Contributing +------------ + +We welcome feedback and improvements to these tutorials via the `Astropy +Tutorials repo on Github `_. If +you find a typo or would like to clarify some text, please either `create an +issue `_ or make the +change yourself and then submit a pull request directly to the repository. +Questions and/or comments about the tutorials are welcome on the `astropy-dev +`_ mailing list. + +If you are interested in contributing an ipython notebook as a tutorial, please +check the `README +`_ or +contact the `astropy developer email list +`_. If you have an idea for +a tutorial or a tutorial request, please also post to the developer email list. +If you would like to contribute to this effort, but need some inspiration, check +out the `open issues for new content +`_. This is a +collaborative effort and we are looking for contributions and ideas from users +like you! diff --git a/templates/astropy.tpl b/templates/astropy.tpl deleted file mode 100644 index 910f43ca2..000000000 --- a/templates/astropy.tpl +++ /dev/null @@ -1,91 +0,0 @@ -{%- extends 'full.tpl' -%} - -{% block header %} - - -{title} - - - - - -{{ super() }} - - - - - -{%- endblock header %} - -{% block body %} - -
    - - - - - -
    - -
    - - {{ super() }} - - - - -
    - - - - -
    - - - - -{%- endblock body %} \ No newline at end of file diff --git a/templates/index_template.html b/templates/index_template.html deleted file mode 100644 index 3acca0f48..000000000 --- a/templates/index_template.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - -Astropy Tutorials - - - - - - - - -
    - -
    - -

    Astropy Tutorials

    -

    The tutorials on this site walk through some typical software tasks and demonstrate the features in Astropy sub-packages in the context of a story or standard workflow. See the Astropy documentation for a structured view of the functionality within the Astropy project.

    - - -
    -
    - -

    List of Tutorials

    -
      -{entries} -
    - -
    - -
    - -

    Contributing

    - -

    We welcome feedback and improvements to these tutorials via the Astropy Tutorials repo on Github. If you find a typo or would like to clarify some text, please either create an issue or make the change yourself and then submit a pull request directly to the repository. Questions and/or comments about the tutorials are welcome on the astropy-dev mailing list.

    - -

    If you are interested in contributing an ipython notebook as a tutorial, please check the README or contact the developer list. Also, if you have an idea for a tutorial or a tutorial request, please post to the developer list. If you would like to contribute to this effort, but need some inspiration, check out the open issues. This is a collaborative effort and we are looking for contributions and ideas from users like you!

    - -
    - -
    - - - From 1880c5229cdb15ccdad314d020f8fe77703fe2eb Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 10 Oct 2017 09:54:01 -0400 Subject: [PATCH 047/113] clean up section on nbsphinx --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index bd513c6f7..9fd2004e9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -132,7 +132,7 @@ # -- Resolving issue number to links in changelog ----------------------------- github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) -# We require nbsphinx +# -- nbsphinx configuration --------------------------------------------------- extensions.append('nbsphinx') extensions.append('IPython.sphinxext.ipython_console_highlighting') From 94b2440887c8bc84729c69cae6dd2e088d02f864 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 10 Oct 2017 09:54:39 -0400 Subject: [PATCH 048/113] add header above list of tutorials --- docs/index.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index a1921977a..71f57deb0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -6,9 +6,11 @@ demonstrate the features in Astropy sub-packages in the context of a story or standard workflow. See the `Astropy documentation `_ for a structured view of the functionality within the Astropy project. +List of tutorials +----------------- + .. toctree:: :maxdepth: 1 - :caption: List of tutorials :glob: tutorials/coordinates/coordinates.ipynb From da14bc1bb3b05a2937ed5d9bb2fc75bbfb5b442a Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 20 Oct 2017 21:34:32 -0400 Subject: [PATCH 049/113] script to execute and convert notebook --- scripts/convert.py | 144 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 scripts/convert.py diff --git a/scripts/convert.py b/scripts/convert.py new file mode 100644 index 000000000..ec81f798e --- /dev/null +++ b/scripts/convert.py @@ -0,0 +1,144 @@ +# Standard library +from os import path + +# Third-party +from astropy import log as logger +logger.setLevel('INFO') + +from nbconvert.preprocessors import ExecutePreprocessor, CellExecutionError +from nbconvert.exporters import RSTExporter +from nbconvert.writers import FilesWriter +import nbformat + +IPYTHON_VERSION = 4 + +class NBConverter(object): + + def __init__(self, nb_path): + self.nb_path = path.abspath(nb_path) + fn = path.basename(self.nb_path) + self.path_only = path.dirname(self.nb_path) + self.nb_name, _ = path.splitext(fn) + + # the executed notebook + self._executed_nb_path = path.join(self.path_only, + 'exec_{0}'.format(fn)) + + logger.info('Processing notebook {0} (in {1})'.format(fn, + self.path_only)) + + def execute(self, write=True): + """ + Execute the specified notebook file, and optionally write out the + executed notebook to a new file. + + Parameters + ---------- + write : bool, optional + Write the executed notebook to a new file, or not. + + Returns + ------- + executed_nb_path : str, ``None`` + The path to the executed notebook path, or ``None`` if + ``write=False``. + + """ + + # Execute the notebook + logger.debug('Executing notebook...') + executor = ExecutePreprocessor(timeout=900, kernel_name='python3') + with open(self.nb_path) as f: + nb = nbformat.read(f, as_version=IPYTHON_VERSION) + + try: + executor.preprocess(nb, {'metadata': {'path': self.path_only}}) + except CellExecutionError: + # TODO: should we fail fast and raies, or record all errors? + raise + + if write: + logger.debug('Writing executed notebook to file {0}...' + .format(self._executed_nb_path)) + with open(self._executed_nb_path, 'w') as f: + nbformat.write(nb, f) + + return self._executed_nb_path + + def convert(self): + """ + Convert the executed notebook to a restructured text (RST) file. + """ + + if not path.exists(self._executed_nb_path): + raise IOError("Executed notebook file doesn't exist! Expected: {0}" + .format(self._executed_nb_path)) + + # Initialize the resources dict - see: + # https://github.com/jupyter/nbconvert/blob/master/nbconvert/nbconvertapp.py#L327 + resources = {} + resources['config_dir'] = '' # we don't need to specify config + resources['unique_key'] = self.nb_name + + # path to store extra files, like plots generated + resources['output_files_dir'] = path.join(self.path_only, 'nboutput') + + # Exports the notebook to RST + logger.debug('Exporting notebook to RST...') + exporter = RSTExporter() + output, resources = exporter.from_filename(self._executed_nb_path, + resources=resources) + + # Write the output RST file + writer = FilesWriter() + output_file_path = writer.write(output, resources, + notebook_name=self.nb_name) + + return output_file_path + +if __name__ == "__main__": + from argparse import ArgumentParser + import logging + + # Define parser object + parser = ArgumentParser(description="") + + vq_group = parser.add_mutually_exclusive_group() + vq_group.add_argument('-v', '--verbose', action='count', default=0, + dest='verbosity') + vq_group.add_argument('-q', '--quiet', action='count', default=0, + dest='quietness') + + parser.add_argument('-o', '--overwrite', action='store_true', + dest='overwrite', default=False, + help='Re-run and overwrite any existing executed ' + 'notebook or RST files.') + + parser.add_argument('nbfile_or_path', default=None, + help='Path to a specific notebook file, or the ' + 'top-level path to a directory containing ' + 'notebook files to process.') + + args = parser.parse_args() + + # Set logger level based on verbose flags + if args.verbosity != 0: + if args.verbosity == 1: + logger.setLevel(logging.DEBUG) + else: # anything >= 2 + logger.setLevel(1) + + elif args.quietness != 0: + if args.quietness == 1: + logger.setLevel(logging.WARNING) + else: # anything >= 2 + logger.setLevel(logging.ERROR) + + if path.isdir(args.nbfile_or_path): + # TODO: walk through + pass + + else: + nbc = NBConverter(args.nbfile_or_path) + nbc.execute() + nbc.convert() From c39893c65eaaf96e3c7e31002bdb670a6773aff0 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 20 Oct 2017 21:34:53 -0400 Subject: [PATCH 050/113] add skeleton of test --- scripts/__init__.py | 0 scripts/tests/__init__.py | 0 scripts/tests/test-fail.ipynb | 92 +++++++++++++++++++++++++ scripts/tests/test-succeed.ipynb | 112 +++++++++++++++++++++++++++++++ scripts/tests/test_convert.py | 4 ++ 5 files changed, 208 insertions(+) create mode 100644 scripts/__init__.py create mode 100644 scripts/tests/__init__.py create mode 100644 scripts/tests/test-fail.ipynb create mode 100644 scripts/tests/test-succeed.ipynb create mode 100644 scripts/tests/test_convert.py diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/tests/__init__.py b/scripts/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/tests/test-fail.ipynb b/scripts/tests/test-fail.ipynb new file mode 100644 index 000000000..bf3f1277a --- /dev/null +++ b/scripts/tests/test-fail.ipynb @@ -0,0 +1,92 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import astropy.units as u\n", + "import numpy as np\n", + "import matplotlib as mpl\n", + "import matplotlib.pyplot as plt\n", + "%matplotlib inline" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "a = np.arange(10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "print(\"This is some stuff\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "plt.plot(a)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print 100" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "celltoolbar": "Edit Metadata", + "kernelspec": { + "display_name": "Python [default]", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/scripts/tests/test-succeed.ipynb b/scripts/tests/test-succeed.ipynb new file mode 100644 index 000000000..5c0953dbc --- /dev/null +++ b/scripts/tests/test-succeed.ipynb @@ -0,0 +1,112 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import astropy.units as u\n", + "import numpy as np\n", + "import matplotlib as mpl\n", + "import matplotlib.pyplot as plt\n", + "%matplotlib inline" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "a = np.arange(10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "print(\"This is some stuff\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "plt.plot(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "tags": [ + "raises-exception" + ] + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "ERROR: SyntaxError: Missing parentheses in call to 'print' (, line 1) [IPython.core.compilerop]\n" + ] + }, + { + "ename": "SyntaxError", + "evalue": "Missing parentheses in call to 'print' (, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m print 100\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m Missing parentheses in call to 'print'\n" + ] + } + ], + "source": [ + "print 100" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "celltoolbar": "Edit Metadata", + "kernelspec": { + "display_name": "Python [default]", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/scripts/tests/test_convert.py b/scripts/tests/test_convert.py new file mode 100644 index 000000000..b941bcb18 --- /dev/null +++ b/scripts/tests/test_convert.py @@ -0,0 +1,4 @@ +from ..convert import convert + +def test_convert(): + print('done') From ee77cefcffada420a150a829e180bbb9a19b991c Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 20 Oct 2017 21:44:51 -0400 Subject: [PATCH 051/113] comments --- scripts/convert.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/convert.py b/scripts/convert.py index ec81f798e..aa64bb4ac 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -135,10 +135,19 @@ def convert(self): logger.setLevel(logging.ERROR) if path.isdir(args.nbfile_or_path): - # TODO: walk through + # It's a path, so we need to walk through recursively and find any + # notebook files + + # TODO: + + # nbc = NBConverter(args.nbfile_or_path) + # nbc.execute() + # nbc.convert() + pass else: + # It's a single file, so convert it nbc = NBConverter(args.nbfile_or_path) nbc.execute() nbc.convert() From ef0620f577415e24459ecbb13d13f23e051b3295 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 20 Oct 2017 21:45:02 -0400 Subject: [PATCH 052/113] walk through path, if a path is specified --- scripts/convert.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/scripts/convert.py b/scripts/convert.py index aa64bb4ac..182d4508f 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -1,5 +1,5 @@ # Standard library -from os import path +from os import path, walk # Third-party from astropy import log as logger @@ -109,6 +109,12 @@ def convert(self): vq_group.add_argument('-q', '--quiet', action='count', default=0, dest='quietness') + parser.add_argument('--exec-only', default=False, action='store_true', + dest='exec_only', help='Just execute the notebooks, ' + 'don\'t convert them as well. ' + 'This is useful for testing that' + ' the notebooks run.') + parser.add_argument('-o', '--overwrite', action='store_true', dest='overwrite', default=False, help='Re-run and overwrite any existing executed ' @@ -137,17 +143,21 @@ def convert(self): if path.isdir(args.nbfile_or_path): # It's a path, so we need to walk through recursively and find any # notebook files + for root, dirs, files in walk(args.nbfile_or_path): + for name in files: + _,ext = path.splitext(name) - # TODO: - - # nbc = NBConverter(args.nbfile_or_path) - # nbc.execute() - # nbc.convert() + if ext == '.ipynb': + nbc = NBConverter(path.join(root, name)) + nbc.execute() - pass + if not args.exec_only: + nbc.convert() else: # It's a single file, so convert it nbc = NBConverter(args.nbfile_or_path) nbc.execute() - nbc.convert() + + if not args.exec_only: + nbc.convert() From 73263e01da49f745dea41960e72d75d16e5fdbbc Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:06:57 -0400 Subject: [PATCH 053/113] add a simple test of the nbconvert machinery --- scripts/tests/test_convert.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/tests/test_convert.py b/scripts/tests/test_convert.py index b941bcb18..b709a0f47 100644 --- a/scripts/tests/test_convert.py +++ b/scripts/tests/test_convert.py @@ -1,4 +1,26 @@ -from ..convert import convert +# Standard library +from os import path, remove -def test_convert(): - print('done') +# Third-party +import pytest + +# This project +from ..convert import NBConverter + +tests_path = path.split(path.abspath(__file__))[0] + +def test_convert_succeed(): + # With the current master version of nbconvert, we can allow errors + # per-cell. This notebook, even though it raises an exception, should still + # execute fine: + nbc = NBConverter(path.join(tests_path, 'test-succeed.ipynb')) + filename = nbc.execute() + remove(filename) # clean up + +def test_convert_fail(): + # This notebook raises an exception in a cell, but doesn't use the + # 'raises-exception' tag in the cell metadata, so it should fail + nbc = NBConverter(path.join(tests_path, 'test-fail.ipynb')) + + with pytest.raises(Exception): + nbc.execute() From 99a24f15319468d20054db3ec23f866c5c93e19d Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:07:07 -0400 Subject: [PATCH 054/113] add option to remove the executed notebook --- scripts/convert.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/convert.py b/scripts/convert.py index 182d4508f..4ac6b5013 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -1,5 +1,5 @@ # Standard library -from os import path, walk +from os import path, walk, remove # Third-party from astropy import log as logger @@ -65,9 +65,14 @@ def execute(self, write=True): return self._executed_nb_path - def convert(self): + def convert(self, remove_executed=False): """ Convert the executed notebook to a restructured text (RST) file. + + Parameters + ---------- + delete_executed : bool, optional + Controls whether to remove the executed notebook or not. """ if not path.exists(self._executed_nb_path): @@ -94,6 +99,9 @@ def convert(self): output_file_path = writer.write(output, resources, notebook_name=self.nb_name) + if remove_executed: # optionally, clean up the executed notebook file + remove(self._executed_nb_path) + return output_file_path if __name__ == "__main__": From 960c9d6c2eabfeefd9a8093acf7939d3d2b09e2e Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:16:48 -0400 Subject: [PATCH 055/113] add raises-exception tag to cell metadata --- docs/tutorials/coordinates/coordinates.ipynb | 163 ++++++++++++++----- 1 file changed, 123 insertions(+), 40 deletions(-) diff --git a/docs/tutorials/coordinates/coordinates.ipynb b/docs/tutorials/coordinates/coordinates.ipynb index 9736fd039..c70b342be 100644 --- a/docs/tutorials/coordinates/coordinates.ipynb +++ b/docs/tutorials/coordinates/coordinates.ipynb @@ -17,7 +17,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Python standard-library\n", @@ -35,7 +37,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Set up matplotlib and use a nicer set of plot parameters\n", @@ -66,7 +70,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "hcg7_center = SkyCoord(9.81625*u.deg, 0.88806*u.deg, frame='icrs')\n", @@ -83,7 +89,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "SkyCoord('0h39m15.9s', '0d53m17.016s', frame='icrs')" @@ -92,7 +100,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "SkyCoord('0:39:15.9 0:53:17.016', unit=(u.hour, u.deg), frame='icrs')" @@ -110,7 +120,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "hcg7_center = SkyCoord.from_name('HCG 7')\n", @@ -127,7 +139,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "type(hcg7_center.ra), type(hcg7_center.dec)" @@ -136,7 +150,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "hcg7_center.dec" @@ -145,7 +161,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "hcg7_center.ra" @@ -154,7 +172,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "hcg7_center.ra.hour" @@ -172,7 +192,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "impix = 1024\n", @@ -198,7 +220,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "Image('HCG7_SDSS_cutout.jpg')" @@ -230,7 +254,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -246,7 +272,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -274,7 +302,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astroquery.sdss import SDSS\n", @@ -295,7 +325,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sdss.write('HCG7_SDSS_photo.dat', format='ascii')" @@ -311,7 +343,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sdss = Table.read('HCG7_SDSS_photo.dat', format='ascii')" @@ -327,7 +361,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "twomass = Table.read('HCG7_2MASS.tbl', format='ascii')" @@ -343,7 +379,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "sdss # just to see an example of the format" @@ -352,7 +390,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "twomass # just to see an example of the format" @@ -370,7 +410,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "coo_sdss = SkyCoord(sdss['ra']*u.deg, sdss['dec']*u.deg)\n", @@ -389,7 +431,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "idx_sdss, d2d_sdss, d3d_sdss = coo_twomass.match_to_catalog_sky(coo_sdss)" @@ -405,7 +449,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "plt.hist(d2d_sdss.arcsec, histtype='step', range=(0,2))\n", @@ -425,7 +471,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "ras_sim = np.random.rand(len(coo_twomass))*coo_sdss.ra.ptp() + coo_sdss.ra.min()\n", @@ -445,7 +493,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "coo_simulated = SkyCoord(ras_sim, decs_sim) \n", @@ -462,7 +512,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "plt.hist(d2d_sim.arcsec, bins='auto', histtype='step', label='Simulated', linestyle='dashed')\n", @@ -482,7 +534,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "rmag = sdss['r'][idx_sdss]\n", @@ -531,7 +585,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -547,7 +603,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -582,7 +640,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "hcg7_center.galactic" @@ -598,7 +658,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astropy.coordinates import Galactic\n", @@ -615,7 +677,12 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true, + "tags": [ + "raises-exception" + ] + }, "outputs": [], "source": [ "hcg7_center.galactic.ra # should fail because galactic coordinates are l/b not RA/Dec" @@ -624,7 +691,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "hcg7_center.galactic.b" @@ -647,7 +716,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astropy.coordinates import EarthLocation\n", @@ -670,7 +741,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astropy.coordinates import AltAz\n", @@ -689,7 +762,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "hcg7_center.transform_to(aa)" @@ -705,7 +780,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# this gives a Time object with an *array* of times\n", @@ -731,7 +808,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from astropy.coordinates import get_sun\n", @@ -768,7 +847,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, @@ -784,7 +865,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [] }, From e44858e17f13d525797725a0c230ee429af6daa6 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:20:47 -0400 Subject: [PATCH 056/113] skip any notebook files in a checkpoints directory --- scripts/convert.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/convert.py b/scripts/convert.py index 4ac6b5013..ac075966f 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -154,9 +154,13 @@ def convert(self, remove_executed=False): for root, dirs, files in walk(args.nbfile_or_path): for name in files: _,ext = path.splitext(name) + full_path = path.join(root, name) + + if 'ipynb_checkpoints' in full_path: # skip checkpoint saves + continue if ext == '.ipynb': - nbc = NBConverter(path.join(root, name)) + nbc = NBConverter(full_path) nbc.execute() if not args.exec_only: From 769bff2abe886fdf35905937de25a9cde97023bf Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:21:20 -0400 Subject: [PATCH 057/113] also skip notebooks that have already been executed --- scripts/convert.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/convert.py b/scripts/convert.py index ac075966f..32ea362f8 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -159,6 +159,9 @@ def convert(self, remove_executed=False): if 'ipynb_checkpoints' in full_path: # skip checkpoint saves continue + if name.startswith('exec'): # notebook already executed + continue + if ext == '.ipynb': nbc = NBConverter(full_path) nbc.execute() From 8cc186f2f43844673b3ea78a03a84eeb6b0b3652 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:32:56 -0400 Subject: [PATCH 058/113] very rough, zeroth draft of developer docs --- docs/dev.rst | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 docs/dev.rst diff --git a/docs/dev.rst b/docs/dev.rst new file mode 100644 index 000000000..3ada960b6 --- /dev/null +++ b/docs/dev.rst @@ -0,0 +1,75 @@ +Tutorials are written as Jupyter notebooks on the ``master`` branch in +``docs/_static`` (or are sym-linked there). These notebook files do not contain +output in order to simplify version-controlling the files. + +The rendered astropy-tutorials site is built using Sphinx using the astropy +theme to look like the main documentation. Sphinx requires RST (restructured +text) files for its build process, so we need an intermediate step to (a) run +the notebooks to produce output, and (b) convert the notebook files into RST +files. We also need to be able to test that the notebooks run successfully in an +automated way. On the rendered RST pages, we want to include links to (a) the +source notebook, (b) a Binder instance with a live version of the source +notebook. + +Both running and converting the notebooks is handled automatically by the Sphinx +plugin ``nbsphinx``, but it doesn't support all of the features we want. In +particular, there is no supported way to modify the template file that controls +the output RST file that gets generated from each notebook; we definitely want +to be able to modify the template so we can add the links mentioned above. + +We will instead implement our own run-and-convert machinery using ``nbconvert`` +(which is what ``nbsphinx`` uses internally, but just doesn't expose all of the +bells and whistles). An advantage to doing this is we can use the same script +or machinery to test the notebooks as we use to run and convert them to RST. + +There are three possibilities for how to deploy the site: + +1. We use a custom deploy script that runs the Sphinx build locally and pushes + to a ``gh-pages`` branch to be rendered as static HTML. This deploy script + is executed by travis, as is done currently. +2. We use readthedocs to do the Sphinx build. The advantage to this is that the + tutorials would support a version history. If we "release" a new version of + the tutorials with each major Astropy release, this history would show up + for free on readthedocs. The disadvantage to this is that readthedocs is a + lot more finicky than travis, and we have a limited build time (which might + be ok right now, but might not scale to 10's of tutorials). At least a few of + our notebooks access the web, or have components that take some time to + execute, both of which can sometimes lead to failures on readthedocs. +3. We use travis to run the notebooks and convert to RST, then push to a special + branch (e.g., "``rendered``") that readthedocs runs off of. This way, the + only build that gets done on readthedocs is a pretty standard, static Sphinx + build, but we still get all of the versioning benefits of using RTD. The + disadvantage here is that it makes the deploy system more complex in that + there are multiple stages, and more opportunities for things to break. In + this scheme, we'd have to do releases (tag versions) from the ``rendered`` + branch. + +Marking a cell with an intentional error +---------------------------------------- + +Add to cell metadata: ``"tags": ["raises-exception"]`` + +Other notes +----------- + +* Notebook files must have the same name as the directory they are in. This is + just needed for auto-link-generation purposes in the RST template. + +* For now, the tutorials will just be listed on the main page in a table of + contents. If we want to switch to ``sphinx-gallery`` or some fancier layout, + we can, but I suggest we do that in a separate PR + + + On each rendered page, we want: + - Link to notebook on Binder + - Link to download all notebooks and content + + + Travis builds (@eteq): + - Test (nbconvert) + - Run sphinx + - Deploy + + +TODO: +- Add notebook name to notebook metadata From f67bafa8009f084a843ebfb4c2ab1fd9055d1b5e Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:36:01 -0400 Subject: [PATCH 059/113] added raises-exception tags where needed --- docs/tutorials/quantities/quantities.ipynb | 116 +++++++-------------- 1 file changed, 37 insertions(+), 79 deletions(-) diff --git a/docs/tutorials/quantities/quantities.ipynb b/docs/tutorials/quantities/quantities.ipynb index 447939d94..c632dcc37 100644 --- a/docs/tutorials/quantities/quantities.ipynb +++ b/docs/tutorials/quantities/quantities.ipynb @@ -133,9 +133,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "print(\"\"\"Half light radius\n", @@ -153,9 +151,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "print(\"\"\"Half light radius\n", @@ -173,9 +169,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "print(\"{0:.3g}\".format(Reff.to(u.m)))" @@ -204,9 +198,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "print(\"\"\"First 10 radial velocity measurements: \n", @@ -217,9 +209,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "plt.figure()\n", @@ -238,9 +228,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "sigma = np.sqrt(np.sum((v - np.mean(v))**2) / np.size(v))\n", @@ -282,9 +270,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "M = 4*sigma**2*Reff/G\n", @@ -301,9 +287,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "M.decompose()" @@ -319,9 +303,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "print(\"\"\"Galaxy mass\n", @@ -340,9 +322,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "np.log10(M / u.Msun)" @@ -359,7 +339,9 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": true + "tags": [ + "raises-exception" + ] }, "outputs": [], "source": [ @@ -529,9 +511,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "# Average pixel size\n", @@ -556,9 +536,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "intcloud = np.sum(data*dv, axis=2)\n", @@ -575,9 +553,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "#Note that we display RA in the convential way by going from max to min\n", @@ -648,7 +624,9 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": true + "tags": [ + "raises-exception" + ] }, "outputs": [], "source": [ @@ -686,9 +664,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "A13 = 7.4e-8 / u.s\n", @@ -726,9 +702,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "print('{0}\\n{1}'.format(B, B.decompose()))" @@ -744,9 +718,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "NCO = C * np.sum(data*dv, axis=2) / (1 - np.exp(-B))\n", @@ -771,9 +743,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "H2_CO_ratio = 5.9e6\n", @@ -818,9 +788,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "dap = dra * ddec\n", @@ -837,9 +805,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "da = dap * d**2 # don't actually do it this way - use the version below instead!\n", @@ -849,9 +815,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "dap.to(u.steradian).value * d**2" @@ -868,7 +832,9 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": true + "tags": [ + "raises-exception" + ] }, "outputs": [], "source": [ @@ -885,9 +851,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "da = (dap * d**2).to(u.pc**2, equivalencies=u.dimensionless_angles())\n", @@ -897,9 +861,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "da.to(u.cm**2)" @@ -915,9 +877,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "M = np.sum(rho * da)\n", @@ -1011,9 +971,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "response_func(1.0, 1.2)" @@ -1054,7 +1012,9 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": true + "tags": [ + "raises-exception" + ] }, "outputs": [], "source": [ @@ -1071,9 +1031,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "response_func(1.0*u.arcmin, 1.2*u.arcmin)" From 010020e8f4d2f71a659b91a100ec6f9c0ad75475 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:37:43 -0400 Subject: [PATCH 060/113] ignore executed notebooks --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7b7042a14..f58332729 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ .ipynb_checkpoints/ docs/_build/ -runipy-* IPython-* *.fits *.pdf *.png *.jpg *.pyc -*.tex \ No newline at end of file +*.tex +exec*.ipynb \ No newline at end of file From 9ec162cf243f98cd218fb6639a309adde667b1ab Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:56:32 -0400 Subject: [PATCH 061/113] remove nbsphinx --- docs/conf.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 9fd2004e9..e13b0b0b7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -131,18 +131,3 @@ # -- Resolving issue number to links in changelog ----------------------------- github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) - -# -- nbsphinx configuration --------------------------------------------------- -extensions.append('nbsphinx') -extensions.append('IPython.sphinxext.ipython_console_highlighting') - -nbsphinx_timeout = 600 # Time in seconds; use -1 for no timeout -nbsphinx_prompt_width = 0 - -# TODO: remove this when errors in tutorials are updated to be static text -nbsphinx_allow_errors = True - -import nbsphinx - -with open(path.join(path.dirname(__file__), '_static', 'astropy.tpl'), 'r') as f: - nbsphinx.RST_TEMPLATE = f.read() From 7716d2b155d8ad2b3963ef6525aa064eaa4855c8 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:56:48 -0400 Subject: [PATCH 062/113] remove link --- tutorials | 1 - 1 file changed, 1 deletion(-) delete mode 120000 tutorials diff --git a/tutorials b/tutorials deleted file mode 120000 index b27de659d..000000000 --- a/tutorials +++ /dev/null @@ -1 +0,0 @@ -docs/tutorials/ \ No newline at end of file From 2cac97a0b00213541e7651b01bfe8a1345eb85bf Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 10:56:59 -0400 Subject: [PATCH 063/113] add option to specify output path --- scripts/convert.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/convert.py b/scripts/convert.py index 32ea362f8..af2528fde 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -14,14 +14,19 @@ class NBConverter(object): - def __init__(self, nb_path): + def __init__(self, nb_path, output_path=None): self.nb_path = path.abspath(nb_path) fn = path.basename(self.nb_path) self.path_only = path.dirname(self.nb_path) self.nb_name, _ = path.splitext(fn) + if output_path is not None: + self.output_path = output_path + else: + self.output_path = self.path_only + # the executed notebook - self._executed_nb_path = path.join(self.path_only, + self._executed_nb_path = path.join(self.output_path, 'exec_{0}'.format(fn)) logger.info('Processing notebook {0} (in {1})'.format(fn, @@ -86,7 +91,7 @@ def convert(self, remove_executed=False): resources['unique_key'] = self.nb_name # path to store extra files, like plots generated - resources['output_files_dir'] = path.join(self.path_only, 'nboutput') + resources['output_files_dir'] = path.join(self.output_path, 'nboutput') # Exports the notebook to RST logger.debug('Exporting notebook to RST...') @@ -133,6 +138,12 @@ def convert(self, remove_executed=False): 'top-level path to a directory containing ' 'notebook files to process.') + parser.add_argument('--output-path', default=None, dest='output_path', + help='The path to save all executed or converted ' + 'notebook files. If not specified, the executed/' + 'converted files will be in the same path as the ' + 'source notebooks.') + args = parser.parse_args() # Set logger level based on verbose flags @@ -163,7 +174,7 @@ def convert(self, remove_executed=False): continue if ext == '.ipynb': - nbc = NBConverter(full_path) + nbc = NBConverter(full_path, output_path=args.output_path) nbc.execute() if not args.exec_only: @@ -171,7 +182,7 @@ def convert(self, remove_executed=False): else: # It's a single file, so convert it - nbc = NBConverter(args.nbfile_or_path) + nbc = NBConverter(args.nbfile_or_path, output_path=args.output_path) nbc.execute() if not args.exec_only: From f682a4eee4846ea92b23f5f647da7060144b8987 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 11:20:43 -0400 Subject: [PATCH 064/113] add option to specify a template and move tutorials --- docs/_static/astropy.tpl | 244 +++++------------- .../tutorials/FITS-header/FITS-header.ipynb | 0 .../tutorials/FITS-header/input_file.fits | Bin .../tutorials/FITS-header/requirements.txt | 0 .../tutorials/FITS-images/FITS-images.ipynb | 0 .../tutorials/FITS-images/requirements.txt | 0 .../tutorials/FITS-tables/FITS-tables.ipynb | 0 .../tutorials/FITS-tables/requirements.txt | 0 docs/{ => _static}/tutorials/UVES/CaII-1.png | Bin docs/{ => _static}/tutorials/UVES/CaII-2.png | Bin docs/{ => _static}/tutorials/UVES/CaII-3.png | Bin .../tutorials/UVES/CaII-lines-all.png | Bin .../tutorials/UVES/CaII-lines-one.png | Bin docs/{ => _static}/tutorials/UVES/CaII.png | Bin docs/{ => _static}/tutorials/UVES/UVES.ipynb | 0 .../tutorials/UVES/requirements.txt | 0 .../tutorials/coordinates/HCG7_2MASS.tbl | 0 .../coordinates/HCG7_SDSS_cutout.jpg | Bin .../tutorials/coordinates/HCG7_SDSS_photo.dat | 0 .../tutorials/coordinates/coordinates.ipynb | 0 .../tutorials/coordinates/requirements.txt | 0 .../Young-Objects-Compilation.csv | 0 .../tutorials/plot-catalog/plot-catalog.ipynb | 0 .../tutorials/plot-catalog/requirements.txt | 0 .../tutorials/plot-catalog/simple_table.csv | 0 .../tutorials/quantities/quantities.ipynb | 0 .../tutorials/quantities/requirements.txt | 0 .../tutorials/redshift-plot/ang_dist.png | Bin .../redshift-plot/redshift-plot.ipynb | 0 .../tutorials/redshift-plot/requirements.txt | 0 docs/{ => _static}/tutorials/vo/README.md | 0 .../tutorials/vo/conesearch.ipynb | 0 scripts/convert.py | 39 ++- 33 files changed, 103 insertions(+), 180 deletions(-) rename docs/{ => _static}/tutorials/FITS-header/FITS-header.ipynb (100%) rename docs/{ => _static}/tutorials/FITS-header/input_file.fits (100%) rename docs/{ => _static}/tutorials/FITS-header/requirements.txt (100%) rename docs/{ => _static}/tutorials/FITS-images/FITS-images.ipynb (100%) rename docs/{ => _static}/tutorials/FITS-images/requirements.txt (100%) rename docs/{ => _static}/tutorials/FITS-tables/FITS-tables.ipynb (100%) rename docs/{ => _static}/tutorials/FITS-tables/requirements.txt (100%) rename docs/{ => _static}/tutorials/UVES/CaII-1.png (100%) rename docs/{ => _static}/tutorials/UVES/CaII-2.png (100%) rename docs/{ => _static}/tutorials/UVES/CaII-3.png (100%) rename docs/{ => _static}/tutorials/UVES/CaII-lines-all.png (100%) rename docs/{ => _static}/tutorials/UVES/CaII-lines-one.png (100%) rename docs/{ => _static}/tutorials/UVES/CaII.png (100%) rename docs/{ => _static}/tutorials/UVES/UVES.ipynb (100%) rename docs/{ => _static}/tutorials/UVES/requirements.txt (100%) rename docs/{ => _static}/tutorials/coordinates/HCG7_2MASS.tbl (100%) rename docs/{ => _static}/tutorials/coordinates/HCG7_SDSS_cutout.jpg (100%) rename docs/{ => _static}/tutorials/coordinates/HCG7_SDSS_photo.dat (100%) rename docs/{ => _static}/tutorials/coordinates/coordinates.ipynb (100%) rename docs/{ => _static}/tutorials/coordinates/requirements.txt (100%) rename docs/{ => _static}/tutorials/plot-catalog/Young-Objects-Compilation.csv (100%) rename docs/{ => _static}/tutorials/plot-catalog/plot-catalog.ipynb (100%) rename docs/{ => _static}/tutorials/plot-catalog/requirements.txt (100%) rename docs/{ => _static}/tutorials/plot-catalog/simple_table.csv (100%) rename docs/{ => _static}/tutorials/quantities/quantities.ipynb (100%) rename docs/{ => _static}/tutorials/quantities/requirements.txt (100%) rename docs/{ => _static}/tutorials/redshift-plot/ang_dist.png (100%) rename docs/{ => _static}/tutorials/redshift-plot/redshift-plot.ipynb (100%) rename docs/{ => _static}/tutorials/redshift-plot/requirements.txt (100%) rename docs/{ => _static}/tutorials/vo/README.md (100%) rename docs/{ => _static}/tutorials/vo/conesearch.ipynb (100%) diff --git a/docs/_static/astropy.tpl b/docs/_static/astropy.tpl index f99dcbb5d..9e89e83e5 100644 --- a/docs/_static/astropy.tpl +++ b/docs/_static/astropy.tpl @@ -1,206 +1,98 @@ +{%- extends 'display_priority.tpl' -%} -{% extends 'rst.tpl' %} +{% block header %} +{# Remove the exec_ prefix #} +{% set nb_name = resources.metadata.name[5:] %} -{% macro insert_empty_lines(text) %} -{%- set before, after = text | get_empty_lines %} -{%- if before %} - :empty-lines-before: {{ before }} -{%- endif %} -{%- if after %} - :empty-lines-after: {{ after }} -{%- endif %} -{%- endmacro %} +.. note:: + This tutorial was generated from an IPython notebook that can be downloaded `here + <../_static/tutorials/{{ nb_name }}/{{ nb_name }}.ipynb>`_. -{% block any_cell %} -{%- if cell.metadata.nbsphinx != 'hidden' %} -{{ super() }} -{% endif %} -{%- endblock any_cell %} - - -{% block input -%} -.. nbinput:: {% if cell.metadata.magics_language -%} -{{ cell.metadata.magics_language }} -{%- elif nb.metadata.language_info -%} -{{ nb.metadata.language_info.pygments_lexer or nb.metadata.language_info.name }} -{%- else -%} -{{ resources.codecell_lexer }} -{%- endif -%} -{{ insert_empty_lines(cell.source) }} -{%- if cell.execution_count %} - :execution-count: {{ cell.execution_count }} -{%- endif %} -{%- if not cell.outputs %} - :no-output: -{%- endif %} -{%- if cell.source.strip() %} - -{{ cell.source.strip(' -') | indent }} -{%- endif %} -{% endblock input %} - - -{% macro insert_nboutput(datatype, output, cell) -%} -.. nboutput:: -{%- if datatype == 'text/plain' %}{# nothing #} -{%- else %} rst -{%- endif %} -{%- if output.output_type == 'execute_result' and cell.execution_count %} - :execution-count: {{ cell.execution_count }} -{%- endif %} -{%- if output != cell.outputs[-1] %} - :more-to-come: -{%- endif %} -{%- if output.name == 'stderr' %} - :class: stderr -{%- endif %} -{%- if datatype == 'text/plain' -%} -{{ insert_empty_lines(output.data[datatype]) }} - -{{ output.data[datatype].strip( -) | indent }} -{%- elif datatype in ['image/svg+xml', 'image/png', 'image/jpeg', 'application/pdf'] %} - - .. image:: {{ output.metadata.filenames[datatype] | posix_path }} -{%- elif datatype in ['text/markdown'] %} - -{{ output.data['text/markdown'] | markdown2rst | indent }} -{%- elif datatype in ['text/latex'] %} - - .. math:: - :nowrap: - -{{ output.data['text/latex'] | indent | indent }} -{%- elif datatype == 'text/html' %} - - .. raw:: html - -{{ output.data['text/html'] | indent | indent }} -{%- elif datatype == 'application/javascript' %} -{% set div_id = uuid4() %} - - .. raw:: html - -
    - -{%- elif datatype.startswith('application') and datatype.endswith('+json') %} - - .. raw:: html - - -{%- elif datatype == 'ansi' %} - - .. rst-class:: highlight +.. _{{nb_name}}: +{% endblock %} - .. raw:: html +{% block in_prompt %} +{% endblock in_prompt %} -
    -{{ output.data[datatype] | ansi2html | indent | indent }}
    -        
    +{% block output_prompt %} +{% endblock output_prompt %} - .. raw:: latex +{% block input %} +{%- if cell.source.strip() and not cell.source.startswith("%") -%} +.. code:: python - % - \begin{OriginalVerbatim}[commandchars=\\\{\}] -{{ output.data[datatype] | ansi2latex | indent | indent }} - \end{OriginalVerbatim} - % The following \relax is needed to avoid problems with adjacent ANSI - % cells and some other stuff (e.g. bullet lists) following ANSI cells. - % See https://github.com/sphinx-doc/sphinx/issues/3594 - \relax -{% else %} - - .. nbwarning:: Data type cannot be displayed: {{ datatype }} -{%- endif %} -{% endmacro %} - - -{% block nboutput -%} -{%- set html_datatype, latex_datatype = output | get_output_type %} -{%- if html_datatype == latex_datatype %} -{{ insert_nboutput(html_datatype, output, cell) }} -{%- else %} -.. only:: html - -{{ insert_nboutput(html_datatype, output, cell) | indent }} -.. only:: latex - -{{ insert_nboutput(latex_datatype, output, cell) | indent }} -{%- endif %} -{% endblock nboutput %} +{{ cell.source | indent}} +{% endif -%} +{% endblock input %} +{% block error %} +:: -{% block execute_result %}{{ self.nboutput() }}{% endblock execute_result %} -{% block display_data %}{{ self.nboutput() }}{% endblock display_data %} -{% block stream %}{{ self.nboutput() }}{% endblock stream %} -{% block error %}{{ self.nboutput() }}{% endblock error %} +{{ super() }} +{% endblock error %} +{% block traceback_line %} +{{ line | indent | strip_ansi }} +{% endblock traceback_line %} -{% block markdowncell %} -{%- if 'nbsphinx-toctree' in cell.metadata %} -{{ cell | extract_toctree }} -{%- else %} +{% block execute_result %} +{% block data_priority scoped %} {{ super() }} -{% endif %} -{% endblock markdowncell %} +{% endblock %} +{% endblock execute_result %} +{% block stream %} +.. parsed-literal:: -{% block rawcell %} -{%- set raw_mimetype = cell.metadata.get('raw_mimetype', '').lower() %} -{%- if raw_mimetype == '' %} -.. raw:: html - -{{ cell.source | indent }} +{{ output.text | indent }} +{% endblock stream %} -.. raw:: latex +{% block data_svg %} +.. image:: {{ output.metadata.filenames['image/svg+xml'] | urlencode }} +{% endblock data_svg %} - % -{{ cell.source | indent }} -{%- elif raw_mimetype == 'text/html' %} -.. raw:: html +{% block data_png %} +.. image:: {{ output.metadata.filenames['image/png'] | urlencode }} +{% endblock data_png %} -{{ cell.source | indent }} -{%- elif raw_mimetype == 'text/latex' %} -.. raw:: latex +{% block data_jpg %} +.. image:: {{ output.metadata.filenames['image/jpeg'] | urlencode }} +{% endblock data_jpg %} - % -{{ cell.source | indent }} -{%- elif raw_mimetype == 'text/markdown' %} -{{ cell.source | markdown2rst }} -{%- elif raw_mimetype == 'text/restructuredtext' %} -{{ cell.source }} -{% endif %} -{% endblock rawcell %} +{% block data_latex %} +.. math:: +{{ output.data['text/latex'] | strip_dollars | indent }} +{% endblock data_latex %} -{% block footer %} +{% block data_text scoped %} +.. parsed-literal:: -{% if 'application/vnd.jupyter.widget-state+json' in nb.metadata.widgets %} +{{ output.data['text/plain'] | indent }} +{% endblock data_text %} +{% block data_html scoped %} .. raw:: html - -{% endif %} +{{ output.data['text/html'] | indent }} +{% endblock data_html %} -{# This is where the custom astropy-tutorials modifications begin: #} -{% set base_url = "https://github.com/astropy/astropy-tutorials/tree/master/docs/" %} -{% set nb_name = "{0}.ipynb".format("_".join(resources.unique_key.split('_')[2:])) %} -{% set nb_url = "/".join([base_url] + resources.unique_key.split('_')[:2] + [nb_name]) %} +{% block markdowncell scoped %} +{{ cell.source | markdown2rst }} +{% endblock markdowncell %} -.. raw:: html +{%- block rawcell scoped -%} +{%- if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %} +{{cell.source}} +{% endif -%} +{%- endblock rawcell -%} -
    -

    - Source notebook -

    +{% block headingcell scoped %} +{{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2rst }} +{% endblock headingcell %} -{{ super() }} -{% endblock footer %} +{% block unknowncell scoped %} +unknown type {{cell.type}} +{% endblock unknowncell %} diff --git a/docs/tutorials/FITS-header/FITS-header.ipynb b/docs/_static/tutorials/FITS-header/FITS-header.ipynb similarity index 100% rename from docs/tutorials/FITS-header/FITS-header.ipynb rename to docs/_static/tutorials/FITS-header/FITS-header.ipynb diff --git a/docs/tutorials/FITS-header/input_file.fits b/docs/_static/tutorials/FITS-header/input_file.fits similarity index 100% rename from docs/tutorials/FITS-header/input_file.fits rename to docs/_static/tutorials/FITS-header/input_file.fits diff --git a/docs/tutorials/FITS-header/requirements.txt b/docs/_static/tutorials/FITS-header/requirements.txt similarity index 100% rename from docs/tutorials/FITS-header/requirements.txt rename to docs/_static/tutorials/FITS-header/requirements.txt diff --git a/docs/tutorials/FITS-images/FITS-images.ipynb b/docs/_static/tutorials/FITS-images/FITS-images.ipynb similarity index 100% rename from docs/tutorials/FITS-images/FITS-images.ipynb rename to docs/_static/tutorials/FITS-images/FITS-images.ipynb diff --git a/docs/tutorials/FITS-images/requirements.txt b/docs/_static/tutorials/FITS-images/requirements.txt similarity index 100% rename from docs/tutorials/FITS-images/requirements.txt rename to docs/_static/tutorials/FITS-images/requirements.txt diff --git a/docs/tutorials/FITS-tables/FITS-tables.ipynb b/docs/_static/tutorials/FITS-tables/FITS-tables.ipynb similarity index 100% rename from docs/tutorials/FITS-tables/FITS-tables.ipynb rename to docs/_static/tutorials/FITS-tables/FITS-tables.ipynb diff --git a/docs/tutorials/FITS-tables/requirements.txt b/docs/_static/tutorials/FITS-tables/requirements.txt similarity index 100% rename from docs/tutorials/FITS-tables/requirements.txt rename to docs/_static/tutorials/FITS-tables/requirements.txt diff --git a/docs/tutorials/UVES/CaII-1.png b/docs/_static/tutorials/UVES/CaII-1.png similarity index 100% rename from docs/tutorials/UVES/CaII-1.png rename to docs/_static/tutorials/UVES/CaII-1.png diff --git a/docs/tutorials/UVES/CaII-2.png b/docs/_static/tutorials/UVES/CaII-2.png similarity index 100% rename from docs/tutorials/UVES/CaII-2.png rename to docs/_static/tutorials/UVES/CaII-2.png diff --git a/docs/tutorials/UVES/CaII-3.png b/docs/_static/tutorials/UVES/CaII-3.png similarity index 100% rename from docs/tutorials/UVES/CaII-3.png rename to docs/_static/tutorials/UVES/CaII-3.png diff --git a/docs/tutorials/UVES/CaII-lines-all.png b/docs/_static/tutorials/UVES/CaII-lines-all.png similarity index 100% rename from docs/tutorials/UVES/CaII-lines-all.png rename to docs/_static/tutorials/UVES/CaII-lines-all.png diff --git a/docs/tutorials/UVES/CaII-lines-one.png b/docs/_static/tutorials/UVES/CaII-lines-one.png similarity index 100% rename from docs/tutorials/UVES/CaII-lines-one.png rename to docs/_static/tutorials/UVES/CaII-lines-one.png diff --git a/docs/tutorials/UVES/CaII.png b/docs/_static/tutorials/UVES/CaII.png similarity index 100% rename from docs/tutorials/UVES/CaII.png rename to docs/_static/tutorials/UVES/CaII.png diff --git a/docs/tutorials/UVES/UVES.ipynb b/docs/_static/tutorials/UVES/UVES.ipynb similarity index 100% rename from docs/tutorials/UVES/UVES.ipynb rename to docs/_static/tutorials/UVES/UVES.ipynb diff --git a/docs/tutorials/UVES/requirements.txt b/docs/_static/tutorials/UVES/requirements.txt similarity index 100% rename from docs/tutorials/UVES/requirements.txt rename to docs/_static/tutorials/UVES/requirements.txt diff --git a/docs/tutorials/coordinates/HCG7_2MASS.tbl b/docs/_static/tutorials/coordinates/HCG7_2MASS.tbl similarity index 100% rename from docs/tutorials/coordinates/HCG7_2MASS.tbl rename to docs/_static/tutorials/coordinates/HCG7_2MASS.tbl diff --git a/docs/tutorials/coordinates/HCG7_SDSS_cutout.jpg b/docs/_static/tutorials/coordinates/HCG7_SDSS_cutout.jpg similarity index 100% rename from docs/tutorials/coordinates/HCG7_SDSS_cutout.jpg rename to docs/_static/tutorials/coordinates/HCG7_SDSS_cutout.jpg diff --git a/docs/tutorials/coordinates/HCG7_SDSS_photo.dat b/docs/_static/tutorials/coordinates/HCG7_SDSS_photo.dat similarity index 100% rename from docs/tutorials/coordinates/HCG7_SDSS_photo.dat rename to docs/_static/tutorials/coordinates/HCG7_SDSS_photo.dat diff --git a/docs/tutorials/coordinates/coordinates.ipynb b/docs/_static/tutorials/coordinates/coordinates.ipynb similarity index 100% rename from docs/tutorials/coordinates/coordinates.ipynb rename to docs/_static/tutorials/coordinates/coordinates.ipynb diff --git a/docs/tutorials/coordinates/requirements.txt b/docs/_static/tutorials/coordinates/requirements.txt similarity index 100% rename from docs/tutorials/coordinates/requirements.txt rename to docs/_static/tutorials/coordinates/requirements.txt diff --git a/docs/tutorials/plot-catalog/Young-Objects-Compilation.csv b/docs/_static/tutorials/plot-catalog/Young-Objects-Compilation.csv similarity index 100% rename from docs/tutorials/plot-catalog/Young-Objects-Compilation.csv rename to docs/_static/tutorials/plot-catalog/Young-Objects-Compilation.csv diff --git a/docs/tutorials/plot-catalog/plot-catalog.ipynb b/docs/_static/tutorials/plot-catalog/plot-catalog.ipynb similarity index 100% rename from docs/tutorials/plot-catalog/plot-catalog.ipynb rename to docs/_static/tutorials/plot-catalog/plot-catalog.ipynb diff --git a/docs/tutorials/plot-catalog/requirements.txt b/docs/_static/tutorials/plot-catalog/requirements.txt similarity index 100% rename from docs/tutorials/plot-catalog/requirements.txt rename to docs/_static/tutorials/plot-catalog/requirements.txt diff --git a/docs/tutorials/plot-catalog/simple_table.csv b/docs/_static/tutorials/plot-catalog/simple_table.csv similarity index 100% rename from docs/tutorials/plot-catalog/simple_table.csv rename to docs/_static/tutorials/plot-catalog/simple_table.csv diff --git a/docs/tutorials/quantities/quantities.ipynb b/docs/_static/tutorials/quantities/quantities.ipynb similarity index 100% rename from docs/tutorials/quantities/quantities.ipynb rename to docs/_static/tutorials/quantities/quantities.ipynb diff --git a/docs/tutorials/quantities/requirements.txt b/docs/_static/tutorials/quantities/requirements.txt similarity index 100% rename from docs/tutorials/quantities/requirements.txt rename to docs/_static/tutorials/quantities/requirements.txt diff --git a/docs/tutorials/redshift-plot/ang_dist.png b/docs/_static/tutorials/redshift-plot/ang_dist.png similarity index 100% rename from docs/tutorials/redshift-plot/ang_dist.png rename to docs/_static/tutorials/redshift-plot/ang_dist.png diff --git a/docs/tutorials/redshift-plot/redshift-plot.ipynb b/docs/_static/tutorials/redshift-plot/redshift-plot.ipynb similarity index 100% rename from docs/tutorials/redshift-plot/redshift-plot.ipynb rename to docs/_static/tutorials/redshift-plot/redshift-plot.ipynb diff --git a/docs/tutorials/redshift-plot/requirements.txt b/docs/_static/tutorials/redshift-plot/requirements.txt similarity index 100% rename from docs/tutorials/redshift-plot/requirements.txt rename to docs/_static/tutorials/redshift-plot/requirements.txt diff --git a/docs/tutorials/vo/README.md b/docs/_static/tutorials/vo/README.md similarity index 100% rename from docs/tutorials/vo/README.md rename to docs/_static/tutorials/vo/README.md diff --git a/docs/tutorials/vo/conesearch.ipynb b/docs/_static/tutorials/vo/conesearch.ipynb similarity index 100% rename from docs/tutorials/vo/conesearch.ipynb rename to docs/_static/tutorials/vo/conesearch.ipynb diff --git a/scripts/convert.py b/scripts/convert.py index af2528fde..279ae4359 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -1,5 +1,5 @@ # Standard library -from os import path, walk, remove +from os import path, walk, remove, makedirs # Third-party from astropy import log as logger @@ -14,7 +14,7 @@ class NBConverter(object): - def __init__(self, nb_path, output_path=None): + def __init__(self, nb_path, output_path=None, template_file=None): self.nb_path = path.abspath(nb_path) fn = path.basename(self.nb_path) self.path_only = path.dirname(self.nb_path) @@ -25,6 +25,11 @@ def __init__(self, nb_path, output_path=None): else: self.output_path = self.path_only + if template_file is not None: + self.template_file = path.abspath(template_file) + else: + self.template_file = None + # the executed notebook self._executed_nb_path = path.join(self.output_path, 'exec_{0}'.format(fn)) @@ -93,9 +98,15 @@ def convert(self, remove_executed=False): # path to store extra files, like plots generated resources['output_files_dir'] = path.join(self.output_path, 'nboutput') + # + resources['metadata'] = {'derp': 42} + # Exports the notebook to RST logger.debug('Exporting notebook to RST...') exporter = RSTExporter() + + if self.template_file: + exporter.template_file = self.template_file output, resources = exporter.from_filename(self._executed_nb_path, resources=resources) @@ -138,6 +149,10 @@ def convert(self, remove_executed=False): 'top-level path to a directory containing ' 'notebook files to process.') + parser.add_argument('--template', default=None, dest='template_file', + help='The path to a jinja2 template file for the ' + 'notebook to RST conversion.') + parser.add_argument('--output-path', default=None, dest='output_path', help='The path to save all executed or converted ' 'notebook files. If not specified, the executed/' @@ -159,6 +174,18 @@ def convert(self, remove_executed=False): else: # anything >= 2 logger.setLevel(logging.ERROR) + # make sure output path exists + output_path = args.output_path + if output_path is not None: + output_path = path.abspath(output_path) + makedirs(output_path, exist_ok=True) + + # make sure the template file exists + template_file = args.template_file + if template_file is not None and not path.exists(template_file): + raise IOError("Couldn't find RST template file at {0}" + .format(template_file)) + if path.isdir(args.nbfile_or_path): # It's a path, so we need to walk through recursively and find any # notebook files @@ -174,7 +201,9 @@ def convert(self, remove_executed=False): continue if ext == '.ipynb': - nbc = NBConverter(full_path, output_path=args.output_path) + nbc = NBConverter(full_path, + output_path=output_path, + template_file=template_file) nbc.execute() if not args.exec_only: @@ -182,7 +211,9 @@ def convert(self, remove_executed=False): else: # It's a single file, so convert it - nbc = NBConverter(args.nbfile_or_path, output_path=args.output_path) + nbc = NBConverter(args.nbfile_or_path, + output_path=output_path, + template_file=template_file) nbc.execute() if not args.exec_only: From d0b08e96c7f59b5869383fed0e3b602af8f58244 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sat, 21 Oct 2017 11:23:05 -0400 Subject: [PATCH 065/113] added makefile option --- docs/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/Makefile b/docs/Makefile index fb03f26e6..ff202866c 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -34,6 +34,11 @@ help: @echo " man to make manual pages" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" + @echo " tutorials to convert all tutorials to RST" + +tutorials: + python ../scripts/convert.py _static/tutorials/ --output-path=rst-tutorials -v \ + --template=_static/astropy.tpl clean: -rm -rf $(BUILDDIR) From 77bf998f233281221e8743fed407f02e7e0b35e1 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 09:50:52 -0400 Subject: [PATCH 066/113] use posixpath --- docs/_static/astropy.tpl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/_static/astropy.tpl b/docs/_static/astropy.tpl index 9e89e83e5..369661fb5 100644 --- a/docs/_static/astropy.tpl +++ b/docs/_static/astropy.tpl @@ -50,15 +50,16 @@ {% endblock stream %} {% block data_svg %} -.. image:: {{ output.metadata.filenames['image/svg+xml'] | urlencode }} +.. image:: {{ output.metadata.filenames['image/svg+xml'] | posix_path }} {% endblock data_svg %} {% block data_png %} -.. image:: {{ output.metadata.filenames['image/png'] | urlencode }} +.. image:: {{ output.metadata.filenames['image/png'] | posix_path }} + {% endblock data_png %} {% block data_jpg %} -.. image:: {{ output.metadata.filenames['image/jpeg'] | urlencode }} +.. image:: {{ output.metadata.filenames['image/jpeg'] | posix_path }} {% endblock data_jpg %} {% block data_latex %} From f53214216a25873db36ced8e7afcf5acf1906f6c Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 09:51:05 -0400 Subject: [PATCH 067/113] remove scripts from setup.py --- setup.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/setup.py b/setup.py index c5a0405e7..cae885cdd 100755 --- a/setup.py +++ b/setup.py @@ -60,11 +60,6 @@ # modify distutils' behavior. cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE) -# Treat everything in scripts except README* as a script to be installed -scripts = [fname for fname in glob.glob(os.path.join('scripts', '*')) - if not os.path.basename(fname).startswith('README')] - - # Get configuration information from all of the various subpackages. # See the docstring for setup_helpers.update_package_files for more # details. @@ -101,7 +96,6 @@ setup(name=PACKAGENAME, version=VERSION, description=DESCRIPTION, - scripts=scripts, install_requires=metadata.get('install_requires', 'astropy').strip().split(), author=AUTHOR, author_email=AUTHOR_EMAIL, From c659b3f0ee361c2aed4a3e379c37dd79e00fb2ed Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 09:51:28 -0400 Subject: [PATCH 068/113] ignore generated tutorials --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f58332729..55ce56513 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .ipynb_checkpoints/ docs/_build/ +docs/rst-tutorials/ IPython-* *.fits *.pdf From 1dd89e5d9fb3e3ebacbdba317922a84009e61262 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 09:51:41 -0400 Subject: [PATCH 069/113] generate toctree from generated rst files --- docs/index.rst | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 71f57deb0..5ba1fee27 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -13,15 +13,7 @@ List of tutorials :maxdepth: 1 :glob: - tutorials/coordinates/coordinates.ipynb - tutorials/FITS-header/FITS-header.ipynb - tutorials/FITS-images/FITS-images.ipynb - tutorials/FITS-tables/FITS-tables.ipynb - tutorials/plot-catalog/plot-catalog.ipynb - tutorials/quantities/quantities.ipynb - tutorials/redshift-plot/redshift-plot.ipynb - tutorials/UVES/UVES.ipynb - tutorials/vo/conesearch.ipynb + rst-tutorials/* Contributing ------------ From ae09207fc0cb66828b905084c5d1897521ea6f3f Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 09:51:59 -0400 Subject: [PATCH 070/113] don't specify full path to nboutput for plots --- scripts/convert.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/convert.py b/scripts/convert.py index 279ae4359..677478221 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -96,10 +96,7 @@ def convert(self, remove_executed=False): resources['unique_key'] = self.nb_name # path to store extra files, like plots generated - resources['output_files_dir'] = path.join(self.output_path, 'nboutput') - - # - resources['metadata'] = {'derp': 42} + resources['output_files_dir'] = 'nboutput' # Exports the notebook to RST logger.debug('Exporting notebook to RST...') From 336140e66557a40e100a53c8fdc33048f3ca9efc Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 09:52:09 -0400 Subject: [PATCH 071/113] travis config --- .travis.yml | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c3fd1e5a..967f9fea1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,49 @@ language: c -sudo: false - os: - linux +sudo: false + +addons: + apt: + packages: + - graphviz + - texlive-latex-extra + - dvipng + env: global: + - PYTHON_VERSION=3.6 - - SETUP_XVFB=True - - CONDA_ENVIRONMENT=conda-environment.yml - - CONDA_DEPENDENCIES='jupyter notebook ipython runipy' - - GH_REF: github.com/astropy/astropy-tutorials.git - - secure: "NBZlEg//sDYvJikqXESLsx/WA1Nj7fAH2mJfI8ZVMnolvyjJuLdEMxxEYFP8t6U/iieSSrgUkgP94yy5Oq6iJRjj7ThGCdcjgvgWTQCzoQgEVDc5SzdJGyGs30VC+8t7GTobzMe086HX16SJRvsIumqXdmRcJjAdMCyhMUxLoUg=" + - NUMPY_VERSION=stable + - ASTROPY_VERSION=stable + - EVENT_TYPE='pull_request push' + + - CONDA_ENVIRONMENT='conda-environment.yml' + - CONDA_DEPENDENCIES='' + - CONDA_CHANNELS='astropy-ci-extras astropy' + - PIP_DEPENDENCIES='' + +# matrix: + +# # Don't wait for allowed failures +# fast_finish: true + +# include: + +# - os: linux +# env: SETUP_CMD='test --coverage' install: - - git clone git://github.com/astropy/ci-helpers.git + + - git clone --depth 1 git://github.com/astropy/ci-helpers.git - source ci-helpers/travis/setup_conda.sh script: - - python prepare_deploy.py run - -deploy: - provider: script - script: ./travis_deploy - on: - repo: astropy/astropy-tutorials - branch: master + # - | + # python scripts/convert.py docs/_static/tutorials/ -v + # --output-path=docs/rst-tutorials + # --template=docs/_static/astropy.tpl + - python scripts/convert.py docs/_static/tutorials/ --exec-only -v + From 3212caaeec48adc623df80e3786a3fc55f72b709 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 09:57:35 -0400 Subject: [PATCH 072/113] also install nbconvert --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 967f9fea1..d63d5df35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ env: - EVENT_TYPE='pull_request push' - CONDA_ENVIRONMENT='conda-environment.yml' - - CONDA_DEPENDENCIES='' + - CONDA_DEPENDENCIES='jupyter ipython nbconvert' - CONDA_CHANNELS='astropy-ci-extras astropy' - PIP_DEPENDENCIES='' From 2932b5a3b9a03aa276e7b614270700cf65841b2a Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 10:04:28 -0400 Subject: [PATCH 073/113] add scipy to requirements - needed in coordinates cross-matching --- conda-environment.yml | 1 + docs/_static/tutorials/coordinates/requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/conda-environment.yml b/conda-environment.yml index 537ffbc61..fd5e64257 100644 --- a/conda-environment.yml +++ b/conda-environment.yml @@ -10,3 +10,4 @@ dependencies: - astroquery=0.3.6 - matplotlib=2.0.2 - numpy=1.13.1 + - scipy=0.19 # needed for coordinates cross-matching diff --git a/docs/_static/tutorials/coordinates/requirements.txt b/docs/_static/tutorials/coordinates/requirements.txt index 7f537aa82..eb2904129 100644 --- a/docs/_static/tutorials/coordinates/requirements.txt +++ b/docs/_static/tutorials/coordinates/requirements.txt @@ -3,3 +3,4 @@ numpy matplotlib astroquery IPython +scipy From e0525014280a8dcb3e03a7ca190fa172c4d9d4f4 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 10:09:37 -0400 Subject: [PATCH 074/113] install dev version of nbconvert --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d63d5df35..5ee13bb87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,9 +21,12 @@ env: - EVENT_TYPE='pull_request push' - CONDA_ENVIRONMENT='conda-environment.yml' - - CONDA_DEPENDENCIES='jupyter ipython nbconvert' + - CONDA_DEPENDENCIES='jupyter ipython' - CONDA_CHANNELS='astropy-ci-extras astropy' - - PIP_DEPENDENCIES='' + + # We need to install the master/latest version of nbconvert because it has support for + # allowing exceptions in individual cells: + - PIP_DEPENDENCIES='git+https://github.com/jupyter/nbconvert' # matrix: From cdbac4828993d24f610dafde399ea431af8c8dad Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 10:45:51 -0400 Subject: [PATCH 075/113] add nb->rst build to conf.py --- docs/conf.py | 15 ++++++++ scripts/convert.py | 92 +++++++++++++++++++++++++++++----------------- 2 files changed, 74 insertions(+), 33 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index e13b0b0b7..01ad17dbd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -131,3 +131,18 @@ # -- Resolving issue number to links in changelog ----------------------------- github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) + + +# -- Run and convert the notebook files to RST -------------------------------- + +_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +_scripts_path = os.path.join(_root, 'scripts') +if _scripts_path not in sys.path: + sys.path.insert(1, _scripts_path) + +from convert import process_notebooks +nb_tutorials_path = os.path.join(_root, 'docs', '_static', 'tutorials') +template_path = os.path.join(_root, 'docs', '_static', 'astropy.tpl') +rst_output_path = os.path.join(_root, 'docs', 'rst-tutorials') +process_notebooks(nb_tutorials_path, output_path=rst_output_path, + template_file=template_path) diff --git a/scripts/convert.py b/scripts/convert.py index 677478221..607beb776 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -14,7 +14,8 @@ class NBConverter(object): - def __init__(self, nb_path, output_path=None, template_file=None): + def __init__(self, nb_path, output_path=None, template_file=None, + overwrite=False): self.nb_path = path.abspath(nb_path) fn = path.basename(self.nb_path) self.path_only = path.dirname(self.nb_path) @@ -30,6 +31,8 @@ def __init__(self, nb_path, output_path=None, template_file=None): else: self.template_file = None + self.overwrite = overwrite + # the executed notebook self._executed_nb_path = path.join(self.output_path, 'exec_{0}'.format(fn)) @@ -55,6 +58,12 @@ def execute(self, write=True): """ + if path.exists(self._executed_nb_path) and not self.overwrite: + logger.debug("Executed notebook already exists at {0}. Use " + "overwrite=True or --overwrite (at cmd line) to re-run" + .format(self._executed_nb_path)) + return return self._executed_nb_path + # Execute the notebook logger.debug('Executing notebook...') executor = ExecutePreprocessor(timeout=900, kernel_name='python3') @@ -117,6 +126,52 @@ def convert(self, remove_executed=False): return output_file_path +def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): + """ + Execute and optionally convert the specified notebook file or directory of + notebook files. + + This is a wrapper around the ``NBConverter`` class that does file handling. + + Parameters + ---------- + nbfile_or_path : str + Either a single notebook filename or a path containing notebook files. + exec_only : bool, optional + Just execute the notebooks, don't run them. + **kwargs + Any other keyword arguments are passed to the ``NBConverter`` init. + + """ + if path.isdir(nbfile_or_path): + # It's a path, so we need to walk through recursively and find any + # notebook files + for root, dirs, files in walk(nbfile_or_path): + for name in files: + _,ext = path.splitext(name) + full_path = path.join(root, name) + + if 'ipynb_checkpoints' in full_path: # skip checkpoint saves + continue + + if name.startswith('exec'): # notebook already executed + continue + + if ext == '.ipynb': + nbc = NBConverter(full_path, **kwargs) + nbc.execute() + + if not exec_only: + nbc.convert() + + else: + # It's a single file, so convert it + nbc = NBConverter(nbfile_or_path, **kwargs) + nbc.execute() + + if not exec_only: + nbc.convert() + if __name__ == "__main__": from argparse import ArgumentParser import logging @@ -183,35 +238,6 @@ def convert(self, remove_executed=False): raise IOError("Couldn't find RST template file at {0}" .format(template_file)) - if path.isdir(args.nbfile_or_path): - # It's a path, so we need to walk through recursively and find any - # notebook files - for root, dirs, files in walk(args.nbfile_or_path): - for name in files: - _,ext = path.splitext(name) - full_path = path.join(root, name) - - if 'ipynb_checkpoints' in full_path: # skip checkpoint saves - continue - - if name.startswith('exec'): # notebook already executed - continue - - if ext == '.ipynb': - nbc = NBConverter(full_path, - output_path=output_path, - template_file=template_file) - nbc.execute() - - if not args.exec_only: - nbc.convert() - - else: - # It's a single file, so convert it - nbc = NBConverter(args.nbfile_or_path, - output_path=output_path, - template_file=template_file) - nbc.execute() - - if not args.exec_only: - nbc.convert() + process_notebooks(args.nbfile_or_path, exec_only=args.exec_only, + output_path=output_path, template_file=template_file, + overwrite=args.overwrite) From 7abb0903dfb1fb0eb67f9bc066badcb5f101d9a3 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 10:50:27 -0400 Subject: [PATCH 076/113] add readthedocs config --- readthedocs.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 readthedocs.yml diff --git a/readthedocs.yml b/readthedocs.yml new file mode 100644 index 000000000..728fe3a12 --- /dev/null +++ b/readthedocs.yml @@ -0,0 +1,8 @@ +conda: + file: conda-environment.yml + +python: + setup_py_install: false + +formats: + - none From 7f1f9034abce0b4ce8dff83263241c192f8cb034 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 10:51:49 -0400 Subject: [PATCH 077/113] argh typo --- scripts/convert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/convert.py b/scripts/convert.py index 607beb776..354b6a9f1 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -62,7 +62,7 @@ def execute(self, write=True): logger.debug("Executed notebook already exists at {0}. Use " "overwrite=True or --overwrite (at cmd line) to re-run" .format(self._executed_nb_path)) - return return self._executed_nb_path + return self._executed_nb_path # Execute the notebook logger.debug('Executing notebook...') From 00007dca6b8a73d3d063f009992dac9569a0e1c4 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 10:59:06 -0400 Subject: [PATCH 078/113] update rtd environment to include nbconvert --- .rtd-environment.yml | 16 ++++++++++++++++ conda-environment.yml | 1 + readthedocs.yml | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .rtd-environment.yml diff --git a/.rtd-environment.yml b/.rtd-environment.yml new file mode 100644 index 000000000..dad76d046 --- /dev/null +++ b/.rtd-environment.yml @@ -0,0 +1,16 @@ +name: tutorials + +channels: + - astropy + +dependencies: + - python=3.6 + - jupyter=4.3 + - IPython=6.1.0 + - astropy=2.0 + - astroquery=0.3.6 + - matplotlib=2.0.2 + - numpy=1.13.1 + - scipy=0.19 # needed for coordinates cross-matching + - pip: + - git+https://github.com/jupyter/nbconvert diff --git a/conda-environment.yml b/conda-environment.yml index fd5e64257..e3193deec 100644 --- a/conda-environment.yml +++ b/conda-environment.yml @@ -5,6 +5,7 @@ channels: dependencies: - python=3.6 + - jupyter=4.3 - IPython=6.1.0 - astropy=2.0 - astroquery=0.3.6 diff --git a/readthedocs.yml b/readthedocs.yml index 728fe3a12..ef49fa6aa 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -1,5 +1,5 @@ conda: - file: conda-environment.yml + file: .rtd-environment.yml python: setup_py_install: false From 239c0ab9b02fdbb0c860b4f4698eccf8bc931beb Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 12:30:44 -0400 Subject: [PATCH 079/113] add jupyter and notebook to requirements --- .rtd-environment.yml | 3 ++- conda-environment.yml | 3 ++- pip-requirements.txt | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rtd-environment.yml b/.rtd-environment.yml index dad76d046..07c029fce 100644 --- a/.rtd-environment.yml +++ b/.rtd-environment.yml @@ -5,12 +5,13 @@ channels: dependencies: - python=3.6 - - jupyter=4.3 - IPython=6.1.0 - astropy=2.0 - astroquery=0.3.6 - matplotlib=2.0.2 - numpy=1.13.1 - scipy=0.19 # needed for coordinates cross-matching + - jupyter=1.0 + - notebook=5.0 - pip: - git+https://github.com/jupyter/nbconvert diff --git a/conda-environment.yml b/conda-environment.yml index e3193deec..ce27cd11b 100644 --- a/conda-environment.yml +++ b/conda-environment.yml @@ -5,10 +5,11 @@ channels: dependencies: - python=3.6 - - jupyter=4.3 - IPython=6.1.0 - astropy=2.0 - astroquery=0.3.6 - matplotlib=2.0.2 - numpy=1.13.1 - scipy=0.19 # needed for coordinates cross-matching + - jupyter=1.0 + - notebook=5.0 diff --git a/pip-requirements.txt b/pip-requirements.txt index cd1f31faa..f8d6cc07f 100644 --- a/pip-requirements.txt +++ b/pip-requirements.txt @@ -3,3 +3,4 @@ astropy==2.0.2 astroquery==0.3.6 matplotlib==2.0.2 numpy==1.13.1 +jupyter==1.0 From 14256860a40153f6584f18f9fc78d2b3f2271cc6 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 12:45:27 -0400 Subject: [PATCH 080/113] ensure output dir exists --- scripts/convert.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/convert.py b/scripts/convert.py index 354b6a9f1..b54e6f69f 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -23,6 +23,7 @@ def __init__(self, nb_path, output_path=None, template_file=None, if output_path is not None: self.output_path = output_path + makedirs(self.output_path, exist_ok=True) else: self.output_path = self.path_only From 5e8bf752f53b973f0ca32460b9230f759b4657f1 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 13:05:17 -0400 Subject: [PATCH 081/113] cleaning up old deploy scripts --- DEPLOY.md | 29 ------- deploy | 124 --------------------------- docs/Makefile | 4 - check_env.py => scripts/check_env.py | 0 travis_deploy | 15 ---- 5 files changed, 172 deletions(-) delete mode 100644 DEPLOY.md delete mode 100755 deploy rename check_env.py => scripts/check_env.py (100%) delete mode 100755 travis_deploy diff --git a/DEPLOY.md b/DEPLOY.md deleted file mode 100644 index 5331ddf7f..000000000 --- a/DEPLOY.md +++ /dev/null @@ -1,29 +0,0 @@ -Deploying -========= - -All notebooks in this repository aren't necessarily live. They have to be 'published' in order to appear on the main astropy tutorials web page. To mark a tutorial as published, you must edit the notebook metadata set the published key to `true`. For example, if I wanted to publish the Quantities tutorial, I would edit the notebook metadata for `tutorials/Quantities/Quantities.ipynb` to include a line `"published": true`. - -Once a tutorial is marked as published, the automated deploy script will find the corresponding notebook file, convert it to HTML, and include it in a push to the gh-pages branch of the repository. Only repository admins can deploy because it requires direct commit rights to the main `astropy-tutorials` repository. - -To actually deploy the tutorials, just run the deploy script: - - ./deploy - -and follow the prompts. By default, the script takes the tutorials in the master branch, runs them, converts them to HTML, and pushes to the `gh-pages` branch. __If you have any uncomitted changes in your master branch the deploy script will wipe them!__ - -Test deploy ------------ - -If you'd instead like to test running and converting the notebooks, use the `prepare_deploy.py`script. You can run the notebook files with: - - python prepare_deploy.py run - -and convert them with: - - python prepare_deploy.py convert - -or combine the commands: - - python prepare_deploy.py run convert - -The converted html files will appear in the `html` path. \ No newline at end of file diff --git a/deploy b/deploy deleted file mode 100755 index 196a3b522..000000000 --- a/deploy +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash - -# this conditional assignment means you can do things like: -# GH_REMOTE=myremote ./deploy -# to set these to something other than the default - -# branches and remote for pushing to github -: ${GH_PAGESBRANCH=gh-pages} -: ${GH_REMOTE=origin} - -# if not interactive, automatically "yes" things but don't show anything -: ${INTERACTIVE=true} -: ${CURRENT_BRANCH_NAME="$(git symbolic-ref --quiet --short HEAD)"} - -if [ -z "$CURRENT_BRANCH_NAME" ]; then - echo "Could not determine current branch. Cannot continue with deployment." - exit 1 -fi - -giveup_message () { - echo "\n" - echo "You're now in an orphaned test deploy branch." - echo "To get back to normal you can run the following:" - echo " git checkout -f $CURRENT_BRANCH_NAME" - echo " git clean -f" - echo " git branch -D $GH_PAGESBRANCH" -} - -promptifinteractive () { - # first argument is message, second is non-interactive answer, all others passed to read - if [ "$INTERACTIVE" = true ] ; then - read -p "$1" -r "${@:3}" - else - echo $1 $2 - REPLY=$2 - fi -} - -echo "*****************************************************************" -echo "WARNING! This script will remove the local $GH_PAGESBRANCH branch," -echo "build the notebook files into HTML, then push to remote gh-pages" -echo "located here: $GH_REMOTE/gh-pages." -echo -echo "Make sure you have no uncommitted changes in your current branch" -echo "as these may be overwritten!" -echo -promptifinteractive "Are you sure you want to do this? [y/N] " y -n 1 -echo -if [[ $REPLY =~ ^[Yy]$ ]] -then - # first run the notebooks - OUTPUT=`python setup.py build_sphinx` - if [[ $OUTPUT == *ERROR* ]] - then - echo "Error running notebook files!"; - exit; - fi - - # remove the old $GH_PAGESBRANCH branch - OUTPUT=`git branch -D $GH_PAGESBRANCH` - if [[ $OUTPUT == *fatal* ]] - then - echo "Error deleting branch '$GH_PAGESBRANCH'."; - exit; - fi - - # Create a new "orphaned" branch -- we don't need history for - # the built products - git checkout --orphan $GH_PAGESBRANCH - - # Copy the built files to a tmp location - cp -R docs/_build/html _tmp - - # This will delete all of the git-managed files here - git rm -rf . - - # Now copy the html back into here - cp -R _tmp/* . - rm -rf _tmp - - git add * - git commit -m "Generated from sources" - - promptifinteractive "Would you like to preview the rendered HTML? [y/N] " N -n 1 - if [[ $REPLY =~ ^[Yy]$ ]]; then - echo - echo - open index.html - else - echo - fi - - promptifinteractive "Are you sure you want to push to the remote branch '$GH_PAGESBRANCH' on the remote '$GH_REMOTE'? [y/N] " y -n 1 - if [[ $REPLY =~ ^[Yy]$ ]]; then - echo - git ls-remote --exit-code $GH_REMOTE > /dev/null 2> /dev/null - while [[ $? != 0 ]] - do - promptifinteractive "Could not communicate with remote '$GH_REMOTE'. Enter an alternate remote name (or 'quit' to give up):" quit - if [[ $REPLY = "quit" ]]; then - giveup_message - exit - fi - GH_REMOTE=$REPLY - - git ls-remote --exit-code $GH_REMOTE > /dev/null 2> /dev/null - done - - echo "Pushing to '$GH_PAGESBRANCH' on remote '$GH_REMOTE'" - if [ "$INTERACTIVE" = true ] ; then - git push -f $GH_REMOTE $GH_PAGESBRANCH - else - # we do this with nothing to stdout because otherwise it might reveal secret tokens - git push -f --quiet $GH_REMOTE $GH_PAGESBRANCH >/dev/null 2>&1 - echo "Silent push finished." - fi - - git checkout -f $CURRENT_BRANCH_NAME - git clean -f - git branch -D $GH_PAGESBRANCH - else - giveup_message - fi -fi diff --git a/docs/Makefile b/docs/Makefile index ff202866c..2dbf56a87 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -36,10 +36,6 @@ help: @echo " linkcheck to check all external links for integrity" @echo " tutorials to convert all tutorials to RST" -tutorials: - python ../scripts/convert.py _static/tutorials/ --output-path=rst-tutorials -v \ - --template=_static/astropy.tpl - clean: -rm -rf $(BUILDDIR) -rm -rf api diff --git a/check_env.py b/scripts/check_env.py similarity index 100% rename from check_env.py rename to scripts/check_env.py diff --git a/travis_deploy b/travis_deploy deleted file mode 100755 index c9a518518..000000000 --- a/travis_deploy +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# The key element here is using ``travis encrypt GH_TOKEN=`` -# and then adding the resulting secure key/value pair to .travis.yml . For security, -# probably best to use an account that only has access to this specific repo, not -# someone's personal token with general access to all of their stuff. - -echo "Adding deployment remote" -git remote add deploy "https://${GH_TOKEN}@${GH_REF}" - -export CURRENT_BRANCH_NAME="$(git rev-parse HEAD)" -export INTERACTIVE=false -export GH_REMOTE=deploy -export GH_PAGESBRANCH="test-gh-pages" # remove this to get deployment on the "real branch" -./deploy \ No newline at end of file From e6c51481ddf6ffa330a0d9cc12c034b04b2281ef Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 13:25:14 -0400 Subject: [PATCH 082/113] added some developer documentation --- docs/dev.rst | 132 +++++++++++++++++++++++++++---------------------- docs/index.rst | 12 ++++- 2 files changed, 82 insertions(+), 62 deletions(-) diff --git a/docs/dev.rst b/docs/dev.rst index 3ada960b6..1323b0be6 100644 --- a/docs/dev.rst +++ b/docs/dev.rst @@ -1,75 +1,87 @@ -Tutorials are written as Jupyter notebooks on the ``master`` branch in -``docs/_static`` (or are sym-linked there). These notebook files do not contain -output in order to simplify version-controlling the files. - -The rendered astropy-tutorials site is built using Sphinx using the astropy -theme to look like the main documentation. Sphinx requires RST (restructured -text) files for its build process, so we need an intermediate step to (a) run -the notebooks to produce output, and (b) convert the notebook files into RST -files. We also need to be able to test that the notebooks run successfully in an -automated way. On the rendered RST pages, we want to include links to (a) the -source notebook, (b) a Binder instance with a live version of the source -notebook. +Documentation for developers +============================ + +Overview +-------- + +Tutorials are written as Jupyter notebooks on the ``master`` branch of the +``astropy/astropy-tutorials`` repository in ``docs/_static/tutorials/``. These +notebook files do not contain output in order to simplify version-controlling +the files. + +The rendered Astropy-tutorials site is built using Sphinx with the Astropy theme +to look like the main documentation. Sphinx requires restructured text (RST) +files for its build process, so use an intermediate step to run the notebooks to +produce output, and then convert the notebook files into RST files. + +We use our own run-and-convert machinery using ``nbconvert``. We use the same +script that converts the notebooks to RST to test the notebooks on travis by +simply executing the notebooks and ignoring the output. + +We use `readthedocs `_ to do the Sphinx build, which is what +allows us to preserve the version history of the tutorials. The notebooks are +first converted to RST files during the Sphinx build by doing the conversion +at the end of the `Sphinx configuration file +`_. + +Why not use nbsphinx? +--------------------- Both running and converting the notebooks is handled automatically by the Sphinx plugin ``nbsphinx``, but it doesn't support all of the features we want. In particular, there is no supported way to modify the template file that controls -the output RST file that gets generated from each notebook; we definitely want -to be able to modify the template so we can add the links mentioned above. - -We will instead implement our own run-and-convert machinery using ``nbconvert`` -(which is what ``nbsphinx`` uses internally, but just doesn't expose all of the -bells and whistles). An advantage to doing this is we can use the same script -or machinery to test the notebooks as we use to run and convert them to RST. - -There are three possibilities for how to deploy the site: - -1. We use a custom deploy script that runs the Sphinx build locally and pushes - to a ``gh-pages`` branch to be rendered as static HTML. This deploy script - is executed by travis, as is done currently. -2. We use readthedocs to do the Sphinx build. The advantage to this is that the - tutorials would support a version history. If we "release" a new version of - the tutorials with each major Astropy release, this history would show up - for free on readthedocs. The disadvantage to this is that readthedocs is a - lot more finicky than travis, and we have a limited build time (which might - be ok right now, but might not scale to 10's of tutorials). At least a few of - our notebooks access the web, or have components that take some time to - execute, both of which can sometimes lead to failures on readthedocs. -3. We use travis to run the notebooks and convert to RST, then push to a special - branch (e.g., "``rendered``") that readthedocs runs off of. This way, the - only build that gets done on readthedocs is a pretty standard, static Sphinx - build, but we still get all of the versioning benefits of using RTD. The - disadvantage here is that it makes the deploy system more complex in that - there are multiple stages, and more opportunities for things to break. In - this scheme, we'd have to do releases (tag versions) from the ``rendered`` - branch. +the output RST file that gets generated from each notebook; we want to be able +to modify the template so we can add the links mentioned above. -Marking a cell with an intentional error ----------------------------------------- +Tutorials directory structure +----------------------------- + +The notebook files must be written as a single Jupyter notebook in a directory +within the ``docs/_static/tutorials`` directory. The name of the notebook must +be the same as the subdirectory name. This is just needed for auto-generating +links to the source notebooks from the generated RST pages. + +Testing notebook execution +-------------------------- + +You can use the custom nbconvert script in the astropy-tutorials repository to +test that the tutorials all execute correctly. From the top-level repository +path:: -Add to cell metadata: ``"tags": ["raises-exception"]`` + python scripts/convert.py docs/_static/tutorials -v --exec-only -Other notes ------------ +Running the convert script with the flag ``--exec-only`` will just execute the +notebooks and won't generate RST files. If you have already run the notebooks +once, you may need to also specify the ``-o`` or ``--overwrite`` flag: by +default, the script will only execute notebooks that haven't already been +executed. The ``-v`` flag just tells the script to output more "verbose" +messages, which you may or may not want. -* Notebook files must have the same name as the directory they are in. This is - just needed for auto-link-generation purposes in the RST template. +The above command will execute all notebooks in any subdirectory of the +``docs/_static/tutorials`` path. If you want to just execute a single notebook, +you can specify the path to a single notebook file, e.g.:: -* For now, the tutorials will just be listed on the main page in a table of - contents. If we want to switch to ``sphinx-gallery`` or some fancier layout, - we can, but I suggest we do that in a separate PR + python scripts/convert.py docs/_static/tutorials/coordinates/coordinates.ipynb -v --exec-only +You can also do this when running and generating RST files, which can be useful +when writing a new tutorial to make sure it renders in RST properly. To do +this, just remove the ``--exec-only`` flag:: - On each rendered page, we want: - - Link to notebook on Binder - - Link to download all notebooks and content + python scripts/convert.py docs/_static/tutorials/coordinates/coordinates.ipynb -v +Releases +-------- - Travis builds (@eteq): - - Test (nbconvert) - - Run sphinx - - Deploy +We will release a new version of the tutorials with each major release of the +Astropy core package; i.e. we will release for 3.0, 3.1, etc., but not for +bugfix releases like 2.0.3, etc. With each release, we update the pinned +versions of the global dependency files (``conda-envirionment.yml`` for Anaconda +and ``pip-requirements.txt`` for pip). + +Marking a cell with an intentional error +---------------------------------------- +Edit the cell metadata of the cell in which you would like to raise an exception +and add the following to the top-level JSON: ``"tags": ["raises-exception"]`` +This tag is recognized by the latest (master) version of nbconvert. -TODO: -- Add notebook name to notebook metadata diff --git a/docs/index.rst b/docs/index.rst index 5ba1fee27..d6f540021 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,8 +15,8 @@ List of tutorials rst-tutorials/* -Contributing ------------- +For contributors +---------------- We welcome feedback and improvements to these tutorials via the `Astropy Tutorials repo on Github `_. If @@ -37,3 +37,11 @@ out the `open issues for new content `_. This is a collaborative effort and we are looking for contributions and ideas from users like you! + +For developers +-------------- + +.. toctree:: + :maxdepth: 1 + + dev From 55f751f43a84fac6456c2ddfc42f063fe68d86db Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Sun, 22 Oct 2017 13:40:19 -0400 Subject: [PATCH 083/113] add binder link to each rendered page --- docs/_static/astropy.tpl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/_static/astropy.tpl b/docs/_static/astropy.tpl index 369661fb5..1af1b32e8 100644 --- a/docs/_static/astropy.tpl +++ b/docs/_static/astropy.tpl @@ -10,6 +10,13 @@ This tutorial was generated from an IPython notebook that can be downloaded `here <../_static/tutorials/{{ nb_name }}/{{ nb_name }}.ipynb>`_. + You can interact with a live version of the source notebook through binder: + + |binder{{ nb_name }}| + +.. |binder{{ nb_name }}| image:: http://mybinder.org/badge.svg + :target: https://beta.mybinder.org/v2/gh/astropy/astropy-tutorials/master?filepath=docs/_static/tutorials/{{ nb_name }}/{{ nb_name }}.ipynb + .. _{{nb_name}}: {% endblock %} From d198451d3a3189da9ec6bb650d3dac28b2fdc04d Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 2 Nov 2017 11:41:45 -0400 Subject: [PATCH 084/113] add note about nbconv version in rtd env --- .rtd-environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rtd-environment.yml b/.rtd-environment.yml index 07c029fce..5425ce182 100644 --- a/.rtd-environment.yml +++ b/.rtd-environment.yml @@ -14,4 +14,4 @@ dependencies: - jupyter=1.0 - notebook=5.0 - pip: - - git+https://github.com/jupyter/nbconvert + - git+https://github.com/jupyter/nbconvert # this is really >=5.4, but at the time of adding this that wasn't yet available From d0780be419551c5478b8742662728c83ba98cfe5 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 2 Nov 2017 14:41:27 -0400 Subject: [PATCH 085/113] Add README section on building the tutorials --- README.rst | 12 ++++++++++++ docs/dev.rst | 5 ++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 0ca2839e5..23848585d 100644 --- a/README.rst +++ b/README.rst @@ -23,3 +23,15 @@ The tutorials are initially empty of any output. You can run them by pressing See the conda environment file or pip requirements file for a list of dependencies. + +## Building the tutorial web pages + +To build all of the tutorials in the form they appear on the web site, you first +convert the notebooks to sphinx, then run sphinx:: + + >>> python scripts/convert.py docs/_static/tutorials -v --exec-only + >>> cd docs + >>> make html + +For more detail on this, see the "Documentation for tutorials infrastructure +developers" section of the generated sphinx docs. diff --git a/docs/dev.rst b/docs/dev.rst index 1323b0be6..9c7b973d5 100644 --- a/docs/dev.rst +++ b/docs/dev.rst @@ -1,5 +1,5 @@ -Documentation for developers -============================ +Documentation for tutorials infrastructure developers +===================================================== Overview -------- @@ -84,4 +84,3 @@ Marking a cell with an intentional error Edit the cell metadata of the cell in which you would like to raise an exception and add the following to the top-level JSON: ``"tags": ["raises-exception"]`` This tag is recognized by the latest (master) version of nbconvert. - From fd032daafcd6eb6bd63d8b43bb10aaa2a55a1624 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 2 Nov 2017 15:18:24 -0400 Subject: [PATCH 086/113] fixed env check --- scripts/check_env.py | 57 ++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/scripts/check_env.py b/scripts/check_env.py index 6955d7477..482b101f2 100644 --- a/scripts/check_env.py +++ b/scripts/check_env.py @@ -39,52 +39,31 @@ from astropy import log as logger -def check_environment(tutorial=None): +def check_environment(tutorials_base_path, tutorial=None): error = False warnings = False # 'enter' checks if the tutorial name passed by user exists in the repository enter = False logger.info("Running Environment Tests...") - _orig_path = os.getcwd() - tutorials_base = os.path.join(_orig_path, 'tutorials') - for tutorial_name in os.listdir(tutorials_base): + for tutorial_name in os.listdir(tutorials_base_path): + print(tutorial_name,'ARG') if (tutorial_name == tutorial or tutorial is None): enter = True - tutorial_path = os.path.join( - tutorials_base, - tutorial_name) # Path to tutorial folder + tutorialreq_path = os.path.join(tutorials_base_path, tutorial_name, + 'requirements.txt') # Path to tutorial folder try: - with open(tutorial_path + "/requirements.json") as data_file: - # Import data from json file - data = json.load(data_file) + with open(tutorialreq_path) as req_file: # Check for all the packages to be imported - for pkgname in data: - # Check for versioning - for subinfo in data[pkgname]: - if subinfo == 'min_version': - if(not astropy.utils.introspection.minversion(pkgname, data[pkgname][subinfo])): - logger.error( - "Package " + - pkgname + - " is either missing or is out of date to run Tutorial: " + - tutorial_name) - error = True - #Package is Missing - elif subinfo == 'pref_version': - if(not astropy.utils.introspection.minversion(pkgname, data[pkgname][subinfo])): - logger.warning( - "Please upgrade Package " + - pkgname + - " to version " + - data[pkgname][subinfo] + - " for Tutorial: " + - tutorial_name) - warnings = True - # Out of date package is present + for line in req_file: + line_strip = line.strip() + astropy.utils.introspection.minversion(line_strip, '') + logger.info('Sucessfully checked requirements for ' + '"{}".'.format(tutorial_name)) + except IOError: - error = True - logger.error( - "Environment Check Failed ! requirements.json not found") + warnings = True + logger.warn('requirements.txt not found for "{}" - couldn\'t do' + ' environment check.'.format(tutorial_name)) if not enter: logger.error( @@ -112,6 +91,10 @@ def check_environment(tutorial=None): help="A regular expression to select the names of the " "notebooks to be processed. If not given, all " "notebooks will be used.") + parser.add_argument("tutorial_base_path", default='docs/_static/tutorials', + nargs='?', + help="The path to the root of the tutorial " + "directories.") args = parser.parse_args() - check_environment(args.nameregex) # name passed to check_env function + check_environment(args.tutorial_base_path, args.nameregex) # name passed to check_env function From 94c5ec68380d3a306cf7709e9bc34da8a3dc57a2 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 2 Nov 2017 15:18:35 -0400 Subject: [PATCH 087/113] add missing requriements for vo --- docs/_static/tutorials/vo/requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/_static/tutorials/vo/requirements.txt diff --git a/docs/_static/tutorials/vo/requirements.txt b/docs/_static/tutorials/vo/requirements.txt new file mode 100644 index 000000000..30317e981 --- /dev/null +++ b/docs/_static/tutorials/vo/requirements.txt @@ -0,0 +1 @@ +astroquery From 092bcd1cd35558ba961964d7e2a2b694c69e6a96 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 2 Nov 2017 15:24:16 -0400 Subject: [PATCH 088/113] add nosdiebar --- docs/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 01ad17dbd..1982cfb39 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -81,7 +81,8 @@ html_theme_options = { 'logotext1': 'astro', # white, semi-bold 'logotext2': 'py', # orange, light - 'logotext3': ':tutorials' # white, light + 'logotext3': ':tutorials', # white, light + 'nosidebar': True } # Add any paths that contain custom themes here, relative to this directory. From 1ffa409621733cc5da641b97134f3574af34dd26 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 2 Nov 2017 15:58:10 -0400 Subject: [PATCH 089/113] add kernelspec option --- scripts/convert.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/convert.py b/scripts/convert.py index b54e6f69f..13a6c1399 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -15,7 +15,7 @@ class NBConverter(object): def __init__(self, nb_path, output_path=None, template_file=None, - overwrite=False): + overwrite=False, kernel_name=None): self.nb_path = path.abspath(nb_path) fn = path.basename(self.nb_path) self.path_only = path.dirname(self.nb_path) @@ -41,6 +41,11 @@ def __init__(self, nb_path, output_path=None, template_file=None, logger.info('Processing notebook {0} (in {1})'.format(fn, self.path_only)) + if kernel_name is None: + self.kernel_name = ExecutePreprocessor.kernel_name.default_value + else: + self.kernel_name = kernel_name + def execute(self, write=True): """ Execute the specified notebook file, and optionally write out the @@ -66,8 +71,11 @@ def execute(self, write=True): return self._executed_nb_path # Execute the notebook - logger.debug('Executing notebook...') - executor = ExecutePreprocessor(timeout=900, kernel_name='python3') + logger.debug('Executing notebook using kernel ' + '"{}"...'.format(self.kernel_name)) + executor = ExecutePreprocessor(timeout=900, + kernel_name=self.kernel_name) + with open(self.nb_path) as f: nb = nbformat.read(f, as_version=IPYTHON_VERSION) @@ -212,6 +220,11 @@ def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): 'converted files will be in the same path as the ' 'source notebooks.') + parser.add_argument('--kernel-name', default='python3', dest='kernel_name', + help='The name of the kernel to run the notebooks with.' + ' Must be an available kernel from "jupyter ' + 'kernelspec list".') + args = parser.parse_args() # Set logger level based on verbose flags @@ -241,4 +254,4 @@ def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): process_notebooks(args.nbfile_or_path, exec_only=args.exec_only, output_path=output_path, template_file=template_file, - overwrite=args.overwrite) + overwrite=args.overwrite, kernel_name=args.kernel_name) From e7fe19882e4a0c22a86d86ce901b784b08a9fb84 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 2 Nov 2017 15:59:17 -0400 Subject: [PATCH 090/113] add default nbfile_or_path to be sensible --- scripts/convert.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/convert.py b/scripts/convert.py index 13a6c1399..c4790354e 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -205,7 +205,8 @@ def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): help='Re-run and overwrite any existing executed ' 'notebook or RST files.') - parser.add_argument('nbfile_or_path', default=None, + parser.add_argument('nbfile_or_path', default='docs/_static/tutorials/', + nargs='?', help='Path to a specific notebook file, or the ' 'top-level path to a directory containing ' 'notebook files to process.') From 07fcd3e0ac8cb043a4afdb76e1253b0bd9c749fb Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Fri, 3 Nov 2017 11:29:32 -0400 Subject: [PATCH 091/113] Update description of build workflow in README --- README.rst | 13 ++++++------- docs/dev.rst | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 23848585d..1fd269a12 100644 --- a/README.rst +++ b/README.rst @@ -26,12 +26,11 @@ dependencies. ## Building the tutorial web pages -To build all of the tutorials in the form they appear on the web site, you first -convert the notebooks to sphinx, then run sphinx:: +To build all of the tutorials in the form they appear on the web site, you just +do the sphinx build as for a Python package:: - >>> python scripts/convert.py docs/_static/tutorials -v --exec-only - >>> cd docs - >>> make html + >>> python setup.py build_docs -For more detail on this, see the "Documentation for tutorials infrastructure -developers" section of the generated sphinx docs. +For more information on this and other ways to execute the tutorials, see the +"Documentation on tutorials infrastructure" section of the generated +sphinx docs. diff --git a/docs/dev.rst b/docs/dev.rst index 9c7b973d5..299d43d72 100644 --- a/docs/dev.rst +++ b/docs/dev.rst @@ -1,5 +1,5 @@ -Documentation for tutorials infrastructure developers -===================================================== +Documentation on tutorials infrastructure +========================================= Overview -------- From 1e02586095b15e9a8d7b1787faf626c0f0071880 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Fri, 3 Nov 2017 13:34:18 -0400 Subject: [PATCH 092/113] supressed nonlocal uri warnings --- docs/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 1982cfb39..df07d4e4a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,7 +33,7 @@ # -- General configuration ---------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -# needs_sphinx = '1.2' +needs_sphinx = '1.4' # needed for suppress_warnings # To perform a Sphinx version check that needs to be more specific than # major.minor, call `check_sphinx_version("x.y.z")` here. @@ -147,3 +147,6 @@ rst_output_path = os.path.join(_root, 'docs', 'rst-tutorials') process_notebooks(nb_tutorials_path, output_path=rst_output_path, template_file=template_path) + + +suppress_warnings = ['image.nonlocal_uri'] From 9b3a3801a36b1e6b20c26c13a9089f509ea254f8 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Fri, 3 Nov 2017 13:42:47 -0400 Subject: [PATCH 093/113] rename dir structure --- .gitignore | 6 +++--- scripts/check_env.py | 2 +- scripts/convert.py | 2 +- setup.cfg | 12 ++++++------ {docs => tutorials}/Makefile | 0 {docs/_static => tutorials}/astropy.tpl | 0 {docs => tutorials}/conf.py | 6 +++--- {docs => tutorials}/dev.rst | 12 ++++++------ {docs => tutorials}/index.rst | 0 {docs => tutorials}/make.bat | 0 .../notebooks}/FITS-header/FITS-header.ipynb | 0 .../notebooks}/FITS-header/input_file.fits | Bin .../notebooks}/FITS-header/requirements.txt | 0 .../notebooks}/FITS-images/FITS-images.ipynb | 0 .../notebooks}/FITS-images/requirements.txt | 0 .../notebooks}/FITS-tables/FITS-tables.ipynb | 0 .../notebooks}/FITS-tables/requirements.txt | 0 .../notebooks}/UVES/CaII-1.png | Bin .../notebooks}/UVES/CaII-2.png | Bin .../notebooks}/UVES/CaII-3.png | Bin .../notebooks}/UVES/CaII-lines-all.png | Bin .../notebooks}/UVES/CaII-lines-one.png | Bin .../tutorials => tutorials/notebooks}/UVES/CaII.png | Bin .../notebooks}/UVES/UVES.ipynb | 0 .../notebooks}/UVES/requirements.txt | 0 .../notebooks}/coordinates/HCG7_2MASS.tbl | 0 .../notebooks}/coordinates/HCG7_SDSS_cutout.jpg | Bin .../notebooks}/coordinates/HCG7_SDSS_photo.dat | 0 .../notebooks}/coordinates/coordinates.ipynb | 0 .../notebooks}/coordinates/requirements.txt | 0 .../plot-catalog/Young-Objects-Compilation.csv | 0 .../notebooks}/plot-catalog/plot-catalog.ipynb | 0 .../notebooks}/plot-catalog/requirements.txt | 0 .../notebooks}/plot-catalog/simple_table.csv | 0 .../notebooks}/quantities/quantities.ipynb | 0 .../notebooks}/quantities/requirements.txt | 0 .../notebooks}/redshift-plot/ang_dist.png | Bin .../notebooks}/redshift-plot/redshift-plot.ipynb | 0 .../notebooks}/redshift-plot/requirements.txt | 0 .../tutorials => tutorials/notebooks}/vo/README.md | 0 .../notebooks}/vo/conesearch.ipynb | 0 .../notebooks}/vo/requirements.txt | 0 42 files changed, 20 insertions(+), 20 deletions(-) rename {docs => tutorials}/Makefile (100%) rename {docs/_static => tutorials}/astropy.tpl (100%) rename {docs => tutorials}/conf.py (96%) rename {docs => tutorials}/dev.rst (87%) rename {docs => tutorials}/index.rst (100%) rename {docs => tutorials}/make.bat (100%) rename {docs/_static/tutorials => tutorials/notebooks}/FITS-header/FITS-header.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/FITS-header/input_file.fits (100%) rename {docs/_static/tutorials => tutorials/notebooks}/FITS-header/requirements.txt (100%) rename {docs/_static/tutorials => tutorials/notebooks}/FITS-images/FITS-images.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/FITS-images/requirements.txt (100%) rename {docs/_static/tutorials => tutorials/notebooks}/FITS-tables/FITS-tables.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/FITS-tables/requirements.txt (100%) rename {docs/_static/tutorials => tutorials/notebooks}/UVES/CaII-1.png (100%) rename {docs/_static/tutorials => tutorials/notebooks}/UVES/CaII-2.png (100%) rename {docs/_static/tutorials => tutorials/notebooks}/UVES/CaII-3.png (100%) rename {docs/_static/tutorials => tutorials/notebooks}/UVES/CaII-lines-all.png (100%) rename {docs/_static/tutorials => tutorials/notebooks}/UVES/CaII-lines-one.png (100%) rename {docs/_static/tutorials => tutorials/notebooks}/UVES/CaII.png (100%) rename {docs/_static/tutorials => tutorials/notebooks}/UVES/UVES.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/UVES/requirements.txt (100%) rename {docs/_static/tutorials => tutorials/notebooks}/coordinates/HCG7_2MASS.tbl (100%) rename {docs/_static/tutorials => tutorials/notebooks}/coordinates/HCG7_SDSS_cutout.jpg (100%) rename {docs/_static/tutorials => tutorials/notebooks}/coordinates/HCG7_SDSS_photo.dat (100%) rename {docs/_static/tutorials => tutorials/notebooks}/coordinates/coordinates.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/coordinates/requirements.txt (100%) rename {docs/_static/tutorials => tutorials/notebooks}/plot-catalog/Young-Objects-Compilation.csv (100%) rename {docs/_static/tutorials => tutorials/notebooks}/plot-catalog/plot-catalog.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/plot-catalog/requirements.txt (100%) rename {docs/_static/tutorials => tutorials/notebooks}/plot-catalog/simple_table.csv (100%) rename {docs/_static/tutorials => tutorials/notebooks}/quantities/quantities.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/quantities/requirements.txt (100%) rename {docs/_static/tutorials => tutorials/notebooks}/redshift-plot/ang_dist.png (100%) rename {docs/_static/tutorials => tutorials/notebooks}/redshift-plot/redshift-plot.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/redshift-plot/requirements.txt (100%) rename {docs/_static/tutorials => tutorials/notebooks}/vo/README.md (100%) rename {docs/_static/tutorials => tutorials/notebooks}/vo/conesearch.ipynb (100%) rename {docs/_static/tutorials => tutorials/notebooks}/vo/requirements.txt (100%) diff --git a/.gitignore b/.gitignore index 55ce56513..bff0aa0d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .ipynb_checkpoints/ -docs/_build/ -docs/rst-tutorials/ +build/ +tutorials/rst-tutorials/ IPython-* *.fits *.pdf @@ -8,4 +8,4 @@ IPython-* *.jpg *.pyc *.tex -exec*.ipynb \ No newline at end of file +exec*.ipynb diff --git a/scripts/check_env.py b/scripts/check_env.py index 482b101f2..4c1d6c10e 100644 --- a/scripts/check_env.py +++ b/scripts/check_env.py @@ -91,7 +91,7 @@ def check_environment(tutorials_base_path, tutorial=None): help="A regular expression to select the names of the " "notebooks to be processed. If not given, all " "notebooks will be used.") - parser.add_argument("tutorial_base_path", default='docs/_static/tutorials', + parser.add_argument("tutorial_base_path", default='tutorials/notebooks', nargs='?', help="The path to the root of the tutorial " "directories.") diff --git a/scripts/convert.py b/scripts/convert.py index c4790354e..b33c3cbf1 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -205,7 +205,7 @@ def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): help='Re-run and overwrite any existing executed ' 'notebook or RST files.') - parser.add_argument('nbfile_or_path', default='docs/_static/tutorials/', + parser.add_argument('nbfile_or_path', default='tutorials/notebooks/', nargs='?', help='Path to a specific notebook file, or the ' 'top-level path to a directory containing ' diff --git a/setup.cfg b/setup.cfg index 5696202cc..dd6d37fe2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,20 +1,20 @@ [build_sphinx] -source-dir = docs -build-dir = docs/_build +source-dir = tutorials +build-dir = build/sphinx all_files = 1 [build_docs] -source-dir = docs -build-dir = docs/_build +source-dir = tutorials +build-dir = build/sphinx all_files = 1 [upload_docs] -upload-dir = docs/_build/html +upload-dir = build/sphinx/html show-response = 1 [pytest] minversion = 2.2 -norecursedirs = build docs/_build +norecursedirs = build build/sphinx doctest_plus = enabled [ah_bootstrap] diff --git a/docs/Makefile b/tutorials/Makefile similarity index 100% rename from docs/Makefile rename to tutorials/Makefile diff --git a/docs/_static/astropy.tpl b/tutorials/astropy.tpl similarity index 100% rename from docs/_static/astropy.tpl rename to tutorials/astropy.tpl diff --git a/docs/conf.py b/tutorials/conf.py similarity index 96% rename from docs/conf.py rename to tutorials/conf.py index df07d4e4a..5c9eceaa9 100644 --- a/docs/conf.py +++ b/tutorials/conf.py @@ -142,9 +142,9 @@ sys.path.insert(1, _scripts_path) from convert import process_notebooks -nb_tutorials_path = os.path.join(_root, 'docs', '_static', 'tutorials') -template_path = os.path.join(_root, 'docs', '_static', 'astropy.tpl') -rst_output_path = os.path.join(_root, 'docs', 'rst-tutorials') +nb_tutorials_path = os.path.join(_root, 'tutorials', 'notebooks') +template_path = os.path.join(_root, 'tutorials', 'astropy.tpl') +rst_output_path = os.path.join(_root, 'tutorials', 'rst-tutorials') process_notebooks(nb_tutorials_path, output_path=rst_output_path, template_file=template_path) diff --git a/docs/dev.rst b/tutorials/dev.rst similarity index 87% rename from docs/dev.rst rename to tutorials/dev.rst index 299d43d72..e0ae6702d 100644 --- a/docs/dev.rst +++ b/tutorials/dev.rst @@ -5,7 +5,7 @@ Overview -------- Tutorials are written as Jupyter notebooks on the ``master`` branch of the -``astropy/astropy-tutorials`` repository in ``docs/_static/tutorials/``. These +``astropy/astropy-tutorials`` repository in ``tutorials/notebooks/``. These notebook files do not contain output in order to simplify version-controlling the files. @@ -37,7 +37,7 @@ Tutorials directory structure ----------------------------- The notebook files must be written as a single Jupyter notebook in a directory -within the ``docs/_static/tutorials`` directory. The name of the notebook must +within the ``tutorials/notebooks`` directory. The name of the notebook must be the same as the subdirectory name. This is just needed for auto-generating links to the source notebooks from the generated RST pages. @@ -48,7 +48,7 @@ You can use the custom nbconvert script in the astropy-tutorials repository to test that the tutorials all execute correctly. From the top-level repository path:: - python scripts/convert.py docs/_static/tutorials -v --exec-only + python scripts/convert.py tutorials/notebooks -v --exec-only Running the convert script with the flag ``--exec-only`` will just execute the notebooks and won't generate RST files. If you have already run the notebooks @@ -58,16 +58,16 @@ executed. The ``-v`` flag just tells the script to output more "verbose" messages, which you may or may not want. The above command will execute all notebooks in any subdirectory of the -``docs/_static/tutorials`` path. If you want to just execute a single notebook, +``tutorials/notebooks`` path. If you want to just execute a single notebook, you can specify the path to a single notebook file, e.g.:: - python scripts/convert.py docs/_static/tutorials/coordinates/coordinates.ipynb -v --exec-only + python scripts/convert.py tutorials/notebooks/coordinates/coordinates.ipynb -v --exec-only You can also do this when running and generating RST files, which can be useful when writing a new tutorial to make sure it renders in RST properly. To do this, just remove the ``--exec-only`` flag:: - python scripts/convert.py docs/_static/tutorials/coordinates/coordinates.ipynb -v + python scripts/convert.py tutorials/notebooks/coordinates/coordinates.ipynb -v Releases -------- diff --git a/docs/index.rst b/tutorials/index.rst similarity index 100% rename from docs/index.rst rename to tutorials/index.rst diff --git a/docs/make.bat b/tutorials/make.bat similarity index 100% rename from docs/make.bat rename to tutorials/make.bat diff --git a/docs/_static/tutorials/FITS-header/FITS-header.ipynb b/tutorials/notebooks/FITS-header/FITS-header.ipynb similarity index 100% rename from docs/_static/tutorials/FITS-header/FITS-header.ipynb rename to tutorials/notebooks/FITS-header/FITS-header.ipynb diff --git a/docs/_static/tutorials/FITS-header/input_file.fits b/tutorials/notebooks/FITS-header/input_file.fits similarity index 100% rename from docs/_static/tutorials/FITS-header/input_file.fits rename to tutorials/notebooks/FITS-header/input_file.fits diff --git a/docs/_static/tutorials/FITS-header/requirements.txt b/tutorials/notebooks/FITS-header/requirements.txt similarity index 100% rename from docs/_static/tutorials/FITS-header/requirements.txt rename to tutorials/notebooks/FITS-header/requirements.txt diff --git a/docs/_static/tutorials/FITS-images/FITS-images.ipynb b/tutorials/notebooks/FITS-images/FITS-images.ipynb similarity index 100% rename from docs/_static/tutorials/FITS-images/FITS-images.ipynb rename to tutorials/notebooks/FITS-images/FITS-images.ipynb diff --git a/docs/_static/tutorials/FITS-images/requirements.txt b/tutorials/notebooks/FITS-images/requirements.txt similarity index 100% rename from docs/_static/tutorials/FITS-images/requirements.txt rename to tutorials/notebooks/FITS-images/requirements.txt diff --git a/docs/_static/tutorials/FITS-tables/FITS-tables.ipynb b/tutorials/notebooks/FITS-tables/FITS-tables.ipynb similarity index 100% rename from docs/_static/tutorials/FITS-tables/FITS-tables.ipynb rename to tutorials/notebooks/FITS-tables/FITS-tables.ipynb diff --git a/docs/_static/tutorials/FITS-tables/requirements.txt b/tutorials/notebooks/FITS-tables/requirements.txt similarity index 100% rename from docs/_static/tutorials/FITS-tables/requirements.txt rename to tutorials/notebooks/FITS-tables/requirements.txt diff --git a/docs/_static/tutorials/UVES/CaII-1.png b/tutorials/notebooks/UVES/CaII-1.png similarity index 100% rename from docs/_static/tutorials/UVES/CaII-1.png rename to tutorials/notebooks/UVES/CaII-1.png diff --git a/docs/_static/tutorials/UVES/CaII-2.png b/tutorials/notebooks/UVES/CaII-2.png similarity index 100% rename from docs/_static/tutorials/UVES/CaII-2.png rename to tutorials/notebooks/UVES/CaII-2.png diff --git a/docs/_static/tutorials/UVES/CaII-3.png b/tutorials/notebooks/UVES/CaII-3.png similarity index 100% rename from docs/_static/tutorials/UVES/CaII-3.png rename to tutorials/notebooks/UVES/CaII-3.png diff --git a/docs/_static/tutorials/UVES/CaII-lines-all.png b/tutorials/notebooks/UVES/CaII-lines-all.png similarity index 100% rename from docs/_static/tutorials/UVES/CaII-lines-all.png rename to tutorials/notebooks/UVES/CaII-lines-all.png diff --git a/docs/_static/tutorials/UVES/CaII-lines-one.png b/tutorials/notebooks/UVES/CaII-lines-one.png similarity index 100% rename from docs/_static/tutorials/UVES/CaII-lines-one.png rename to tutorials/notebooks/UVES/CaII-lines-one.png diff --git a/docs/_static/tutorials/UVES/CaII.png b/tutorials/notebooks/UVES/CaII.png similarity index 100% rename from docs/_static/tutorials/UVES/CaII.png rename to tutorials/notebooks/UVES/CaII.png diff --git a/docs/_static/tutorials/UVES/UVES.ipynb b/tutorials/notebooks/UVES/UVES.ipynb similarity index 100% rename from docs/_static/tutorials/UVES/UVES.ipynb rename to tutorials/notebooks/UVES/UVES.ipynb diff --git a/docs/_static/tutorials/UVES/requirements.txt b/tutorials/notebooks/UVES/requirements.txt similarity index 100% rename from docs/_static/tutorials/UVES/requirements.txt rename to tutorials/notebooks/UVES/requirements.txt diff --git a/docs/_static/tutorials/coordinates/HCG7_2MASS.tbl b/tutorials/notebooks/coordinates/HCG7_2MASS.tbl similarity index 100% rename from docs/_static/tutorials/coordinates/HCG7_2MASS.tbl rename to tutorials/notebooks/coordinates/HCG7_2MASS.tbl diff --git a/docs/_static/tutorials/coordinates/HCG7_SDSS_cutout.jpg b/tutorials/notebooks/coordinates/HCG7_SDSS_cutout.jpg similarity index 100% rename from docs/_static/tutorials/coordinates/HCG7_SDSS_cutout.jpg rename to tutorials/notebooks/coordinates/HCG7_SDSS_cutout.jpg diff --git a/docs/_static/tutorials/coordinates/HCG7_SDSS_photo.dat b/tutorials/notebooks/coordinates/HCG7_SDSS_photo.dat similarity index 100% rename from docs/_static/tutorials/coordinates/HCG7_SDSS_photo.dat rename to tutorials/notebooks/coordinates/HCG7_SDSS_photo.dat diff --git a/docs/_static/tutorials/coordinates/coordinates.ipynb b/tutorials/notebooks/coordinates/coordinates.ipynb similarity index 100% rename from docs/_static/tutorials/coordinates/coordinates.ipynb rename to tutorials/notebooks/coordinates/coordinates.ipynb diff --git a/docs/_static/tutorials/coordinates/requirements.txt b/tutorials/notebooks/coordinates/requirements.txt similarity index 100% rename from docs/_static/tutorials/coordinates/requirements.txt rename to tutorials/notebooks/coordinates/requirements.txt diff --git a/docs/_static/tutorials/plot-catalog/Young-Objects-Compilation.csv b/tutorials/notebooks/plot-catalog/Young-Objects-Compilation.csv similarity index 100% rename from docs/_static/tutorials/plot-catalog/Young-Objects-Compilation.csv rename to tutorials/notebooks/plot-catalog/Young-Objects-Compilation.csv diff --git a/docs/_static/tutorials/plot-catalog/plot-catalog.ipynb b/tutorials/notebooks/plot-catalog/plot-catalog.ipynb similarity index 100% rename from docs/_static/tutorials/plot-catalog/plot-catalog.ipynb rename to tutorials/notebooks/plot-catalog/plot-catalog.ipynb diff --git a/docs/_static/tutorials/plot-catalog/requirements.txt b/tutorials/notebooks/plot-catalog/requirements.txt similarity index 100% rename from docs/_static/tutorials/plot-catalog/requirements.txt rename to tutorials/notebooks/plot-catalog/requirements.txt diff --git a/docs/_static/tutorials/plot-catalog/simple_table.csv b/tutorials/notebooks/plot-catalog/simple_table.csv similarity index 100% rename from docs/_static/tutorials/plot-catalog/simple_table.csv rename to tutorials/notebooks/plot-catalog/simple_table.csv diff --git a/docs/_static/tutorials/quantities/quantities.ipynb b/tutorials/notebooks/quantities/quantities.ipynb similarity index 100% rename from docs/_static/tutorials/quantities/quantities.ipynb rename to tutorials/notebooks/quantities/quantities.ipynb diff --git a/docs/_static/tutorials/quantities/requirements.txt b/tutorials/notebooks/quantities/requirements.txt similarity index 100% rename from docs/_static/tutorials/quantities/requirements.txt rename to tutorials/notebooks/quantities/requirements.txt diff --git a/docs/_static/tutorials/redshift-plot/ang_dist.png b/tutorials/notebooks/redshift-plot/ang_dist.png similarity index 100% rename from docs/_static/tutorials/redshift-plot/ang_dist.png rename to tutorials/notebooks/redshift-plot/ang_dist.png diff --git a/docs/_static/tutorials/redshift-plot/redshift-plot.ipynb b/tutorials/notebooks/redshift-plot/redshift-plot.ipynb similarity index 100% rename from docs/_static/tutorials/redshift-plot/redshift-plot.ipynb rename to tutorials/notebooks/redshift-plot/redshift-plot.ipynb diff --git a/docs/_static/tutorials/redshift-plot/requirements.txt b/tutorials/notebooks/redshift-plot/requirements.txt similarity index 100% rename from docs/_static/tutorials/redshift-plot/requirements.txt rename to tutorials/notebooks/redshift-plot/requirements.txt diff --git a/docs/_static/tutorials/vo/README.md b/tutorials/notebooks/vo/README.md similarity index 100% rename from docs/_static/tutorials/vo/README.md rename to tutorials/notebooks/vo/README.md diff --git a/docs/_static/tutorials/vo/conesearch.ipynb b/tutorials/notebooks/vo/conesearch.ipynb similarity index 100% rename from docs/_static/tutorials/vo/conesearch.ipynb rename to tutorials/notebooks/vo/conesearch.ipynb diff --git a/docs/_static/tutorials/vo/requirements.txt b/tutorials/notebooks/vo/requirements.txt similarity index 100% rename from docs/_static/tutorials/vo/requirements.txt rename to tutorials/notebooks/vo/requirements.txt From 7dc2751af457e1678bbd9168518254931215551e Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Fri, 3 Nov 2017 16:12:53 -0400 Subject: [PATCH 094/113] add static path --- tutorials/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tutorials/conf.py b/tutorials/conf.py index 5c9eceaa9..797fe7835 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -150,3 +150,4 @@ suppress_warnings = ['image.nonlocal_uri'] +html_static_path = ['notebooks'] From 5cf47665890adce6cf40c72c91961a0bdcde5fa8 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 3 Nov 2017 16:19:57 -0400 Subject: [PATCH 095/113] add pinned scipy version to pip req --- pip-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/pip-requirements.txt b/pip-requirements.txt index f8d6cc07f..6e549b406 100644 --- a/pip-requirements.txt +++ b/pip-requirements.txt @@ -4,3 +4,4 @@ astroquery==0.3.6 matplotlib==2.0.2 numpy==1.13.1 jupyter==1.0 +scipy=0.19 From 04ef7259b242aab56af2881189d8d4fa69e213b2 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 3 Nov 2017 16:22:13 -0400 Subject: [PATCH 096/113] rename class --- scripts/convert.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/convert.py b/scripts/convert.py index b33c3cbf1..fb25153ca 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -12,7 +12,7 @@ IPYTHON_VERSION = 4 -class NBConverter(object): +class NBTutorialsConverter(object): def __init__(self, nb_path, output_path=None, template_file=None, overwrite=False, kernel_name=None): @@ -140,7 +140,8 @@ def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): Execute and optionally convert the specified notebook file or directory of notebook files. - This is a wrapper around the ``NBConverter`` class that does file handling. + This is a wrapper around the ``NBTutorialsConverter`` class that does file + handling. Parameters ---------- @@ -149,7 +150,8 @@ def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): exec_only : bool, optional Just execute the notebooks, don't run them. **kwargs - Any other keyword arguments are passed to the ``NBConverter`` init. + Any other keyword arguments are passed to the ``NBTutorialsConverter`` + init. """ if path.isdir(nbfile_or_path): @@ -167,7 +169,7 @@ def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): continue if ext == '.ipynb': - nbc = NBConverter(full_path, **kwargs) + nbc = NBTutorialsConverter(full_path, **kwargs) nbc.execute() if not exec_only: @@ -175,7 +177,7 @@ def process_notebooks(nbfile_or_path, exec_only=False, **kwargs): else: # It's a single file, so convert it - nbc = NBConverter(nbfile_or_path, **kwargs) + nbc = NBTutorialsConverter(nbfile_or_path, **kwargs) nbc.execute() if not exec_only: From 2d3dc39b5eb6871c3b658def013d2f6056d96010 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 3 Nov 2017 16:28:44 -0400 Subject: [PATCH 097/113] fix travis execute path --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5ee13bb87..0167f0896 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,5 +48,5 @@ script: # python scripts/convert.py docs/_static/tutorials/ -v # --output-path=docs/rst-tutorials # --template=docs/_static/astropy.tpl - - python scripts/convert.py docs/_static/tutorials/ --exec-only -v + - python scripts/convert.py tutorials/notebooks --exec-only -v From 779e187389ddf8a9fc751b481788c6d63bfd1ad7 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Fri, 3 Nov 2017 16:41:42 -0400 Subject: [PATCH 098/113] we renamed the docs dir --- tutorials/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/conf.py b/tutorials/conf.py index 797fe7835..cfe4cd3b6 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -11,8 +11,8 @@ try: import astropy_helpers except ImportError: - # Building from inside the docs/ directory? - if os.path.basename(os.getcwd()) == 'docs': + # Building from inside the tutorials/ directory? + if os.path.basename(os.getcwd()) == 'tutorials': a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) if os.path.isdir(a_h_path): sys.path.insert(1, a_h_path) From 76bf86af391e69ce3819fb9d0d329d4d24cda15f Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Mon, 6 Nov 2017 15:12:18 -0500 Subject: [PATCH 099/113] possible fix for static nbs --- tutorials/astropy.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/astropy.tpl b/tutorials/astropy.tpl index 1af1b32e8..12cadb3cf 100644 --- a/tutorials/astropy.tpl +++ b/tutorials/astropy.tpl @@ -8,7 +8,7 @@ .. note:: This tutorial was generated from an IPython notebook that can be downloaded `here - <../_static/tutorials/{{ nb_name }}/{{ nb_name }}.ipynb>`_. + <../_static/{{ nb_name }}/{{ nb_name }}.ipynb>`_. You can interact with a live version of the source notebook through binder: From 632a5f221d0537f2a0787100e0dcdaaeba9433ee Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Mon, 13 Nov 2017 17:21:50 -0500 Subject: [PATCH 100/113] Add custom stylesheet to change text width --- tutorials/_static/custom.css | 6 ++++++ tutorials/conf.py | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tutorials/_static/custom.css diff --git a/tutorials/_static/custom.css b/tutorials/_static/custom.css new file mode 100644 index 000000000..3f1226a9c --- /dev/null +++ b/tutorials/_static/custom.css @@ -0,0 +1,6 @@ +@import url("bootstrap-astropy.css"); + +div.body { + margin: 0 auto; + max-width: 768px; +} diff --git a/tutorials/conf.py b/tutorials/conf.py index cfe4cd3b6..949dc4038 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -85,6 +85,8 @@ 'nosidebar': True } +html_style = 'custom.css' + # Add any paths that contain custom themes here, relative to this directory. # To use a different custom theme, add the directory containing the theme. #html_theme_path = [] @@ -150,4 +152,4 @@ suppress_warnings = ['image.nonlocal_uri'] -html_static_path = ['notebooks'] +html_static_path = ['notebooks', '_static'] From d61258422878a73f9dff8ae305f5d58b95819e20 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Tue, 14 Nov 2017 16:48:18 -0500 Subject: [PATCH 101/113] move Makefile to base with correct directories --- tutorials/Makefile => Makefile | 7 ++----- tutorials/conf.py | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) rename tutorials/Makefile => Makefile (96%) diff --git a/tutorials/Makefile b/Makefile similarity index 96% rename from tutorials/Makefile rename to Makefile index 2dbf56a87..8a3d4158e 100644 --- a/tutorials/Makefile +++ b/Makefile @@ -5,18 +5,15 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = _build +BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) tutorials .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest -#This is needed with git because git doesn't create a dir if it's empty -$(shell [ -d "_static" ] || mkdir -p _static) - help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" diff --git a/tutorials/conf.py b/tutorials/conf.py index 949dc4038..d3459debc 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -8,16 +8,19 @@ import sys from os import path -try: - import astropy_helpers -except ImportError: - # Building from inside the tutorials/ directory? - if os.path.basename(os.getcwd()) == 'tutorials': - a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) - if os.path.isdir(a_h_path): - sys.path.insert(1, a_h_path) +# try: +# import astropy_helpers +# except ImportError: +# # Building from inside the tutorials/ directory? +# if os.path.basename(os.getcwd()) == 'tutorials': +# a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) +# if os.path.isdir(a_h_path): +# sys.path.insert(1, a_h_path) +sys.path.insert(0, os.path.abspath(os.path.join('..', 'astropy_helpers'))) # Load all of the global Astropy configuration + + from astropy_helpers.sphinx.conf import * # Get configuration information from setup.cfg From 91a01ef7fcc640776305bf7a24f49fb479d51c62 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Tue, 14 Nov 2017 16:48:57 -0500 Subject: [PATCH 102/113] also move make.bat (not tested) --- tutorials/make.bat => make.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename tutorials/make.bat => make.bat (98%) diff --git a/tutorials/make.bat b/make.bat similarity index 98% rename from tutorials/make.bat rename to make.bat index 93dfe92b9..0da9bbc56 100644 --- a/tutorials/make.bat +++ b/make.bat @@ -5,8 +5,8 @@ REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) -set BUILDDIR=_build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set BUILDDIR=build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% tutorials if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% ) From 5643b97b8cb592f11159770052ce620acac912f7 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Wed, 15 Nov 2017 01:20:23 -0500 Subject: [PATCH 103/113] change path add to use the supplied helpers regardless of import success --- tutorials/conf.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tutorials/conf.py b/tutorials/conf.py index d3459debc..da6ede890 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -8,19 +8,13 @@ import sys from os import path -# try: -# import astropy_helpers -# except ImportError: -# # Building from inside the tutorials/ directory? -# if os.path.basename(os.getcwd()) == 'tutorials': -# a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) -# if os.path.isdir(a_h_path): -# sys.path.insert(1, a_h_path) -sys.path.insert(0, os.path.abspath(os.path.join('..', 'astropy_helpers'))) +# Building from inside the tutorials/ directory? Need to add correct helpers to the python path +if os.path.basename(os.getcwd()) == 'tutorials': + a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) + if os.path.isdir(a_h_path): + sys.path.insert(1, a_h_path) # Load all of the global Astropy configuration - - from astropy_helpers.sphinx.conf import * # Get configuration information from setup.cfg From 0a539931981e7e27335806aef4cf4bb5af646cbb Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Wed, 15 Nov 2017 01:25:56 -0500 Subject: [PATCH 104/113] make useful error message to help with what to do with missing helpers --- tutorials/conf.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tutorials/conf.py b/tutorials/conf.py index da6ede890..bf839395f 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -15,7 +15,12 @@ sys.path.insert(1, a_h_path) # Load all of the global Astropy configuration -from astropy_helpers.sphinx.conf import * +try: + from astropy_helpers.sphinx.conf import * +except ImportError: + raise ImportError('Couldn\'t import astropy_helpers. You may need to "git ' + 'submodule init" and then "git submodule update" from ' + 'the base of the tutorials repo?') # Get configuration information from setup.cfg try: From 5c350239057835b35200667fc34f0e0240795478 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Wed, 15 Nov 2017 01:32:18 -0500 Subject: [PATCH 105/113] add mismatch helpers warning --- tutorials/conf.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tutorials/conf.py b/tutorials/conf.py index bf839395f..6f216aadf 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -9,6 +9,7 @@ from os import path # Building from inside the tutorials/ directory? Need to add correct helpers to the python path +a_h_path = None if os.path.basename(os.getcwd()) == 'tutorials': a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) if os.path.isdir(a_h_path): @@ -17,6 +18,15 @@ # Load all of the global Astropy configuration try: from astropy_helpers.sphinx.conf import * + + import astropy_helpers + if a_h_path is not None and not astropy_helpers.__path__[0].startswith(a_h_path): + from warnings import warn + warn("The astropy_helpers you are importing is not the one that's " + "included with the tutorials. This may be fine but might cause " + "unexpected problems. You'll probably need to init/update the " + "submodules to rectify this, or delete your installed version of " + "the helpers (normally you shouldn't need to have them installed)") except ImportError: raise ImportError('Couldn\'t import astropy_helpers. You may need to "git ' 'submodule init" and then "git submodule update" from ' From 75064ac3e96e8c1ea42929c81b191bebab4b768e Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 16 Nov 2017 17:32:44 -0500 Subject: [PATCH 106/113] remove setups --- setup.cfg | 51 ------------------------- setup.py | 110 ------------------------------------------------------ 2 files changed, 161 deletions(-) delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index dd6d37fe2..000000000 --- a/setup.cfg +++ /dev/null @@ -1,51 +0,0 @@ -[build_sphinx] -source-dir = tutorials -build-dir = build/sphinx -all_files = 1 - -[build_docs] -source-dir = tutorials -build-dir = build/sphinx -all_files = 1 - -[upload_docs] -upload-dir = build/sphinx/html -show-response = 1 - -[pytest] -minversion = 2.2 -norecursedirs = build build/sphinx -doctest_plus = enabled - -[ah_bootstrap] -auto_use = True - -[pep8] -# E101 - mix of tabs and spaces -# W191 - use of tabs -# W291 - trailing whitespace -# W292 - no newline at end of file -# W293 - trailing whitespace -# W391 - blank line at end of file -# E111 - 4 spaces per indentation level -# E112 - 4 spaces per indentation level -# E113 - 4 spaces per indentation level -# E901 - SyntaxError or IndentationError -# E902 - IOError -select = E101,W191,W291,W292,W293,W391,E111,E112,E113,E901,E902 -exclude = extern,sphinx,*parsetab.py - -[metadata] -package_name = astropy-tutorials -description = Tutorials for the Astropy Project -author = The Astropy Developers -author_email = astropy.team@gmail.com -license = BSD -url = http://tutorials.astropy.org/ -edit_on_github = False -github_project = astropy/astropy-tutorials -install_requires = astropy -# version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) -version = 3.0.dev - -[entry_points] diff --git a/setup.py b/setup.py deleted file mode 100755 index cae885cdd..000000000 --- a/setup.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -import glob -import os -import sys - -import ah_bootstrap -from setuptools import setup - -#A dirty hack to get around some early import/configurations ambiguities -if sys.version_info[0] >= 3: - import builtins -else: - import __builtin__ as builtins -builtins._ASTROPY_SETUP_ = True - -from astropy_helpers.setup_helpers import (register_commands, get_debug_option, - get_package_info) -from astropy_helpers.git_helpers import get_git_devstr -from astropy_helpers.version_helpers import generate_version_py - -# Get some values from the setup.cfg -try: - from ConfigParser import ConfigParser -except ImportError: - from configparser import ConfigParser - -conf = ConfigParser() -conf.read(['setup.cfg']) -metadata = dict(conf.items('metadata')) - -PACKAGENAME = metadata.get('package_name', 'packagename') -DESCRIPTION = metadata.get('description', 'Astropy affiliated package') -AUTHOR = metadata.get('author', '') -AUTHOR_EMAIL = metadata.get('author_email', '') -LICENSE = metadata.get('license', 'unknown') -URL = metadata.get('url', 'http://astropy.org') - - -readme_glob = 'README.rst' -with open('README.rst') as f: - LONG_DESCRIPTION = f.read() - -# Store the package name in a built-in variable so it's easy -# to get from other parts of the setup infrastructure -builtins._ASTROPY_PACKAGE_NAME_ = PACKAGENAME - -# VERSION should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) -VERSION = metadata.get('version', '0.0.dev') - -# Indicates if this version is a release version -RELEASE = 'dev' not in VERSION - -if not RELEASE: - VERSION += get_git_devstr(False) - -# Populate the dict of setup command overrides; this should be done before -# invoking any other functionality from distutils since it can potentially -# modify distutils' behavior. -cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE) - -# Get configuration information from all of the various subpackages. -# See the docstring for setup_helpers.update_package_files for more -# details. -package_info = get_package_info() - -# Add the project-global data -package_info['package_data'].setdefault(PACKAGENAME, []) -package_info['package_data'][PACKAGENAME].append('data/*') - -# Define entry points for command-line scripts -entry_points = {'console_scripts': []} - -entry_point_list = conf.items('entry_points') -for entry_point in entry_point_list: - entry_points['console_scripts'].append('{0} = {1}'.format(entry_point[0], - entry_point[1])) - -# Include all .c files, recursively, including those generated by -# Cython, since we can not do this in MANIFEST.in with a "dynamic" -# directory name. -c_files = [] -for root, dirs, files in os.walk(PACKAGENAME): - for filename in files: - if filename.endswith('.c'): - c_files.append( - os.path.join( - os.path.relpath(root, PACKAGENAME), filename)) -package_info['package_data'][PACKAGENAME].extend(c_files) - -# Note that requires and provides should not be included in the call to -# ``setup``, since these are now deprecated. See this link for more details: -# https://groups.google.com/forum/#!topic/astropy-dev/urYO8ckB2uM - -setup(name=PACKAGENAME, - version=VERSION, - description=DESCRIPTION, - install_requires=metadata.get('install_requires', 'astropy').strip().split(), - author=AUTHOR, - author_email=AUTHOR_EMAIL, - license=LICENSE, - url=URL, - long_description=LONG_DESCRIPTION, - cmdclass=cmdclassd, - zip_safe=False, - use_2to3=False, - entry_points=entry_points, - **package_info -) From 226581f17eb7ff87e34c74c66167f1f9158744ee Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 16 Nov 2017 22:29:07 -0500 Subject: [PATCH 107/113] rewrite readme to defer to 'documentation' --- README.rst | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/README.rst b/README.rst index 1fd269a12..e2caa295e 100644 --- a/README.rst +++ b/README.rst @@ -1,36 +1,32 @@ -# Astropy Tutorials +Astropy Tutorials +================= -This repository contains tutorials for the [Astropy](http://astropy.org) -project (also on [github](https://github.com/astropy/astropy)). +This repository contains tutorials for the `Astropy `_ +project. These are typically longer-form, more narrative presentations of +functionality in the `Astropy core package +`_ and any `affiliated packages +`_. The tutorials are therefore +different from the `Astropy core package documentation +`_, which presents a more structured and exhaustive +view of the core package. -## Running Tutorials +To see the tutorials rendered as static web pages, see the `Astropy tutorials +site `_. -The easiest way to get started quickly is to use binder to run the tutorials in -your web browser - when this loads, click the "tutorials" folder and you should -see all the tutorials: +To run the tutorials interactively, you'll need to make sure you have `Jupyter +notebook `_ installed, then clone or download this +repository. The notebook files themselves live in the ``tutorials`` directory +of this repository, organized by the names of the tutorials. + +You can also get started quickly using `Binder `_ to run the tutorials in +your web browser within a remote server: .. image:: http://mybinder.org/badge.svg :target: http://mybinder.org/repo/astropy/astropy-tutorials/docs/tutorials -To run the tutorials *locally*, you need jupyter notebook installed:: - - jupyter notebook - -The tutorials are initially empty of any output. You can run them by pressing -"Run All" under the "Cell" menu in the notebook file. - -## Dependencies - -See the conda environment file or pip requirements file for a list of -dependencies. - -## Building the tutorial web pages - -To build all of the tutorials in the form they appear on the web site, you just -do the sphinx build as for a Python package:: - - >>> python setup.py build_docs +Contributing tutorial material +------------------------------ -For more information on this and other ways to execute the tutorials, see the -"Documentation on tutorials infrastructure" section of the generated -sphinx docs. +Please see the "`For contributors +`_" section +of the tutorials documentation for information on how to get started. From e2f1ba89dcca37077b5acf1d1931312102423a1f Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 16 Nov 2017 22:36:04 -0500 Subject: [PATCH 108/113] clean up landing page --- tutorials/index.rst | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/tutorials/index.rst b/tutorials/index.rst index d6f540021..6adde10de 100644 --- a/tutorials/index.rst +++ b/tutorials/index.rst @@ -18,25 +18,17 @@ List of tutorials For contributors ---------------- -We welcome feedback and improvements to these tutorials via the `Astropy -Tutorials repo on Github `_. If -you find a typo or would like to clarify some text, please either `create an -issue `_ or make the -change yourself and then submit a pull request directly to the repository. -Questions and/or comments about the tutorials are welcome on the `astropy-dev -`_ mailing list. - -If you are interested in contributing an ipython notebook as a tutorial, please -check the `README -`_ or -contact the `astropy developer email list -`_. If you have an idea for -a tutorial or a tutorial request, please also post to the developer email list. -If you would like to contribute to this effort, but need some inspiration, check -out the `open issues for new content -`_. This is a -collaborative effort and we are looking for contributions and ideas from users -like you! +We welcome feedback, improvements, and new tutorial content via the `Astropy +Tutorials repository `_ on +GitHub. If you find a typo or would like to clarify some text, please either +`create an issue `_ or +make the change yourself and then submit a pull request directly to the +repository. Questions and/or comments about the tutorials are welcome on the +`astropy-dev `_ mailing +list. + +If you are interested in contributing a new tutorial or content, please see +:ref:`contributing-page`. For developers -------------- From cc08da17e3511fd9c36ba9d7d123726d554cd057 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 16 Nov 2017 23:02:17 -0500 Subject: [PATCH 109/113] add make html instructions --- tutorials/dev.rst | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tutorials/dev.rst b/tutorials/dev.rst index e0ae6702d..6d6ab285a 100644 --- a/tutorials/dev.rst +++ b/tutorials/dev.rst @@ -22,7 +22,7 @@ We use `readthedocs `_ to do the Sphinx build, which is what allows us to preserve the version history of the tutorials. The notebooks are first converted to RST files during the Sphinx build by doing the conversion at the end of the `Sphinx configuration file -`_. +`_. Why not use nbsphinx? --------------------- @@ -69,6 +69,25 @@ this, just remove the ``--exec-only`` flag:: python scripts/convert.py tutorials/notebooks/coordinates/coordinates.ipynb -v +Building the tutorials page locally +----------------------------------- + +For this, you can use the `Makefile +`_ at the +top-level of the tutorials repository. From the root level of the cloned or +downloaded repository:: + + make html + +Will execute and convert the Jupyter notebooks to RST files, then do the Sphinx +build. If this returns an error, you may need to initialize the +``astropy_helpers`` submodule (read the error message). That is, you may need to +do:: + + git submodule init + git submodule update + make html + Releases -------- From 08018739aedea976eae701ef5e56d9ef7f33e8d0 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 16 Nov 2017 23:25:39 -0500 Subject: [PATCH 110/113] add back in cfg with metadata for the tutorials --- metadata.cfg | 11 +++++++++++ tutorials/conf.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 metadata.cfg diff --git a/metadata.cfg b/metadata.cfg new file mode 100644 index 000000000..383df43c0 --- /dev/null +++ b/metadata.cfg @@ -0,0 +1,11 @@ +[metadata] +package_name = astropy-tutorials +description = Tutorials for the Astropy Project +author = The Astropy Developers +author_email = astropy.team@gmail.com +license = BSD +url = http://tutorials.astropy.org/ +edit_on_github = False +github_project = astropy/astropy-tutorials +# version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) +version = 3.0.dev \ No newline at end of file diff --git a/tutorials/conf.py b/tutorials/conf.py index 6f216aadf..30ccd112e 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -39,7 +39,7 @@ from configparser import ConfigParser conf = ConfigParser() -conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) +conf.read([os.path.join(os.path.dirname(__file__), '..', 'metadata.cfg')]) setup_cfg = dict(conf.items('metadata')) # -- General configuration ---------------------------------------------------- From a1693a0dd13a3065a34dc0372cb4a10fb7849d2c Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 16 Nov 2017 23:26:06 -0500 Subject: [PATCH 111/113] remove unnecessary ah_bootstrap.py --- ah_bootstrap.py | 987 ------------------------------------------------ 1 file changed, 987 deletions(-) delete mode 100644 ah_bootstrap.py diff --git a/ah_bootstrap.py b/ah_bootstrap.py deleted file mode 100644 index 0dc50071b..000000000 --- a/ah_bootstrap.py +++ /dev/null @@ -1,987 +0,0 @@ -""" -This bootstrap module contains code for ensuring that the astropy_helpers -package will be importable by the time the setup.py script runs. It also -includes some workarounds to ensure that a recent-enough version of setuptools -is being used for the installation. - -This module should be the first thing imported in the setup.py of distributions -that make use of the utilities in astropy_helpers. If the distribution ships -with its own copy of astropy_helpers, this module will first attempt to import -from the shipped copy. However, it will also check PyPI to see if there are -any bug-fix releases on top of the current version that may be useful to get -past platform-specific bugs that have been fixed. When running setup.py, use -the ``--offline`` command-line option to disable the auto-upgrade checks. - -When this module is imported or otherwise executed it automatically calls a -main function that attempts to read the project's setup.cfg file, which it -checks for a configuration section called ``[ah_bootstrap]`` the presences of -that section, and options therein, determine the next step taken: If it -contains an option called ``auto_use`` with a value of ``True``, it will -automatically call the main function of this module called -`use_astropy_helpers` (see that function's docstring for full details). -Otherwise no further action is taken (however, -``ah_bootstrap.use_astropy_helpers`` may be called manually from within the -setup.py script). - -Additional options in the ``[ah_boostrap]`` section of setup.cfg have the same -names as the arguments to `use_astropy_helpers`, and can be used to configure -the bootstrap script when ``auto_use = True``. - -See https://github.com/astropy/astropy-helpers for more details, and for the -latest version of this module. -""" - -import contextlib -import errno -import imp -import io -import locale -import os -import re -import subprocess as sp -import sys - -try: - from ConfigParser import ConfigParser, RawConfigParser -except ImportError: - from configparser import ConfigParser, RawConfigParser - - -if sys.version_info[0] < 3: - _str_types = (str, unicode) - _text_type = unicode - PY3 = False -else: - _str_types = (str, bytes) - _text_type = str - PY3 = True - - -# What follows are several import statements meant to deal with install-time -# issues with either missing or misbehaving pacakges (including making sure -# setuptools itself is installed): - - -# Some pre-setuptools checks to ensure that either distribute or setuptools >= -# 0.7 is used (over pre-distribute setuptools) if it is available on the path; -# otherwise the latest setuptools will be downloaded and bootstrapped with -# ``ez_setup.py``. This used to be included in a separate file called -# setuptools_bootstrap.py; but it was combined into ah_bootstrap.py -try: - import pkg_resources - _setuptools_req = pkg_resources.Requirement.parse('setuptools>=0.7') - # This may raise a DistributionNotFound in which case no version of - # setuptools or distribute is properly installed - _setuptools = pkg_resources.get_distribution('setuptools') - if _setuptools not in _setuptools_req: - # Older version of setuptools; check if we have distribute; again if - # this results in DistributionNotFound we want to give up - _distribute = pkg_resources.get_distribution('distribute') - if _setuptools != _distribute: - # It's possible on some pathological systems to have an old version - # of setuptools and distribute on sys.path simultaneously; make - # sure distribute is the one that's used - sys.path.insert(1, _distribute.location) - _distribute.activate() - imp.reload(pkg_resources) -except: - # There are several types of exceptions that can occur here; if all else - # fails bootstrap and use the bootstrapped version - from ez_setup import use_setuptools - use_setuptools() - - -# Note: The following import is required as a workaround to -# https://github.com/astropy/astropy-helpers/issues/89; if we don't import this -# module now, it will get cleaned up after `run_setup` is called, but that will -# later cause the TemporaryDirectory class defined in it to stop working when -# used later on by setuptools -try: - import setuptools.py31compat -except ImportError: - pass - - -# matplotlib can cause problems if it is imported from within a call of -# run_setup(), because in some circumstances it will try to write to the user's -# home directory, resulting in a SandboxViolation. See -# https://github.com/matplotlib/matplotlib/pull/4165 -# Making sure matplotlib, if it is available, is imported early in the setup -# process can mitigate this (note importing matplotlib.pyplot has the same -# issue) -try: - import matplotlib - matplotlib.use('Agg') - import matplotlib.pyplot -except: - # Ignore if this fails for *any* reason* - pass - - -# End compatibility imports... - - -# In case it didn't successfully import before the ez_setup checks -import pkg_resources - -from setuptools import Distribution -from setuptools.package_index import PackageIndex -from setuptools.sandbox import run_setup - -from distutils import log -from distutils.debug import DEBUG - - -# TODO: Maybe enable checking for a specific version of astropy_helpers? -DIST_NAME = 'astropy-helpers' -PACKAGE_NAME = 'astropy_helpers' - -# Defaults for other options -DOWNLOAD_IF_NEEDED = True -INDEX_URL = 'https://pypi.python.org/simple' -USE_GIT = True -OFFLINE = False -AUTO_UPGRADE = True - -# A list of all the configuration options and their required types -CFG_OPTIONS = [ - ('auto_use', bool), ('path', str), ('download_if_needed', bool), - ('index_url', str), ('use_git', bool), ('offline', bool), - ('auto_upgrade', bool) -] - - -class _Bootstrapper(object): - """ - Bootstrapper implementation. See ``use_astropy_helpers`` for parameter - documentation. - """ - - def __init__(self, path=None, index_url=None, use_git=None, offline=None, - download_if_needed=None, auto_upgrade=None): - - if path is None: - path = PACKAGE_NAME - - if not (isinstance(path, _str_types) or path is False): - raise TypeError('path must be a string or False') - - if PY3 and not isinstance(path, _text_type): - fs_encoding = sys.getfilesystemencoding() - path = path.decode(fs_encoding) # path to unicode - - self.path = path - - # Set other option attributes, using defaults where necessary - self.index_url = index_url if index_url is not None else INDEX_URL - self.offline = offline if offline is not None else OFFLINE - - # If offline=True, override download and auto-upgrade - if self.offline: - download_if_needed = False - auto_upgrade = False - - self.download = (download_if_needed - if download_if_needed is not None - else DOWNLOAD_IF_NEEDED) - self.auto_upgrade = (auto_upgrade - if auto_upgrade is not None else AUTO_UPGRADE) - - # If this is a release then the .git directory will not exist so we - # should not use git. - git_dir_exists = os.path.exists(os.path.join(os.path.dirname(__file__), '.git')) - if use_git is None and not git_dir_exists: - use_git = False - - self.use_git = use_git if use_git is not None else USE_GIT - # Declared as False by default--later we check if astropy-helpers can be - # upgraded from PyPI, but only if not using a source distribution (as in - # the case of import from a git submodule) - self.is_submodule = False - - @classmethod - def main(cls, argv=None): - if argv is None: - argv = sys.argv - - config = cls.parse_config() - config.update(cls.parse_command_line(argv)) - - auto_use = config.pop('auto_use', False) - bootstrapper = cls(**config) - - if auto_use: - # Run the bootstrapper, otherwise the setup.py is using the old - # use_astropy_helpers() interface, in which case it will run the - # bootstrapper manually after reconfiguring it. - bootstrapper.run() - - return bootstrapper - - @classmethod - def parse_config(cls): - if not os.path.exists('setup.cfg'): - return {} - - cfg = ConfigParser() - - try: - cfg.read('setup.cfg') - except Exception as e: - if DEBUG: - raise - - log.error( - "Error reading setup.cfg: {0!r}\n{1} will not be " - "automatically bootstrapped and package installation may fail." - "\n{2}".format(e, PACKAGE_NAME, _err_help_msg)) - return {} - - if not cfg.has_section('ah_bootstrap'): - return {} - - config = {} - - for option, type_ in CFG_OPTIONS: - if not cfg.has_option('ah_bootstrap', option): - continue - - if type_ is bool: - value = cfg.getboolean('ah_bootstrap', option) - else: - value = cfg.get('ah_bootstrap', option) - - config[option] = value - - return config - - @classmethod - def parse_command_line(cls, argv=None): - if argv is None: - argv = sys.argv - - config = {} - - # For now we just pop recognized ah_bootstrap options out of the - # arg list. This is imperfect; in the unlikely case that a setup.py - # custom command or even custom Distribution class defines an argument - # of the same name then we will break that. However there's a catch22 - # here that we can't just do full argument parsing right here, because - # we don't yet know *how* to parse all possible command-line arguments. - if '--no-git' in argv: - config['use_git'] = False - argv.remove('--no-git') - - if '--offline' in argv: - config['offline'] = True - argv.remove('--offline') - - return config - - def run(self): - strategies = ['local_directory', 'local_file', 'index'] - dist = None - - # First, remove any previously imported versions of astropy_helpers; - # this is necessary for nested installs where one package's installer - # is installing another package via setuptools.sandbox.run_setup, as in - # the case of setup_requires - for key in list(sys.modules): - try: - if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'): - del sys.modules[key] - except AttributeError: - # Sometimes mysterious non-string things can turn up in - # sys.modules - continue - - # Check to see if the path is a submodule - self.is_submodule = self._check_submodule() - - for strategy in strategies: - method = getattr(self, 'get_{0}_dist'.format(strategy)) - dist = method() - if dist is not None: - break - else: - raise _AHBootstrapSystemExit( - "No source found for the {0!r} package; {0} must be " - "available and importable as a prerequisite to building " - "or installing this package.".format(PACKAGE_NAME)) - - # This is a bit hacky, but if astropy_helpers was loaded from a - # directory/submodule its Distribution object gets a "precedence" of - # "DEVELOP_DIST". However, in other cases it gets a precedence of - # "EGG_DIST". However, when activing the distribution it will only be - # placed early on sys.path if it is treated as an EGG_DIST, so always - # do that - dist = dist.clone(precedence=pkg_resources.EGG_DIST) - - # Otherwise we found a version of astropy-helpers, so we're done - # Just active the found distribution on sys.path--if we did a - # download this usually happens automatically but it doesn't hurt to - # do it again - # Note: Adding the dist to the global working set also activates it - # (makes it importable on sys.path) by default. - - try: - pkg_resources.working_set.add(dist, replace=True) - except TypeError: - # Some (much) older versions of setuptools do not have the - # replace=True option here. These versions are old enough that all - # bets may be off anyways, but it's easy enough to work around just - # in case... - if dist.key in pkg_resources.working_set.by_key: - del pkg_resources.working_set.by_key[dist.key] - pkg_resources.working_set.add(dist) - - @property - def config(self): - """ - A `dict` containing the options this `_Bootstrapper` was configured - with. - """ - - return dict((optname, getattr(self, optname)) - for optname, _ in CFG_OPTIONS if hasattr(self, optname)) - - def get_local_directory_dist(self): - """ - Handle importing a vendored package from a subdirectory of the source - distribution. - """ - - if not os.path.isdir(self.path): - return - - log.info('Attempting to import astropy_helpers from {0} {1!r}'.format( - 'submodule' if self.is_submodule else 'directory', - self.path)) - - dist = self._directory_import() - - if dist is None: - log.warn( - 'The requested path {0!r} for importing {1} does not ' - 'exist, or does not contain a copy of the {1} ' - 'package.'.format(self.path, PACKAGE_NAME)) - elif self.auto_upgrade and not self.is_submodule: - # A version of astropy-helpers was found on the available path, but - # check to see if a bugfix release is available on PyPI - upgrade = self._do_upgrade(dist) - if upgrade is not None: - dist = upgrade - - return dist - - def get_local_file_dist(self): - """ - Handle importing from a source archive; this also uses setup_requires - but points easy_install directly to the source archive. - """ - - if not os.path.isfile(self.path): - return - - log.info('Attempting to unpack and import astropy_helpers from ' - '{0!r}'.format(self.path)) - - try: - dist = self._do_download(find_links=[self.path]) - except Exception as e: - if DEBUG: - raise - - log.warn( - 'Failed to import {0} from the specified archive {1!r}: ' - '{2}'.format(PACKAGE_NAME, self.path, str(e))) - dist = None - - if dist is not None and self.auto_upgrade: - # A version of astropy-helpers was found on the available path, but - # check to see if a bugfix release is available on PyPI - upgrade = self._do_upgrade(dist) - if upgrade is not None: - dist = upgrade - - return dist - - def get_index_dist(self): - if not self.download: - log.warn('Downloading {0!r} disabled.'.format(DIST_NAME)) - return None - - log.warn( - "Downloading {0!r}; run setup.py with the --offline option to " - "force offline installation.".format(DIST_NAME)) - - try: - dist = self._do_download() - except Exception as e: - if DEBUG: - raise - log.warn( - 'Failed to download and/or install {0!r} from {1!r}:\n' - '{2}'.format(DIST_NAME, self.index_url, str(e))) - dist = None - - # No need to run auto-upgrade here since we've already presumably - # gotten the most up-to-date version from the package index - return dist - - def _directory_import(self): - """ - Import astropy_helpers from the given path, which will be added to - sys.path. - - Must return True if the import succeeded, and False otherwise. - """ - - # Return True on success, False on failure but download is allowed, and - # otherwise raise SystemExit - path = os.path.abspath(self.path) - - # Use an empty WorkingSet rather than the man - # pkg_resources.working_set, since on older versions of setuptools this - # will invoke a VersionConflict when trying to install an upgrade - ws = pkg_resources.WorkingSet([]) - ws.add_entry(path) - dist = ws.by_key.get(DIST_NAME) - - if dist is None: - # We didn't find an egg-info/dist-info in the given path, but if a - # setup.py exists we can generate it - setup_py = os.path.join(path, 'setup.py') - if os.path.isfile(setup_py): - with _silence(): - run_setup(os.path.join(path, 'setup.py'), - ['egg_info']) - - for dist in pkg_resources.find_distributions(path, True): - # There should be only one... - return dist - - return dist - - def _do_download(self, version='', find_links=None): - if find_links: - allow_hosts = '' - index_url = None - else: - allow_hosts = None - index_url = self.index_url - - # Annoyingly, setuptools will not handle other arguments to - # Distribution (such as options) before handling setup_requires, so it - # is not straightforward to programmatically augment the arguments which - # are passed to easy_install - class _Distribution(Distribution): - def get_option_dict(self, command_name): - opts = Distribution.get_option_dict(self, command_name) - if command_name == 'easy_install': - if find_links is not None: - opts['find_links'] = ('setup script', find_links) - if index_url is not None: - opts['index_url'] = ('setup script', index_url) - if allow_hosts is not None: - opts['allow_hosts'] = ('setup script', allow_hosts) - return opts - - if version: - req = '{0}=={1}'.format(DIST_NAME, version) - else: - req = DIST_NAME - - attrs = {'setup_requires': [req]} - - try: - if DEBUG: - _Distribution(attrs=attrs) - else: - with _silence(): - _Distribution(attrs=attrs) - - # If the setup_requires succeeded it will have added the new dist to - # the main working_set - return pkg_resources.working_set.by_key.get(DIST_NAME) - except Exception as e: - if DEBUG: - raise - - msg = 'Error retrieving {0} from {1}:\n{2}' - if find_links: - source = find_links[0] - elif index_url != INDEX_URL: - source = index_url - else: - source = 'PyPI' - - raise Exception(msg.format(DIST_NAME, source, repr(e))) - - def _do_upgrade(self, dist): - # Build up a requirement for a higher bugfix release but a lower minor - # release (so API compatibility is guaranteed) - next_version = _next_version(dist.parsed_version) - - req = pkg_resources.Requirement.parse( - '{0}>{1},<{2}'.format(DIST_NAME, dist.version, next_version)) - - package_index = PackageIndex(index_url=self.index_url) - - upgrade = package_index.obtain(req) - - if upgrade is not None: - return self._do_download(version=upgrade.version) - - def _check_submodule(self): - """ - Check if the given path is a git submodule. - - See the docstrings for ``_check_submodule_using_git`` and - ``_check_submodule_no_git`` for further details. - """ - - if (self.path is None or - (os.path.exists(self.path) and not os.path.isdir(self.path))): - return False - - if self.use_git: - return self._check_submodule_using_git() - else: - return self._check_submodule_no_git() - - def _check_submodule_using_git(self): - """ - Check if the given path is a git submodule. If so, attempt to initialize - and/or update the submodule if needed. - - This function makes calls to the ``git`` command in subprocesses. The - ``_check_submodule_no_git`` option uses pure Python to check if the given - path looks like a git submodule, but it cannot perform updates. - """ - - cmd = ['git', 'submodule', 'status', '--', self.path] - - try: - log.info('Running `{0}`; use the --no-git option to disable git ' - 'commands'.format(' '.join(cmd))) - returncode, stdout, stderr = run_cmd(cmd) - except _CommandNotFound: - # The git command simply wasn't found; this is most likely the - # case on user systems that don't have git and are simply - # trying to install the package from PyPI or a source - # distribution. Silently ignore this case and simply don't try - # to use submodules - return False - - stderr = stderr.strip() - - if returncode != 0 and stderr: - # Unfortunately the return code alone cannot be relied on, as - # earlier versions of git returned 0 even if the requested submodule - # does not exist - - # This is a warning that occurs in perl (from running git submodule) - # which only occurs with a malformatted locale setting which can - # happen sometimes on OSX. See again - # https://github.com/astropy/astropy/issues/2749 - perl_warning = ('perl: warning: Falling back to the standard locale ' - '("C").') - if not stderr.strip().endswith(perl_warning): - # Some other unknown error condition occurred - log.warn('git submodule command failed ' - 'unexpectedly:\n{0}'.format(stderr)) - return False - - # Output of `git submodule status` is as follows: - # - # 1: Status indicator: '-' for submodule is uninitialized, '+' if - # submodule is initialized but is not at the commit currently indicated - # in .gitmodules (and thus needs to be updated), or 'U' if the - # submodule is in an unstable state (i.e. has merge conflicts) - # - # 2. SHA-1 hash of the current commit of the submodule (we don't really - # need this information but it's useful for checking that the output is - # correct) - # - # 3. The output of `git describe` for the submodule's current commit - # hash (this includes for example what branches the commit is on) but - # only if the submodule is initialized. We ignore this information for - # now - _git_submodule_status_re = re.compile( - '^(?P[+-U ])(?P[0-9a-f]{40}) ' - '(?P\S+)( .*)?$') - - # The stdout should only contain one line--the status of the - # requested submodule - m = _git_submodule_status_re.match(stdout) - if m: - # Yes, the path *is* a git submodule - self._update_submodule(m.group('submodule'), m.group('status')) - return True - else: - log.warn( - 'Unexpected output from `git submodule status`:\n{0}\n' - 'Will attempt import from {1!r} regardless.'.format( - stdout, self.path)) - return False - - def _check_submodule_no_git(self): - """ - Like ``_check_submodule_using_git``, but simply parses the .gitmodules file - to determine if the supplied path is a git submodule, and does not exec any - subprocesses. - - This can only determine if a path is a submodule--it does not perform - updates, etc. This function may need to be updated if the format of the - .gitmodules file is changed between git versions. - """ - - gitmodules_path = os.path.abspath('.gitmodules') - - if not os.path.isfile(gitmodules_path): - return False - - # This is a minimal reader for gitconfig-style files. It handles a few of - # the quirks that make gitconfig files incompatible with ConfigParser-style - # files, but does not support the full gitconfig syntax (just enough - # needed to read a .gitmodules file). - gitmodules_fileobj = io.StringIO() - - # Must use io.open for cross-Python-compatible behavior wrt unicode - with io.open(gitmodules_path) as f: - for line in f: - # gitconfig files are more flexible with leading whitespace; just - # go ahead and remove it - line = line.lstrip() - - # comments can start with either # or ; - if line and line[0] in (':', ';'): - continue - - gitmodules_fileobj.write(line) - - gitmodules_fileobj.seek(0) - - cfg = RawConfigParser() - - try: - cfg.readfp(gitmodules_fileobj) - except Exception as exc: - log.warn('Malformatted .gitmodules file: {0}\n' - '{1} cannot be assumed to be a git submodule.'.format( - exc, self.path)) - return False - - for section in cfg.sections(): - if not cfg.has_option(section, 'path'): - continue - - submodule_path = cfg.get(section, 'path').rstrip(os.sep) - - if submodule_path == self.path.rstrip(os.sep): - return True - - return False - - def _update_submodule(self, submodule, status): - if status == ' ': - # The submodule is up to date; no action necessary - return - elif status == '-': - if self.offline: - raise _AHBootstrapSystemExit( - "Cannot initialize the {0} submodule in --offline mode; " - "this requires being able to clone the submodule from an " - "online repository.".format(submodule)) - cmd = ['update', '--init'] - action = 'Initializing' - elif status == '+': - cmd = ['update'] - action = 'Updating' - if self.offline: - cmd.append('--no-fetch') - elif status == 'U': - raise _AHBoostrapSystemExit( - 'Error: Submodule {0} contains unresolved merge conflicts. ' - 'Please complete or abandon any changes in the submodule so that ' - 'it is in a usable state, then try again.'.format(submodule)) - else: - log.warn('Unknown status {0!r} for git submodule {1!r}. Will ' - 'attempt to use the submodule as-is, but try to ensure ' - 'that the submodule is in a clean state and contains no ' - 'conflicts or errors.\n{2}'.format(status, submodule, - _err_help_msg)) - return - - err_msg = None - cmd = ['git', 'submodule'] + cmd + ['--', submodule] - log.warn('{0} {1} submodule with: `{2}`'.format( - action, submodule, ' '.join(cmd))) - - try: - log.info('Running `{0}`; use the --no-git option to disable git ' - 'commands'.format(' '.join(cmd))) - returncode, stdout, stderr = run_cmd(cmd) - except OSError as e: - err_msg = str(e) - else: - if returncode != 0: - err_msg = stderr - - if err_msg is not None: - log.warn('An unexpected error occurred updating the git submodule ' - '{0!r}:\n{1}\n{2}'.format(submodule, err_msg, - _err_help_msg)) - -class _CommandNotFound(OSError): - """ - An exception raised when a command run with run_cmd is not found on the - system. - """ - - -def run_cmd(cmd): - """ - Run a command in a subprocess, given as a list of command-line - arguments. - - Returns a ``(returncode, stdout, stderr)`` tuple. - """ - - try: - p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE) - # XXX: May block if either stdout or stderr fill their buffers; - # however for the commands this is currently used for that is - # unlikely (they should have very brief output) - stdout, stderr = p.communicate() - except OSError as e: - if DEBUG: - raise - - if e.errno == errno.ENOENT: - msg = 'Command not found: `{0}`'.format(' '.join(cmd)) - raise _CommandNotFound(msg, cmd) - else: - raise _AHBoostrapSystemExit( - 'An unexpected error occurred when running the ' - '`{0}` command:\n{1}'.format(' '.join(cmd), str(e))) - - - # Can fail of the default locale is not configured properly. See - # https://github.com/astropy/astropy/issues/2749. For the purposes under - # consideration 'latin1' is an acceptable fallback. - try: - stdio_encoding = locale.getdefaultlocale()[1] or 'latin1' - except ValueError: - # Due to an OSX oddity locale.getdefaultlocale() can also crash - # depending on the user's locale/language settings. See: - # http://bugs.python.org/issue18378 - stdio_encoding = 'latin1' - - # Unlikely to fail at this point but even then let's be flexible - if not isinstance(stdout, _text_type): - stdout = stdout.decode(stdio_encoding, 'replace') - if not isinstance(stderr, _text_type): - stderr = stderr.decode(stdio_encoding, 'replace') - - return (p.returncode, stdout, stderr) - - -def _next_version(version): - """ - Given a parsed version from pkg_resources.parse_version, returns a new - version string with the next minor version. - - Examples - ======== - >>> _next_version(pkg_resources.parse_version('1.2.3')) - '1.3.0' - """ - - if hasattr(version, 'base_version'): - # New version parsing from setuptools >= 8.0 - if version.base_version: - parts = version.base_version.split('.') - else: - parts = [] - else: - parts = [] - for part in version: - if part.startswith('*'): - break - parts.append(part) - - parts = [int(p) for p in parts] - - if len(parts) < 3: - parts += [0] * (3 - len(parts)) - - major, minor, micro = parts[:3] - - return '{0}.{1}.{2}'.format(major, minor + 1, 0) - - -class _DummyFile(object): - """A noop writeable object.""" - - errors = '' # Required for Python 3.x - encoding = 'utf-8' - - def write(self, s): - pass - - def flush(self): - pass - - -@contextlib.contextmanager -def _silence(): - """A context manager that silences sys.stdout and sys.stderr.""" - - old_stdout = sys.stdout - old_stderr = sys.stderr - sys.stdout = _DummyFile() - sys.stderr = _DummyFile() - exception_occurred = False - try: - yield - except: - exception_occurred = True - # Go ahead and clean up so that exception handling can work normally - sys.stdout = old_stdout - sys.stderr = old_stderr - raise - - if not exception_occurred: - sys.stdout = old_stdout - sys.stderr = old_stderr - - -_err_help_msg = """ -If the problem persists consider installing astropy_helpers manually using pip -(`pip install astropy_helpers`) or by manually downloading the source archive, -extracting it, and installing by running `python setup.py install` from the -root of the extracted source code. -""" - - -class _AHBootstrapSystemExit(SystemExit): - def __init__(self, *args): - if not args: - msg = 'An unknown problem occurred bootstrapping astropy_helpers.' - else: - msg = args[0] - - msg += '\n' + _err_help_msg - - super(_AHBootstrapSystemExit, self).__init__(msg, *args[1:]) - - -if sys.version_info[:2] < (2, 7): - # In Python 2.6 the distutils log does not log warnings, errors, etc. to - # stderr so we have to wrap it to ensure consistency at least in this - # module - import distutils - - class log(object): - def __getattr__(self, attr): - return getattr(distutils.log, attr) - - def warn(self, msg, *args): - self._log_to_stderr(distutils.log.WARN, msg, *args) - - def error(self, msg): - self._log_to_stderr(distutils.log.ERROR, msg, *args) - - def fatal(self, msg): - self._log_to_stderr(distutils.log.FATAL, msg, *args) - - def log(self, level, msg, *args): - if level in (distutils.log.WARN, distutils.log.ERROR, - distutils.log.FATAL): - self._log_to_stderr(level, msg, *args) - else: - distutils.log.log(level, msg, *args) - - def _log_to_stderr(self, level, msg, *args): - # This is the only truly 'public' way to get the current threshold - # of the log - current_threshold = distutils.log.set_threshold(distutils.log.WARN) - distutils.log.set_threshold(current_threshold) - if level >= current_threshold: - if args: - msg = msg % args - sys.stderr.write('%s\n' % msg) - sys.stderr.flush() - - log = log() - - -BOOTSTRAPPER = _Bootstrapper.main() - - -def use_astropy_helpers(**kwargs): - """ - Ensure that the `astropy_helpers` module is available and is importable. - This supports automatic submodule initialization if astropy_helpers is - included in a project as a git submodule, or will download it from PyPI if - necessary. - - Parameters - ---------- - - path : str or None, optional - A filesystem path relative to the root of the project's source code - that should be added to `sys.path` so that `astropy_helpers` can be - imported from that path. - - If the path is a git submodule it will automatically be initialized - and/or updated. - - The path may also be to a ``.tar.gz`` archive of the astropy_helpers - source distribution. In this case the archive is automatically - unpacked and made temporarily available on `sys.path` as a ``.egg`` - archive. - - If `None` skip straight to downloading. - - download_if_needed : bool, optional - If the provided filesystem path is not found an attempt will be made to - download astropy_helpers from PyPI. It will then be made temporarily - available on `sys.path` as a ``.egg`` archive (using the - ``setup_requires`` feature of setuptools. If the ``--offline`` option - is given at the command line the value of this argument is overridden - to `False`. - - index_url : str, optional - If provided, use a different URL for the Python package index than the - main PyPI server. - - use_git : bool, optional - If `False` no git commands will be used--this effectively disables - support for git submodules. If the ``--no-git`` option is given at the - command line the value of this argument is overridden to `False`. - - auto_upgrade : bool, optional - By default, when installing a package from a non-development source - distribution ah_boostrap will try to automatically check for patch - releases to astropy-helpers on PyPI and use the patched version over - any bundled versions. Setting this to `False` will disable that - functionality. If the ``--offline`` option is given at the command line - the value of this argument is overridden to `False`. - - offline : bool, optional - If `False` disable all actions that require an internet connection, - including downloading packages from the package index and fetching - updates to any git submodule. Defaults to `True`. - """ - - global BOOTSTRAPPER - - config = BOOTSTRAPPER.config - config.update(**kwargs) - - # Create a new bootstrapper with the updated configuration and run it - BOOTSTRAPPER = _Bootstrapper(**config) - BOOTSTRAPPER.run() From 3d32db3dc071a7956833df216cef849b64912615 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Thu, 16 Nov 2017 23:36:40 -0500 Subject: [PATCH 112/113] add additional dev info --- tutorials/dev.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tutorials/dev.rst b/tutorials/dev.rst index 6d6ab285a..688c8eef5 100644 --- a/tutorials/dev.rst +++ b/tutorials/dev.rst @@ -88,6 +88,9 @@ do:: git submodule update make html +Once this is done, you will find the index for the pages in your local +``build/html/index.html`` file. + Releases -------- @@ -97,6 +100,10 @@ bugfix releases like 2.0.3, etc. With each release, we update the pinned versions of the global dependency files (``conda-envirionment.yml`` for Anaconda and ``pip-requirements.txt`` for pip). +To actually update the version, modify the ``metadata.cfg`` at the root of this +repository with the new version. This is the version number that will be +shown in the sphinx builds. + Marking a cell with an intentional error ---------------------------------------- From ee479d08fab79c1771a50f1612b7764f73ecb5e5 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Fri, 17 Nov 2017 00:02:10 -0500 Subject: [PATCH 113/113] use sensible dev versions --- tutorials/conf.py | 23 ++++++++++++++++++----- tutorials/dev.rst | 3 ++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tutorials/conf.py b/tutorials/conf.py index 30ccd112e..c6014c257 100644 --- a/tutorials/conf.py +++ b/tutorials/conf.py @@ -4,9 +4,9 @@ # Astropy documentation build configuration file. import datetime +import re import os import sys -from os import path # Building from inside the tutorials/ directory? Need to add correct helpers to the python path a_h_path = None @@ -17,6 +17,8 @@ # Load all of the global Astropy configuration try: + # at some point hopefully this can be replaced with installing a + # standalone sphinx-astropy-theme from astropy_helpers.sphinx.conf import * import astropy_helpers @@ -42,6 +44,7 @@ conf.read([os.path.join(os.path.dirname(__file__), '..', 'metadata.cfg')]) setup_cfg = dict(conf.items('metadata')) + # -- General configuration ---------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. @@ -72,11 +75,21 @@ # |version| and |release|, also used in various other places throughout the # built documents. -# The short X.Y version. -version = setup_cfg['version'].split('-', 1)[0] # The full version, including alpha/beta/rc tags. -# release = package.__version__ -release = version +release = setup_cfg['version'] +# The short X.Y version. +version = re.match(r'([\d\.]*)(\D*\d?)', setup_cfg['version']).group(1) +if version.endswith('.'): # e.g. "3.0.dev", which splits into groups "3.0." and "dev" + version = version[:-1] + + +if release.endswith('dev'): + # once the sphinx-astropy-theme is ready, just copy over the git_helpers.py file + # into this repo - it has been long-term stable so the helpers aren't needed + # just for this. + from astropy_helpers.git_helpers import get_git_devstr + release = release + get_git_devstr(path=os.path.join(os.path.split(__file__)[0],'..')) + # -- Options for HTML output -------------------------------------------------- diff --git a/tutorials/dev.rst b/tutorials/dev.rst index 688c8eef5..0652ab764 100644 --- a/tutorials/dev.rst +++ b/tutorials/dev.rst @@ -102,7 +102,8 @@ and ``pip-requirements.txt`` for pip). To actually update the version, modify the ``metadata.cfg`` at the root of this repository with the new version. This is the version number that will be -shown in the sphinx builds. +shown in the sphinx builds. Note that if it ends in ``.dev``, this will be +followed by a revision number that is determined by the number of git commits. Marking a cell with an intentional error ----------------------------------------