clean notebook processing
@@ -25,9 +25,8 @@ setup_cfg = dict(conf.items("metadata"))
build_docs_cfg = dict(conf.items("build_docs"))
DOWN_NBS = build_docs_cfg["downloadable-notebooks"]
PATH_NBS = Path(build_docs_cfg["source-dir"]) / DOWN_NBS
-GITHUB_TUTOS_URL = "https://github.com/gammapy/gammapy/tree/master/docs/tutorials"
-BINDER_BADGE_URL = "https://static.mybinder.org/badge.svg"
BINDER_URL = "https://mybinder.org/v2/gh/gammapy/gammapy-webpage"
+BINDER_BADGE = "https://static.mybinder.org/badge.svg"
def copy_clean_notebook(nb_path):
@@ -64,44 +63,31 @@ def add_box(nb_path):
start_link = level_depth * "../"
nb_filename = nb_path.absolute().name
py_filename = nb_filename.replace("ipynb", "py")
- release_number_binder = f"v{__version__}"
- release_number_download = __version__
- BINDER_LINK = f"- Try online[![Binder]({BINDER_BADGE_URL})]({BINDER_URL} " \
- f"/ {release_number_binder}?urlpath=lab / tree{path_tail})"
+ release_number = __version__
+ BINDER_LINK = f"- Try online[![Binder]({BINDER_BADGE})]({BINDER_URL}/v{__version__}?urlpath=lab/tree{path_tail})"
if "dev" in __version__:
BINDER_LINK = ""
- release_number_download = "dev"
-
- ctx = dict(
- path_tail=path_tail,
- nb_filename=nb_filename,
- py_filename=py_filename,
- release_number_download=release_number_download,
- BINDER_LINK=BINDER_LINK,
- DOWN_NBS=DOWN_NBS,
- GITHUB_TUTOS_URL=GITHUB_TUTOS_URL,
- start_link=start_link,
- )
+ release_number = "dev"
- DOWNLOAD_CELL = f"""
+ BOX_CELL = f"""
<div class="alert alert-info">
**This is a fixed-text formatted version of a Jupyter notebook**
{BINDER_LINK}
-- You may download all the notebooks in the documentation as a [tar file]({start_link}_downloads/notebooks-{release_number_download}.tar).
+- You may download all the notebooks in the documentation as a
+[tar file]({start_link}_downloads/notebooks-{release_number}.tar).
- **Source files:**
[{nb_filename}]({start_link}{DOWN_NBS}/{nb_filename}) |
[{py_filename}]({start_link}{DOWN_NBS}/{py_filename})
</div>
"""
- strcell = DOWNLOAD_CELL.format(**ctx)
rawnb = nbformat.read(nb_path, as_version=nbformat.NO_CONVERT)
if "nbsphinx" not in rawnb.metadata:
rawnb.metadata["nbsphinx"] = {"orphan": bool("true")}
- rawnb.cells.insert(0, new_markdown_cell(strcell))
+ rawnb.cells.insert(0, new_markdown_cell(BOX_CELL))
# add latex format
for cell in rawnb.cells:
