Skip to content

Commit

Permalink
fixing pre-commits
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Apr 11, 2020
1 parent 70202cd commit 1e366f0
Show file tree
Hide file tree
Showing 30 changed files with 53 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .binder/requirements.txt
@@ -1,4 +1,4 @@
matplotlib
numpy
folium
pandas
pandas
18 changes: 0 additions & 18 deletions .circleci/run_notebooks.py

This file was deleted.

3 changes: 3 additions & 0 deletions .flake8
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
ignore=E203,W503
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -131,4 +131,4 @@ dmypy.json
.pyre/

# VSCode config
.vscode
.vscode
2 changes: 1 addition & 1 deletion LICENSE
Expand Up @@ -26,4 +26,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -14,4 +14,4 @@ pip install -e .
```
cd docs
jupyter-book build
```
```
2 changes: 1 addition & 1 deletion docs/_toc.yml
Expand Up @@ -10,7 +10,7 @@

- file: customize/index
sections:
- file: customize/toc
- file: customize/toc
- file: customize/faq
- file: customize/advanced

Expand Down
2 changes: 1 addition & 1 deletion docs/customize/advanced.md
Expand Up @@ -60,7 +60,7 @@ To use it, simply use the following command:
jupyter-book toc path/to/mybook
```

This will treat all `.md` and `.ipynb` files in the root of the
This will treat all `.md` and `.ipynb` files in the root of the
**content folder** as top-level pages, or chapters.
For any files that are in folders, it will create one
section per **top-level folder** and treat all content files inside that
Expand Down
2 changes: 1 addition & 1 deletion docs/customize/index.md
Expand Up @@ -9,7 +9,7 @@ This page describes the general structure of `_config.yml`, and how
you can use it to control some basic parts of your book. The rest of the
pages in this section describe more detail for specific features.

## Structure of `_config.yml`
## Structure of `_config.yml`

Here is a very simple `_config.yml` configuration (it is taken from
{download}`the demo book config file <../../jupyter_book/book_template/_config.yml>`):
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.md
Expand Up @@ -76,4 +76,4 @@ The primary way to use this tool is via the command line. It provides a
top-level command called `jupyter-book`, and a number of sub-commands.
Run `jupyter-book -h` for more information.

For more information on how to use this tool, see {doc}`start/01_overview`.
For more information on how to use this tool, see {doc}`start/01_overview`.
18 changes: 9 additions & 9 deletions docs/use/citations.md
Expand Up @@ -32,36 +32,36 @@ way.
1. Modify the file in `_bibliography/references.bib`. This has a few sample citations
in bibtex form. Update as you wish!
2. In your content, add the following text to include a citation

```
{cite}`mybibtexcitation`
```

For example, this text

```
{cite}`holdgraf_rapid_2016`
```

generates this citation: {cite}`holdgraf_rapid_2016`

You can also include multiple citations in one go, like so:

```
{cite}`holdgraf_evidence_2014,holdgraf_portable_2017`
```

becomes {cite}`holdgraf_evidence_2014,holdgraf_portable_2017`.

3. Generate a bibliography on your page by using the following text:

````
```{bibliography} path/to/your/bibtexfile.bib
```
````

This will generate a bibliography for your entire bibtex file, like so:

```{bibliography} ../references.bib
```

Expand Down
4 changes: 2 additions & 2 deletions docs/use/hiding.md
Expand Up @@ -76,12 +76,12 @@ Some hidden toggle content!
You can hide most cell elements of a page. The sections below describe how
to hide each.

If an element is hidden, Jupyter Book will display a small button to the right of the
If an element is hidden, Jupyter Book will display a small button to the right of the
old location for the hidden element. If a user clicks the button,
the element will be displayed.


### Hide cell inputs
### Hide cell inputs

If you add the tag `hide-input` to a cell, then Jupyter Book will hide the cell but
display the outputs.
Expand Down
2 changes: 1 addition & 1 deletion docs/use/launchbuttons.ipynb
Expand Up @@ -192,4 +192,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
2 changes: 1 addition & 1 deletion docs/use/myst-notebooks.md
Expand Up @@ -181,5 +181,5 @@ Content in one markdown cell
Content in another markdown cell
```
````

[jupytext]: https://jupytext.readthedocs.io/
2 changes: 1 addition & 1 deletion docs/use/myst.md
Expand Up @@ -219,7 +219,7 @@ name: my_figure
Here is my figure caption!
```

You can then refer to this figure using the `{ref}` role like:
You can then refer to this figure using the `{ref}` role like:
`` {ref}`my-figure` ``, which will replace the reference with the figure
caption like so: {ref}`my_figure`.
Another convenient way to create cross-references is with the `{numref}` role,
Expand Down
2 changes: 1 addition & 1 deletion docs/use/notebooks.ipynb
Expand Up @@ -149,7 +149,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that the image above is captured and displayed by Jekyll."
"Note that the image above is captured and displayed in your site."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/single_page.ipynb
Expand Up @@ -113,4 +113,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
4 changes: 1 addition & 3 deletions jupyter_book/__init__.py
@@ -1,6 +1,4 @@
"""Build an online book using Jupyter Notebooks and Jekyll."""
from pathlib import Path
import os
"""Build a book with Jupyter Notebooks and Sphinx."""
from docutils.parsers.rst.directives.body import Sidebar
from .toc import update_indexname, add_toctree
from .yaml import add_yaml_config
Expand Down
2 changes: 1 addition & 1 deletion jupyter_book/book_template/_toc.yml
Expand Up @@ -3,4 +3,4 @@
sections:
- file: markdown
- file: notebooks
- file: syntax
- file: syntax
2 changes: 1 addition & 1 deletion jupyter_book/book_template/references.bib
Expand Up @@ -53,4 +53,4 @@ @book{ruby
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
}
8 changes: 4 additions & 4 deletions jupyter_book/commands/__init__.py
@@ -1,11 +1,9 @@
"""Defines the commands that the CLI will use."""
import sys
import os.path as op
from pathlib import Path
import click
from glob import glob
import shutil as sh
import asyncio

from ..sphinx import build_sphinx
from ..toc import build_toc
Expand Down Expand Up @@ -37,8 +35,9 @@ def build(path_book, path_output, config, toc, build):
book_config = {}
build_dict = {"html": "html", "pdf_html": "singlehtml"}
if build not in build_dict.keys():
allowed_keys = tuple(build_dict.keys())
raise ValueError(
f"Value for --build must be one of {tuple(build_dict.keys())}. Got '{build}'"
f"Value for --build must be one of {allowed_keys}. Got '{build}'"
)
builder = build_dict[build]

Expand All @@ -48,7 +47,8 @@ def build(path_book, path_output, config, toc, build):
toc = PATH_BOOK.joinpath("_toc.yml")
else:
raise ValueError(
f"Couldn't find a Table of Contents file. To auto-generate one, run\n\n\tjupyter-book build {path_book}"
f"Couldn't find a Table of Contents file. To auto-generate"
"one, run\n\n\tjupyter-book build {path_book}"
)
book_config["globaltoc_path"] = str(toc)

Expand Down
14 changes: 10 additions & 4 deletions jupyter_book/sphinx.py
Expand Up @@ -13,7 +13,7 @@
"""

ROOT = Path(__file__)
# Some configuration values that don't make sense to be in `default_config.yml` because they are sphinx-specific
# Some configuration values that are really sphinx-specific
DEFAULT_CONFIG = dict(
extensions=[
"sphinx_togglebutton",
Expand All @@ -30,7 +30,9 @@
html_theme="sphinx_book_theme",
html_theme_options={
"single_page": False,
"sidebar_footer_text": "Powered by <a href='https://jupyterbook.org'>Jupyter Book</a>",
"sidebar_footer_text": (
"Powered by <a href='https://jupyterbook.org'>Jupyter Book</a>"
),
},
html_add_permalinks="¶",
numfig=True,
Expand Down Expand Up @@ -150,11 +152,15 @@ def debug_args():
path_toc = Path(config["globaltoc_path"])
if not path_toc.exists():
raise ValueError(
f"You gave a Configuration file path that doesn't exist: {path_toc}"
(
f"You gave a Configuration file path"
"that doesn't exist: {path_toc}"
)
)
if path_toc.suffix not in [".yml", ".yaml"]:
raise ValueError(
f"You gave a Configuration file path that is not a YAML file: {path_toc}"
f"You gave a Configuration file path"
"that is not a YAML file: {path_toc}"
)
else:
path_toc = None
Expand Down
2 changes: 1 addition & 1 deletion jupyter_book/tests/books/toc/content2.md
@@ -1 +1 @@
# Content 2
# Content 2
2 changes: 1 addition & 1 deletion jupyter_book/tests/books/toc/subfolder/asubpage.md
@@ -1 +1 @@
# A subpage
# A subpage
2 changes: 1 addition & 1 deletion jupyter_book/tests/books/toc/subfolder/index.md
@@ -1 +1 @@
# Subfolder index
# Subfolder index
2 changes: 0 additions & 2 deletions jupyter_book/tests/test_build.py
@@ -1,7 +1,5 @@
import os
from pathlib import Path
from subprocess import run
import jupyter_book as jb


path_tests = Path(__file__).parent
Expand Down
2 changes: 1 addition & 1 deletion jupyter_book/tests/test_toc.py
Expand Up @@ -7,7 +7,7 @@
def test_toc():
path_book = Path(__file__).parent.joinpath("books", "toc")
toc_yaml = build_toc(path_book)
toc_dict = yaml.safe_load(toc_yaml)
_ = yaml.safe_load(toc_yaml)

# Folder with no content should return none
with pytest.raises(ValueError):
Expand Down
10 changes: 4 additions & 6 deletions jupyter_book/toc.py
Expand Up @@ -49,9 +49,7 @@ def add_toctree(app, docname, source):
parent_suff = Path(path_parent).suffix
# If we didn't find this page in the TOC, raise a warning
if parent_page is None:
logger.warning(
f"Found a content page that is not in Table of Contents: {path_parent}."
)
logger.warning(f"Found a content page that is not in _toc.yml: {path_parent}.")
return

# If we have no sections, then don't worry about a toctree
Expand Down Expand Up @@ -91,7 +89,7 @@ def gen_toctree(options, subsections):
)
return toctree

# Build toctrees for the page. We may need more than one depending on the options
# Build toctrees for the page. We may need more than one
toctrees = []
toc_sections = []
toc_options = []
Expand Down Expand Up @@ -126,7 +124,7 @@ def gen_toctree(options, subsections):
if parent_page.get(option):
toc_options.append(f":{option}:")

# Now create the final toctree for this page and prep them to insert into the page
# Now create the final toctree for this page and prep to insert into page
if toc_sections:
final_toctree = gen_toctree(toc_options, toc_sections)
toctrees.append(final_toctree)
Expand Down Expand Up @@ -245,7 +243,7 @@ def build_toc(path, filename_split_char="_", skip_text=None):
* All subsequent files are sections of the parent page
* For each sub-folder
* Its first page is appended to sections of the parent page
* All other sub-folder are children of the subfolder's first page
* All other sub-folder are children of the subfolder's first page
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion jupyter_book/yaml.py
Expand Up @@ -22,7 +22,7 @@ def add_yaml_config(app):
path_yaml = Path(path_yaml)
if not path_yaml.exists():
raise ValueError(
f"Path to a YAML configuration file was given, but not found: {path_yaml}"
f"Path to a _config.yml file was given, but not found: {path_yaml}"
)

# Load the YAML and update its values to translate it into Sphinx keys
Expand Down
1 change: 0 additions & 1 deletion scripts/clear_doc_outputs.py
@@ -1,5 +1,4 @@
import nbformat as nbf
from subprocess import run
from glob import glob
from nbconvert.exporters import NotebookExporter
from traitlets.config import Config
Expand Down

0 comments on commit 1e366f0

Please sign in to comment.