Skip to content

Commit 4ea67a6

Browse files
authored
Add Binder, simplify hook (#2)
1 parent 21b0a76 commit 4ea67a6

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# ipython-markdown-inspector
22

3-
[![tests](https://github.com/krassowski/ipython-markdown-inspector/workflows/tests/badge.svg)](https://github.com/krassowski/ipython-markdown-inspector/actions?query=workflow%3A%22tests%22)
3+
[![tests](https://github.com/krassowski/ipython-markdown-inspector/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/krassowski/ipython-markdown-inspector/actions/workflows/tests.yml)
44
![CodeQL](https://github.com/krassowski/ipython-markdown-inspector/workflows/CodeQL/badge.svg)
5+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/krassowski/ipython-markdown-inspector/main?urlpath=lab)
56
[![pypi-version](https://img.shields.io/pypi/v/ipython-markdown-inspector.svg)](https://python.org/pypi/ipython-markdown-inspector)
67

78
IPython extension providing inspection results as Markdown, enabling better integration with Jupyter Notebook and JupyterLab.

Diff for: binder/environment.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: ipython-markdown-inspector
2+
3+
channels:
4+
- conda-forge
5+
- nodefaults
6+
7+
dependencies:
8+
- python =3.10
9+
- pip
10+
- jupyterlab >=4.1
11+
- hatchling >=1.5.0
12+
- ipykernel >=6.29
13+
- notebook >=7.1
14+
- jupyter_server >=2.12
15+
- wheel
16+
- build
17+
- ipython >=8.22
18+
- traitlets >=5.14.1

Diff for: binder/ipython_config.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c.InteractiveShellApp.extensions = ["ipython_markdown_inspector"] # noqa: F821

Diff for: binder/postBuild

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
source activate ${NB_PYTHON_PREFIX}
4+
5+
pip install -v -e . --no-build-isolation
6+
7+
mkdir -p ~/.ipython/profile_default/
8+
cp binder/ipython_config.py ~/.ipython/profile_default/

Diff for: ipython_markdown_inspector/__init__.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1-
from functools import partial
21
from typing import List
32

43
from IPython.core.interactiveshell import InteractiveShell
5-
from IPython.core.oinspect import InspectorHookData
64

75
from .formatter import as_markdown
86

97

10-
def hook(
11-
data: InspectorHookData,
12-
*_,
13-
ipython: InteractiveShell,
14-
) -> str:
15-
return as_markdown(data)
16-
17-
188
ORIGINAL_HOOK = None
199

2010

2111
def load_ipython_extension(ipython: InteractiveShell):
2212
global ORIGINAL_HOOK
2313
ORIGINAL_HOOK = ipython.inspector.mime_hooks.get("text/markdown", None)
24-
ipython.inspector.mime_hooks["text/markdown"] = partial(hook, ipython=ipython)
14+
ipython.inspector.mime_hooks["text/markdown"] = as_markdown
2515

2616

2717
def unload_ipython_extension(ipython: InteractiveShell):

0 commit comments

Comments
 (0)