Commit 73e09ea8 authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Initial website change

parent 77e838be
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ fi
# -----------------------------------
echo "About to install numpydoc, s3cmd"
pip install numpydoc s3cmd msmb_theme sphinx_rtd_theme
pip install -I sphinx==1.3.5 sphinx_bootstrap_theme
conda list -e
mkdir -p docs/_build
echo "About to build docs"
+22 −7
Original line number Diff line number Diff line
@@ -15,12 +15,14 @@
import sys
import os
import shlex
import sphinx_bootstrap_theme

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath("../../deepchem"))
sys.path.insert(0, os.path.abspath("../sphinxext"))

# -- General configuration ------------------------------------------------

@@ -40,6 +42,7 @@ extensions = [
    'sphinx.ext.ifconfig',
    'numpydoc',
    'sphinx.ext.viewcode',
    'notebook_sphinxext'
]

autosummary_generate = True
@@ -69,9 +72,9 @@ copyright = u'2016, Stanford University and the Authors'
# built documents.
#
# The short X.Y version.
version = '0.1'
version = '1.2'
# The full version, including alpha/beta/rc tags.
release = '0.1'
release = '1.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -88,7 +91,7 @@ language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
exclude_patterns = ['_build', '**.ipynb_checkpoints']

# The reST default role (used for this markup: `text`) to use for all
# documents.
@@ -124,17 +127,27 @@ todo_include_todos = False
# a list of builtin themes.
import msmb_theme

html_theme = 'msmb_theme'
html_theme = 'bootstrap'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
html_theme_options = {
    'source_link_position': "footer",
    'bootswatch_theme': "flatly",
    'navbar_sidebarrel': False,
    'bootstrap_version': "3",
    'navbar_links': [("Notebooks", "notebooks/index")],
}

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [
  msmb_theme.get_html_theme_path()
]
#print("sphinx_bootstrap_theme.get_html_theme_path()")
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
#html_theme_path = [
#  #msmb_theme.get_html_theme_path(),
#  sphinx_bootstrap_theme.get_html_theme_path()
#]

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
@@ -146,6 +159,7 @@ html_theme_path = [
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = '_static/logo.png' 
#html_logo = '../website/static/img/logo.png' 

# 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
@@ -156,6 +170,7 @@ html_logo = '_static/logo.png'
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
#html_static_path = ['../website/static/']

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
+4 −0
Original line number Diff line number Diff line
BACE
====

.. notebook:: BACE 
+30 −0
Original line number Diff line number Diff line
.. _notebooks:

Tutorials
========

The following tutorials show off various aspects or capabilities of
DeepChem. They can be run interactively in Jupyter (IPython) notebook.
Download the `notebook files
<https://github.com/deepchem/deepchem/tree/master/examples/notebooks>`_ and open
them in Jupyter::

    $ jupyter notebook

.. To make the ipython rendered images show up, each rst file must be
   in its own directory.

.. toctree::
   :maxdepth: 2
   :titlesonly:

   BACE 


Contributing tutorials 
----------------------

Do you have a neat example of using DeepChem? Format your code
into an IPython notebook and submit a pull request!

.. vim: tw=75
+129 −0
Original line number Diff line number Diff line
# Copied from the yt_project, commit e8fb57e
# yt/doc/extensions/notebook_sphinxext.py
#  https://bitbucket.org/yt_analysis/yt/src/e8fb57e66ca42e26052dadf054a5c782740abec9/doc/extensions/notebook_sphinxext.py?at=yt

# Almost completely re-written by Matthew Harrigan to use nbconvert v4

from __future__ import print_function

import os
import shutil

from sphinx.util.compat import Directive
from docutils import nodes
from docutils.parsers.rst import directives
import nbformat
from nbconvert import HTMLExporter, PythonExporter
from nbconvert.preprocessors import ExecutePreprocessor


def export_html(nb, f):
    config = {
        'Exporter': {'template_file': 'basic',
                     'template_path': ['./sphinxext/']},
        'ExtractOutputPreprocessor': {'enabled': True},
        'CSSHTMLHeaderPreprocessor': {'enabled': True}
    }

    exporter = HTMLExporter(config)
    body, resources = exporter.from_notebook_node(
        nb, resources={'output_files_dir': f['nbname']})

    for fn, data in resources['outputs'].items():
        bfn = os.path.basename(fn)
        with open("{destdir}/{fn}".format(fn=bfn, **f), 'wb') as res_f:
            res_f.write(data)

    return body


def export_python(nb, destfn):
    exporter = PythonExporter()
    body, resources = exporter.from_notebook_node(nb)
    with open(destfn, 'w') as f:
        f.write(body)


class NotebookDirective(Directive):
    """Insert an evaluated notebook into a document
    """
    required_arguments = 1
    optional_arguments = 1
    option_spec = {'skip_exceptions': directives.flag}
    final_argument_whitespace = True

    def run(self):
        f = {
            'docdir': setup.confdir,
            'builddir': setup.app.builder.outdir,
            'nbname': self.arguments[0],
        }
        f['nbpath'] = "{docdir}/../../examples/notebooks/{nbname}.ipynb".format(**f)
        f['destdir'] = "{builddir}/notebooks/{nbname}".format(**f)

        if not os.path.exists(f['destdir']):
            os.makedirs(f['destdir'])

        f['uneval'] = "{destdir}/{nbname}.ipynb".format(**f)
        f['eval'] = "{destdir}/{nbname}.eval.ipynb".format(**f)
        f['py'] = "{destdir}/{nbname}.py".format(**f)

        # 1. Uneval notebook
        shutil.copyfile(f['nbpath'], f['uneval'])
        with open(f['nbpath']) as nb_f:
            nb = nbformat.read(nb_f, as_version=4)
        # 2. Python
        export_python(nb, f['py'])
        # 3. HTML (execute first)
        executer = ExecutePreprocessor()
        executer.preprocess(nb, {})
        html = export_html(nb, f)
        # 4. Eval'd notebook
        with open(f['eval'], 'w') as eval_f:
            nbformat.write(nb, eval_f)

        # Create link to notebook and script files
        link_rst = "({uneval}; {eval}; {py})".format(
            uneval=formatted_link(f['uneval']),
            eval=formatted_link(f['eval']),
            py=formatted_link(f['py']),
        )

        rst_file = self.state_machine.document.attributes['source']
        self.state_machine.insert_input([link_rst], rst_file)

        # create notebook node
        nb_node = notebook_node('', html, format='html', source='nb_path')
        nb_node.source, nb_node.line = (self.state_machine
                                        .get_source_and_line(self.lineno))

        # add dependency
        self.state.document.settings.record_dependencies.add(f['nbpath'])
        return [nb_node]


class notebook_node(nodes.raw):
    pass


def formatted_link(path):
    return "`%s <%s>`__" % (os.path.basename(path), path)


def visit_notebook_node(self, node):
    self.visit_raw(node)


def depart_notebook_node(self, node):
    self.depart_raw(node)


def setup(app):
    setup.app = app
    setup.config = app.config
    setup.confdir = app.confdir

    app.add_node(notebook_node,
                 html=(visit_notebook_node, depart_notebook_node))

    app.add_directive('notebook', NotebookDirective)
Loading