docs, standard-tests: how to standard test a custom tool, imports (#27931)

This commit is contained in:
Erick Friis
2024-11-15 10:49:14 -08:00
committed by GitHub
parent 39fcb476fd
commit 409c7946ac
5 changed files with 267 additions and 8 deletions

View File

@@ -24,6 +24,16 @@ class EscapePreprocessor(Preprocessor):
# escape ``` in code
cell.source = cell.source.replace("```", r"\`\`\`")
# escape ``` in output
# allow overriding title based on comment at beginning of cell
if cell.source.startswith("# title="):
lines = cell.source.split("\n")
title = lines[0].split("# title=")[1]
if title.startswith('"') and title.endswith('"'):
title = title[1:-1]
cell.metadata["title"] = title
cell.source = "\n".join(lines[1:])
if "outputs" in cell:
filter_out = set()
for i, output in enumerate(cell["outputs"]):

View File

@@ -1,5 +1,20 @@
{% extends 'markdown/index.md.j2' %}
{% block input %}
```
{%- if 'magics_language' in cell.metadata -%}
{{ cell.metadata.magics_language}}
{%- elif 'name' in nb.metadata.get('language_info', {}) -%}
{{ nb.metadata.language_info.name }}
{%- endif %}
{%- if 'title' in cell.metadata -%}
{{ ' ' }}title="{{ cell.metadata.title }}"
{%- endif %}
{{ cell.source}}
```
{% endblock input %}
{%- block traceback_line -%}
```output
{{ line.rstrip() | strip_ansi }}