Skip to content

Commit

Permalink
Adopt sp-repo-review (#2040)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Sep 19, 2023
1 parent 6d2410f commit b94664d
Show file tree
Hide file tree
Showing 143 changed files with 534 additions and 305 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ ______________________________________________________________________

<!--- Describe the solution you'd like. --->

<!--- If possible, describe alternatives you've considered. Why are they insufficent? --->
<!--- If possible, describe alternatives you've considered. Why are they insufficient? --->
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
python-version: "3.9"
- os: "ubuntu-20.04"
python-version: "3.10"
- os: "ubuntu-20.04"
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -79,8 +80,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Run Linters
run: |
- name: Run Linters
run: |
hatch run typing:test
hatch run lint:style
pipx run interrogate -v .
Expand All @@ -106,7 +107,7 @@ jobs:
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
with:
ignore_links: 'https://ipywidgets.readthedocs.io/en/latest/examples/Output'
ignore_links: "https://ipywidgets.readthedocs.io/en/latest/examples/Output"

test_minimum_versions:
name: Test Minimum Versions
Expand All @@ -118,7 +119,6 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
dependency_type: minimum
only_create_file: 1
- name: Install dependencies
run: |
sudo apt-get update
Expand All @@ -140,7 +140,7 @@ jobs:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
dependency_type: pre
dependency_type: pre
- name: Run the tests
run: |
export NBFORMAT_VALIDATOR=jsonschema
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ docs/source/interactive/magics-generated.txt
docs/gh-pages
docs/source/CHANGELOG.md
nbconvert/resources/style.min.css
nbconvert/tests/files/*.html
tests/files/*.html
*.py[co]
__pycache__
*.egg-info
Expand Down
37 changes: 35 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ci:
autoupdate_schedule: monthly
autoupdate_commit_msg: "chore: update pre-commit hooks"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -15,6 +16,7 @@ repos:
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace

Expand All @@ -30,13 +32,44 @@ repos:
additional_dependencies:
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]

- repo: https://github.com/psf/black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.2"
hooks:
- id: prettier
types_or: [yaml, html, json]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.5"
hooks:
- id: codespell
args: ["-L", "sur,nd"]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff
args: ["--fix"]
args: ["--fix", "--show-fixes"]

- repo: https://github.com/scientific-python/cookie
rev: "2023.08.23"
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nbconvert/tests/files/*.html
tests/files/*.html
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ python:
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.11"
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@
[#1761](https://github.com/jupyter/nbconvert/pull/1761)
- WebPDFExporter: Emulate media print by @martinRenou in
[#1791](https://github.com/jupyter/nbconvert/pull/1791)
- Fix fonts overriden by user stylesheet by inheriting styles by
- Fix fonts overridden by user stylesheet by inheriting styles by
@dakoop in [#1793](https://github.com/jupyter/nbconvert/pull/1793)
- Fix lab template output alignment by @dakoop in
[#1795](https://github.com/jupyter/nbconvert/pull/1795)
Expand Down Expand Up @@ -628,7 +628,7 @@ The following 31 authors contributed 81 commits.

## 6.0.7

Primarly a release addressing template extensions issues reported since
Primarily a release addressing template extensions issues reported since
6.0 launched.

### Comprehensive notes
Expand Down Expand Up @@ -1182,7 +1182,7 @@ Thanks to the following 11 authors who contributed 57 commits.
#### Fixing Problems

- Mathjax.tpl fix for rendering Latex in html [#932](https://github.com/jupyter/nbconvert/pull/932)
- Backwards compatbility for empty kernel names
- Backwards compatibility for empty kernel names
[#927](https://github.com/jupyter/nbconvert/pull/927) [#924](https://github.com/jupyter/nbconvert/pull/924)

#### Testing, Docs, and Builds
Expand Down Expand Up @@ -1282,6 +1282,8 @@ class AttrExporter(TemplateExporter):
raw template
{%- endblock in_prompt -%}
"""


exporter_attr = AttrExporter()
output_attr, _ = exporter_attr.from_notebook_node(nb)
assert "raw template" in output_attr
Expand Down Expand Up @@ -1623,7 +1625,7 @@ Many thanks to the following individuals who contributed to this release
- doc improvements [#489](https://github.com/jupyter/nbconvert/pull/489)
[#500](https://github.com/jupyter/nbconvert/pull/500) [#493](https://github.com/jupyter/nbconvert/pull/493) [#506](https://github.com/jupyter/nbconvert/pull/506)
- newly customizable: output prompt [#500](https://github.com/jupyter/nbconvert/pull/500)
- more python2/3 compatibile unicode handling [#502](https://github.com/jupyter/nbconvert/pull/502)
- more python2/3 compatible unicode handling [#502](https://github.com/jupyter/nbconvert/pull/502)

## 5.0

Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The recommended way to make a release is to use [`jupyter_releaser`](https://git

- Run the ["Step 1: Prep Release"](https://github.com/jupyter/nbconvert/actions/workflows/prep-release.yml) workflow with the appropriate inputs.
- You can usually use the following values for the workflow:
- branch : 'main' when releasing fro teh main branch
- branch : 'main' when releasing from the main branch
- "Post Version Specifier" empty unless you do a beta or rc release
- keep `since_last_stable` unchecked
- "Use PRs with activity since this date or git reference"
Expand Down
4 changes: 2 additions & 2 deletions docs/autogen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
.. code-block:: python
c.TemplateExporter.exclude_input_prompt = False # The default
c.TemplateExporter.exclude_input_prompt = False # The default
c.PDFExporter.exclude_input_prompt = True
input prompts will not appear when converting to PDF, but they will appear when
Expand All @@ -41,7 +41,7 @@
to be loaded regardless of the value of their ``enabled`` attribute.
When using Nbconvert from the command line, a number of aliases and flags are
defined as shortcuts to configuration options for convience.
defined as shortcuts to configuration options for convenience.
"""

Expand Down
4 changes: 2 additions & 2 deletions docs/source/api/exporters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ Exporter base classes
Specialized exporter classes
----------------------------

The `NotebookExporter` inherits directly from
The ``NotebookExporter`` inherits directly from
``Exporter``, while the other exporters listed here
inherit either directly or indirectly from
`TemplateExporter`.
``TemplateExporter``.

.. autoclass:: NotebookExporter

Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Filters
Filters are for use with the ``nbconvert.exporters.templateexporter.TemplateExporter`` exporter.
They provide a way for you transform notebook contents to a particular format depending
on the template you are using. For example, when converting to HTML, you would want to
use the `ansi2html()` function to convert ANSI colors (from
use the ``ansi2html()`` function to convert ANSI colors (from
e.g. a terminal traceback) to HTML colors.

.. seealso::
Expand Down
2 changes: 0 additions & 2 deletions docs/source/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ A *Postprocessor* is something that runs after everything is exported and writte
The only postprocessor in nbconvert at this point is the ``nbconvert.postprocessors.serve.ServePostProcessor``,
which is used for serving `reveal.js`_ HTML slideshows.

.. links:
.. _jinja: https://jinja.palletsprojects.com/en/3.0.x/
.. _More on Jinja Filters: https://jinja.palletsprojects.com/en/3.0.x/templates/#filters
.. _reveal.js: http://lab.hakim.se/reveal-js
Expand Down
8 changes: 4 additions & 4 deletions docs/source/customizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ template, exports text/html, and enables two preprocessors called "100-pygments"
Inheritance
~~~~~~~~~~~

Nbconvert walks up the inheritance structure determined by ``conf.json`` and produces an agregated
Nbconvert walks up the inheritance structure determined by ``conf.json`` and produces an aggregated
configuration, merging the dictionaries of registered preprocessors.
The lexical ordering of the preprocessors by name determines the order in which they will be run.

Besides the ``conf.json`` file, nbconvert templates most typically include jinja templates files,
although any other resource from the base template can be overriden in the derived template.
although any other resource from the base template can be overridden in the derived template.

For example, inspecting the content of the ``classic`` template located in
``share/jupyter/nbconvert/templates/classic``, we find the following content:
Expand All @@ -133,13 +133,13 @@ for HTML exporters) as well as CSS and a base template file in ``base.html.j2``.
Inheritance in Jinja
~~~~~~~~~~~~~~~~~~~~

In nbconvert, jinja templates can inherrit from any other jinja template available in its current directory
In nbconvert, jinja templates can inherit from any other jinja template available in its current directory
or base template directory by name. Jinja templates of other directories can be addressed by their relative path
from the Jupyter data directory.

For example, in the reveal template, ``index.html.j2`` extends ``base.html.j2`` which is in the same directory, and
``base.html.j2`` extends ``lab/base.html.j2``. This approach allows using content that is available in other templates
or may be overriden in the current template.
or may be overridden in the current template.

A practical example
~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/source/dejavu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Dejavu works exactly the same as nbconvert and you can use all command line opti

jupyter dejavu notebook.ipynb

In case you want to show code in adition to its output use the flag ``--show-input``.
In case you want to show code in addition to its output use the flag ``--show-input``.


Configuring the Notebook for slides presentations
Expand Down
4 changes: 2 additions & 2 deletions docs/source/execute_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Example
Let's start with a complete quick example, leaving detailed explanations
to the following sections.

**Import**: First we import nbconvert and the `ExecutePreprocessor`
**Import**: First we import nbconvert and the ``ExecutePreprocessor``
class::

import nbformat
Expand Down Expand Up @@ -78,7 +78,7 @@ in the file ``executed_notebook.ipynb``.
Execution arguments (traitlets)
-------------------------------

The arguments passed to `ExecutePreprocessor` are configuration options
The arguments passed to ``ExecutePreprocessor`` are configuration options
called `traitlets <https://traitlets.readthedocs.io/en/stable>`_.
There are many cool things about traitlets. For example,
they enforce the input type, and they can be accessed/modified as
Expand Down
23 changes: 13 additions & 10 deletions docs/source/external_exporters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ example, your package may contain two custom exporters, named "simple" and
.. sourcecode:: python

setup(
...
entry_points = {
'nbconvert.exporters': [
'simple = mymodule:SimpleExporter',
'detail = mymodule:DetailExporter',
# ...
entry_points={
"nbconvert.exporters": [
"simple = mymodule:SimpleExporter",
"detail = mymodule:DetailExporter",
],
}
)
Expand Down Expand Up @@ -167,9 +167,10 @@ We are going to write an exporter that:
from traitlets.config import Config
from nbconvert.exporters.html import HTMLExporter
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
class MyExporter(HTMLExporter):
"""
Expand All @@ -185,7 +186,7 @@ We are going to write an exporter that:
"""
The new file extension is ``.test_ext``
"""
return '.test_ext'
return ".test_ext"
@property
def template_paths(self):
Expand All @@ -195,13 +196,15 @@ We are going to write an exporter that:
Note: nbconvert 6.0 changed ``template_path`` to ``template_paths``
"""
return super().template_paths+[os.path.join(os.path.dirname(__file__), "templates")]
return super().template_paths + [
os.path.join(os.path.dirname(__file__), "templates")
]
def _template_file_default(self):
"""
We want to use the new template we ship with our library.
"""
return 'test_template' # full
return "test_template" # full
And the template file, that inherits from the html ``full`` template and prepend/append text to each markdown cell (see Jinja2 docs for template syntax)::
Expand Down
1 change: 1 addition & 0 deletions docs/source/highlighting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ from a terminal or
.. code-block:: python
from pygments.styles import get_all_styles
print(list(get_all_styles()))
from python.
Expand Down
Loading

0 comments on commit b94664d

Please sign in to comment.