-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix docstring issue and a broken link #1576
Changes from all commits
5f69259
d414f73
b7ab8fc
6d339a9
d1e79bd
d46fc95
78e07ea
5dffe96
ed3ef14
21a899f
90e9dc7
b0a1e82
cfb0d5e
24dfd99
482d408
ce9641b
94991f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,16 @@ Architecture of nbconvert | |
========================= | ||
|
||
This is a high-level outline of the basic workflow, structures and objects in nbconvert. | ||
Specifically, this exposition has a two-fold goal: | ||
#. to alert you to the affordances available for customisation or direct contributions | ||
Specifically, this exposition has a two-fold goal: | ||
|
||
#. to alert you to the affordances available for customisation or direct contributions | ||
#. to provide a map of where and when different events occur, which should aid in tracking down bugs. | ||
|
||
|
||
A detailed pipeline exploration | ||
=============================== | ||
|
||
Nbconvert takes in a notebook, which is a JSON object, and operates on that object. | ||
Nbconvert takes in a notebook, which is a JSON object, and operates on that object. | ||
|
||
This can include operations that take a notebook and return a notebook. | ||
For example, that operation could be to execute the notebook as though it were a continuous script; if it were executed ``--in-place`` then it would overwrite the current notebook. | ||
|
@@ -36,21 +36,21 @@ Markdown cells and raw NbConvert cells do not have analogous substructure. | |
|
||
The template's structure then can be seen as a mechanism for selecting content on which to operate. | ||
Because the template operates on individual cells, this has some upsides and drawbacks. | ||
One upside is that this allows the template to have access to the individual cell's metadata, which enables intelligently transforming the appropriate content. | ||
The transformations occur as a series of replacement rules and filters. | ||
One upside is that this allows the template to have access to the individual cell's metadata, which enables intelligently transforming the appropriate content. | ||
The transformations occur as a series of replacement rules and filters. | ||
For many purposes these filters take the form of external calls to `pandoc`_, which is a utility for converting between many different document formats. | ||
One downside is that this makes operations that require global coördination (e.g., cross referencing across cells) somewhat challenging to implement as filters inside templates. | ||
|
||
Note that all that we've described is happening in memory. | ||
Note that all that we've described is happening in memory. | ||
This is crucial in order to ensure that this functionality is available when writing files is more challenging. | ||
Nonetheless, the reason for using nbconvert almost always involves producing some kind of output file. | ||
We take the in-memory object and write a file appropriate for the output type. | ||
|
||
The entirety of heretofore described process can be described as part of an ``Exporter``. | ||
``Exporter``\s often involves ``Preprocessor``\s, ``filters``, ``templates`` and ``Writer``\s. | ||
The entirety of heretofore described process can be described as part of an ``Exporter``. | ||
``Exporter``\s often involves ``Preprocessor``\s, ``filters``, ``templates`` and ``Writer``\s. | ||
These classes and functions are described in greater detail below. | ||
|
||
Finally, one can apply a ``Postprocessor`` after the writing has occurred. | ||
Finally, one can apply a ``Postprocessor`` after the writing has occurred. | ||
For example, it is common when converting to slides to start a webserver and open a browser window with the newly created document (``--to slides --post serve``). | ||
|
||
Classes | ||
|
@@ -61,7 +61,7 @@ Classes | |
Exporters | ||
--------- | ||
|
||
The primary class in nbconvert is the `Exporter`. | ||
The primary class in nbconvert is the ``nbconvert.exporters.exporter.Exporter``. | ||
Exporters encapsulate the operation of turning a notebook into another format. | ||
There is one Exporter for each format supported in nbconvert. | ||
The first thing an Exporter does is load a notebook, usually from a file via :mod:`nbformat`. | ||
|
@@ -80,7 +80,7 @@ Once the notebook is loaded, it is preprocessed... | |
Preprocessors | ||
------------- | ||
|
||
A `Preprocessor` is an object that transforms the content of the notebook to be exported. | ||
A ``nbconvert.preprocessors.Preprocessor`` is an object that transforms the content of the notebook to be exported. | ||
The result of a preprocessor being applied to a notebook is always a notebook. | ||
These operations include re-executing the cells, stripping output, | ||
removing bundled outputs to separate files, etc. | ||
|
@@ -99,7 +99,7 @@ Once a notebook is preprocessed, it's time to convert the notebook into the dest | |
Templates | ||
--------- | ||
|
||
Most Exporters in nbconvert are a subclass of `TemplateExporter`, which make use of | ||
Most Exporters in nbconvert are a subclass of ``nbconvert.exporters.templateexporter.TemplateExporter``, which make use of | ||
`jinja`_ to render a notebook into the destination format. | ||
|
||
Nbconvert templates can be selected from the command line with the ``--template`` | ||
|
@@ -151,7 +151,7 @@ Configurable classes. | |
.. seealso:: | ||
|
||
- :doc:`customizing` | ||
- :ref:`jinja:filters` | ||
- `More on Jinja Filters`_ | ||
|
||
Once it has passed through the template, an Exporter is done with the notebook, | ||
and returns the file data. | ||
|
@@ -180,12 +180,12 @@ Postprocessors | |
-------------- | ||
|
||
A *Postprocessor* is something that runs after everything is exported and written to the filesystem. | ||
The only postprocessor in nbconvert at this point is the `ServePostProcessor`, | ||
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: http://jinja.pocoo.org/ | ||
.. _filter: http://jinja.pocoo.org/docs/dev/templates/#filters | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm still seems to be complaining about pocoo.org fetches -- maybe the line before or somewhere else in the project we're fetching objects that don't exist anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes @MSeal ! i'm really confused about the CI issue. Here is what i know. that url - jinja.pocoo.org/docs resolves to https://jinja.palletsprojects.com/en/3.0.x/ i've definitely seen builds have a hard time with redirects. i just fixed that but i'm still seeing that CI issue. i suspect somewhere there are other pocoo.org references perhaps? i can search for that next. http://jinja.pocoo.org/docs/dev/objects.inv i think i fixed it. the link for intersphinx_mapping was the old url. give me a few minutes to push it up. fingers crossed :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed this URL to be the new jinja docs link. palletsprojects.com |
||
.. _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 | ||
.. _pandoc: https://pandoc.org/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,13 +203,13 @@ def register_preprocessor(self, preprocessor, enabled=False): | |
""" | ||
Register a preprocessor. | ||
Preprocessors are classes that act upon the notebook before it is | ||
passed into the Jinja templating engine. preprocessors are also | ||
passed into the Jinja templating engine. Preprocessors are also | ||
capable of passing additional information to the Jinja | ||
templating engine. | ||
|
||
Parameters | ||
---------- | ||
preprocessor : `Preprocessor` | ||
preprocessor : `nbconvert.preprocessors.Preprocessor` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i am not sure if this is the correct preprocessor object. It is either this or |
||
A dotted module name, a type, or an instance | ||
enabled : bool | ||
Mark the preprocessor as enabled | ||
|
@@ -316,7 +316,7 @@ def _preprocess(self, nb, resources): | |
# to each preprocessor | ||
for preprocessor in self._preprocessors: | ||
nbc, resc = preprocessor(nbc, resc) | ||
try: | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my text editor Atom must do something with spaces. i hope this isn't problematic. if it is i can try to fix it. |
||
nbformat.validate(nbc, relax_add_props=True) | ||
except nbformat.ValidationError: | ||
self.log.error('Notebook is invalid after preprocessor %s', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated link. this used
:ref:
before which is a local page link. I also fixed the URL to the jinja template page