Skip to content

Commit

Permalink
Merge pull request #11 from choldgraf/thebe
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Jul 16, 2020
2 parents a485ea5 + 1dbe7ba commit 7376cf7
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 126 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# sphinx-thebelab
# sphinx-thebe

[![Documentation](https://readthedocs.org/projects/sphinx-thebelab/badge/?version=latest)](https://sphinx-thebelab.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://img.shields.io/pypi/v/sphinx-thebelab.svg)](https://pypi.org/project/sphinx-thebelab)
[![Documentation](https://readthedocs.org/projects/sphinx-thebe/badge/?version=latest)](https://sphinx-thebe.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://img.shields.io/pypi/v/sphinx-thebe.svg)](https://pypi.org/project/sphinx-thebe)

Integrate interactive code blocks into your documentation with Thebelab and Binder.

See [the sphinx-thebelab documentation](https://sphinx-thebelab.readthedocs.io/en/latest/) for more details!
See [the sphinx-thebe documentation](https://sphinx-thebe.readthedocs.io/en/latest/) for more details!

## Install

To install `sphinx-thebelab` first clonse and install it:
To install `sphinx-thebe` first clonse and install it:

```
pip install sphinx-thebelab
pip install sphinx-thebe
```

Then, add it to your Sphinx site's `conf.py` file:

```
extensions = [
...
"sphinx_thebelab"
"sphinx_thebe"
...
]
```

See [the sphinx-thebelab documentation](https://sphinx-thebelab.readthedocs.io/en/latest/) for more details!
See [the sphinx-thebe documentation](https://sphinx-thebe.readthedocs.io/en/latest/) for more details!
18 changes: 9 additions & 9 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Instructions for creating a new release

Spinx-Copybutton is [hosted on the pypi repository](https://pypi.org/project/sphinx-thebelab/).
To create a new release of sphinx-thebelab, you need to do these things:
Spinx-Copybutton is [hosted on the pypi repository](https://pypi.org/project/sphinx-thebe/).
To create a new release of sphinx-thebe, you need to do these things:

## Before you start

1. Ensure that you have push access to the [sphinx-thebelab pypi repository](https://pypi.org/project/sphinx-thebelab/)
1. Ensure that you have push access to the [sphinx-thebe pypi repository](https://pypi.org/project/sphinx-thebe/)
2. Install [the twine package](https://twine.readthedocs.io/en/latest/). This is a package that helps you
bundle and push new Python package distributions to pip.

## To create the release

To create a new release, [open an issue](https://github.com/executablebooks/sphinx-thebelab/issues/new) to keep
To create a new release, [open an issue](https://github.com/executablebooks/sphinx-thebe/issues/new) to keep
track of the to-do list for the release. Copy/paste the following markdown into the issue
and check off the boxes as you complete items:


```
- [ ] Ensure that the [sphinx-thebelab version number](https://github.com/executablebooks/sphinx-thebelab/blob/master/jupyter_book/__init__.py)
- [ ] Ensure that the [sphinx-thebe version number](https://github.com/executablebooks/sphinx-thebe/blob/master/jupyter_book/__init__.py)
is correct, and remove the `dev0` part of the version number.
Make a PR with the new number and merge into master.
- [ ] Create a new distribution for sphinx-thebelab by
- [ ] Create a new distribution for sphinx-thebe by
[following the twine release instructions](https://twine.readthedocs.io/en/latest/#using-twine)
- [ ] Confirm that the new version of sphinx-thebelab [is posted to pypi](https://pypi.org/project/sphinx-thebelab/)
- [ ] Bump the [sphinx-thebelab version number](https://github.com/executablebooks/sphinx-thebelab/blob/master/jupyter_book/__init__.py) to
- [ ] Confirm that the new version of sphinx-thebe [is posted to pypi](https://pypi.org/project/sphinx-thebe/)
- [ ] Bump the [sphinx-thebe version number](https://github.com/executablebooks/sphinx-thebe/blob/master/jupyter_book/__init__.py) to
the next minor (or major) release and append `dev0` to the end.
- [ ] Celebrate! You've just released a new version of sphinx-thebelab!
- [ ] Celebrate! You've just released a new version of sphinx-thebe!
```
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# -- Project information -----------------------------------------------------

project = "Sphinx Thebelab"
project = "Sphinx Thebe"
copyright = "2020, Executable Book Project"
author = "Executable Book Project"

Expand All @@ -38,7 +38,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx_thebelab", "myst_parser"]
extensions = ["jupyter_sphinx", "sphinx_thebe", "myst_parser"]

thebe_config = {
"repository_url": "https://github.com/binder-examples/jupyter-stacks-datascience",
Expand Down Expand Up @@ -90,7 +90,7 @@
# documentation.
#
html_theme_options = {
"repository_url": "https://github.com/executablebooks/sphinx-thebelab",
"repository_url": "https://github.com/executablebooks/sphinx-thebe",
"path_to_docs": "docs",
"use_repository_button": True,
"use_issues_button": True,
Expand Down
42 changes: 21 additions & 21 deletions docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
thebe-kernel: ir
---

# Configuring thebelab
# Configuring thebe

## Change the HTML selector to mark interactive cells

By default, `sphinx-thebelab` will be run on any cells with the `thebe` class.
By default, `sphinx-thebe` will be run on any cells with the `thebe` class.
However, you can customize the HTML selector to use other classes, elements, etc.

For example, if you wanted to convert **all code cells**, you could use the following
Expand All @@ -19,19 +19,19 @@ thebe_config = {
```

```{note}
`sphinx-thebelab` will subsequently look for any `pre` blocks inside of elements it
`sphinx-thebe` will subsequently look for any `pre` blocks inside of elements it
finds with the `selector` configuration value. These are the blocks that will be
converted to interactive with `thebelab`.
converted to interactive with `thebe`.
```

## Including outputs with your code

If you'd like to include outputs in the *static* version of your page, and only
overwrite them once the user has run that Thebelab cell, you can configure `sphinx-thebelab`
overwrite them once the user has run that Thebe cell, you can configure `sphinx-thebe`
to detect and keep the outputs associated with some code. To do so, use
the `selector_output` configuration. This is a selector that is searched for *within* any
items discovered by `selector`. If an output is found, it will be placed just after the
code and Thebelab will detect it.
code and Thebe will detect it.

For example, the following code:

Expand All @@ -53,7 +53,7 @@ code. We'll use a `code-block` for the code, and another `container` node with o
it has a `thebe` class. It will detect the `pre` block inside the container as the
code, and it will detect the `<div>` block with the `output` class as the output.

The result is that initializing Thebelab *retains* the output until the cell is
The result is that initializing Thebe *retains* the output until the cell is
executed, like so:

```{thebe-button}
Expand All @@ -71,7 +71,7 @@ print("hi")

## Setting the Kernel

You can set the kernel that Thebelab uses on a page by adding metadata to your
You can set the kernel that Thebe uses on a page by adding metadata to your
page. To do so, add the following metadata to the top of your page:

```
Expand All @@ -85,10 +85,10 @@ thebe-kernel: ir
```

In addition, this website is configured to use the [Binder R example repository](https://github.com/binder-examples/r)
for its environment. As a result, we can now run R code interactively with Thebelab:
for its environment. As a result, we can now run R code interactively with Thebe:


```{thebe-button} Launch thebelab in R
```{thebe-button} Launch thebe in R
```

```{code-block}
Expand Down Expand Up @@ -144,30 +144,30 @@ will be displayed below.


(add-custom-button)=
## Adding your own button to start Thebelab
## Adding your own button to start Thebe

By default, Thebelab encourages users to use the `thebe-button` directive to
insert a thebelab button into their documentation. However, you can add your own
By default, Thebe encourages users to use the `thebe-button` directive to
insert a thebe button into their documentation. However, you can add your own
buttons wherever you wish. Simply ensure that an HTML element has this attribute:

```
onclick="initThebelab()"
onclick="initThebe()"
```

and it will be able to initialize Thebelab on that page on its own.
and it will be able to initialize Thebe on that page on its own.

For example, here is the HTML for the Thebelab button generated by the `thebe-button`
For example, here is the HTML for the Thebe button generated by the `thebe-button`
directive:

```html
<button title="Make live" class="thebe-button" onclick="initThebelab()">
<button title="Make live" class="thebe-button" onclick="initThebe()">
Make live
</button>
```

## Choose a codemirror theme

You can customize `sphinx-thebelab` to use the codemirror theme of your choice.
You can customize `sphinx-thebe` to use the codemirror theme of your choice.
To do so, use the following configuration:

```
Expand All @@ -182,9 +182,9 @@ of themes that you can use, and what they look like.

## Configuration reference

Here's a reference of all of the configuration values avialable to `sphinx-thebelab`.
Many of these eventually make their was into the `thebelab` configuration. You can
find a [reference for `thebelab` configuration here](https://thebelab.readthedocs.io/en/latest/config_reference.html).
Here's a reference of all of the configuration values avialable to `sphinx-thebe`.
Many of these eventually make their was into the `thebe` configuration. You can
find a [reference for `thebe` configuration here](https://thebelab.readthedocs.io/en/latest/config_reference.html).

```
thebe_config = {
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/rst.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Using rST syntax

This documentation is written in `MyST Markdown <https://myst-parser.readthedocs.io/>`_,
so the syntax shown is a little bit different than many Sphinx sites, which are written
in reStructuredText. However, ``sphinx-thebelab`` works fine in both. Here is the syntax
for using ``sphinx-thebelab`` with rST:
in reStructuredText. However, ``sphinx-thebe`` works fine in both. Here is the syntax
for using ``sphinx-thebe`` with rST:

Adding a ``thebe`` class to a code block:

Expand Down
28 changes: 14 additions & 14 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# sphinx-thebelab
# sphinx-thebe


```{image} https://readthedocs.org/projects/sphinx-thebelab/badge/?version=latest
:target: https://sphinx-thebelab.readthedocs.io/en/latest/?badge=latest
```{image} https://readthedocs.org/projects/sphinx-thebe/badge/?version=latest
:target: https://sphinx-thebe.readthedocs.io/en/latest/?badge=latest
:alt: Documentation
```

```{image} https://img.shields.io/pypi/v/sphinx-thebelab.svg
:target: https://pypi.org/project/sphinx_thebelab
```{image} https://img.shields.io/pypi/v/sphinx-thebe.svg
:target: https://pypi.org/project/sphinx_thebe
:alt: PyPi page
```

Make your code cells interactive with a kernel provided by [Thebelab](http://thebelab.readthedocs.org/)
Make your code cells interactive with a kernel provided by [Thebe](http://thebelab.readthedocs.org/)
and [Binder](https://mybinder.org).

For example, click the button below. Notice that the code block beneath becomes
editable and runnable!

```{thebe-button} Launch thebelab
```{thebe-button} Launch thebe
```

```{code-block} python
Expand All @@ -26,37 +26,37 @@ editable and runnable!
print("hi")
```

See [](use.md) for more information about what you can do with `sphinx-thebelab`.
See [](use.md) for more information about what you can do with `sphinx-thebe`.

```{note}
This package is a Sphinx wrapper around the excellent [thebelab project](http://thebelab.readthedocs.org/),
This package is a Sphinx wrapper around the excellent [thebe project](http://thebelab.readthedocs.org/),
a javascript tool to convert static code cells into interactive cells backed
by a kernel.
```

## Install

To install `sphinx-thebelab` first clonse and install it:
To install `sphinx-thebe` first clonse and install it:

```
pip install sphinx-thebelab
pip install sphinx-thebe
```

Then, add it to your Sphinx site's `conf.py` file:

```
extensions = [
...
"sphinx_thebelab"
"sphinx_thebe"
...
]
```

## Configure and use

For more information about how to configure `sphinx-thebelab`, see [](configure.md).
For more information about how to configure `sphinx-thebe`, see [](configure.md).

For more information on using `sphinx-thebelab`, see [](use.md).
For more information on using `sphinx-thebe`, see [](use.md).

```{toctree}
:hidden:
Expand Down
36 changes: 18 additions & 18 deletions docs/use.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Using `sphinx-thebelab`
# Using `sphinx-thebe`

## Get started

There are two steps to using `sphinx-thebelab`. First, you must mark certain
parts of your page as "ready for thebelab". Next, you must insert a button onto
the page to tell Thebelab to initialize.
There are two steps to using `sphinx-thebe`. First, you must mark certain
parts of your page as "ready for thebe". Next, you must insert a button onto
the page to tell Thebe to initialize.

```{tip}
The examples on this page use a flavor of markdown called [MyST Markdown](https://myst-parser.readthedocs.io/en/latest/).
However you can also use reStructuredText with `sphinx-thebelab` in the same way. See
However you can also use reStructuredText with `sphinx-thebe` in the same way. See
[](examples/rst) for some tips.
```

### Mark elements for thebelab
### Mark elements for thebe

By default, thebelab will be run on any elements in your documentation that contain
the class `thebelab` and that have a `<pre`> element underneath them.
By default, thebe will be run on any elements in your documentation that contain
the class `thebe` and that have a `<pre`> element underneath them.

```{note}
This documentation is written in [MyST Markdown](https://myst-parser.readthedocs.io),
Expand All @@ -31,8 +31,8 @@ You can add code blocks like so:
```
````

By default, `sphinx-thebelab` will look for any HTML `<pre>` element *inside* the code
block. Thebelab will run on that element.
By default, `sphinx-thebe` will look for any HTML `<pre>` element *inside* the code
block. Thebe will run on that element.

### Add an activate button to your page

Expand All @@ -49,20 +49,20 @@ The button looks like this:
```{thebe-button}
```

Clicking this button will activate Thebelab on the page. If you'd like to manually
Clicking this button will activate Thebe on the page. If you'd like to manually
add your own button (e.g. with your own extension or theme), see [](add-custom-button).

```{note}
By default, `sphinx-thebelab` will serve the Binder environment for the
By default, `sphinx-thebe` will serve the Binder environment for the
[jupyter-stacks-datascience repository](https://github.com/binder-examples/jupyter-stacks-datascience).
See [](configure.md) for information on choosing your own environment.
```

## What can I do with `sphinx-thebelab`?
## What can I do with `sphinx-thebe`?

`sphinx-thebelab` uses Jupyter kernels to execute your page's code and return the
`sphinx-thebe` uses Jupyter kernels to execute your page's code and return the
results, and Binder in order to run the infrastructure for execution. This means that
you can do nearly anything with `sphinx-thebelab` that you could do from within a
you can do nearly anything with `sphinx-thebe` that you could do from within a
Jupyter Notebook cell.

```{admonition} You can customize your environment
Expand Down Expand Up @@ -110,10 +110,10 @@ plt.scatter(*data, c=data[0], s=200)
### Interactive outputs

Interactive outputs are still a little bit flaky, but please try out
`sphinx-thebelab` with the interactive visualization library of your choice,
`sphinx-thebe` with the interactive visualization library of your choice,
and report back how things work!

As a general rule, `sphinx-thebelab` will only work with interactive libraries
As a general rule, `sphinx-thebe` will only work with interactive libraries
that are able to output self-contained bundles of HTML/JS that work on their own.
Many Jupyter environments have libraries pre-loaded, and that will not be the case
with `sphinx-thebelab`.
with `sphinx-thebe`.

0 comments on commit 7376cf7

Please sign in to comment.