diff --git a/spacy/util.py b/spacy/util.py index f481acb5f..39ec8b42c 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -144,7 +144,8 @@ def parse_package_meta(package_path, require=True): def is_in_jupyter(): - """Check if user is in a Jupyter notebook. Mainly used for displaCy. + """Check if user is running spaCy from a Jupyter notebook by detecting the + IPython kernel. Mainly used for the displaCy visualizer. RETURNS (bool): True if in Jupyter, False if not. """ diff --git a/website/docs/api/util.jade b/website/docs/api/util.jade index c0c0e6f3c..078d2a841 100644 --- a/website/docs/api/util.jade +++ b/website/docs/api/util.jade @@ -167,6 +167,26 @@ p +cell dict / #[code None] +cell Model meta data or #[code None]. ++h(2, "is_in_jupyter") util.is_in_jupyter + +tag function + +p + | Check if user is running spaCy from a #[+a("https://jupyter.org") Jupyter] + | notebook by detecting the IPython kernel. Mainly used for the + | #[+api("displacy") #[code displacy]] visualizer. + ++aside-code("Example"). + html = '<h1>Hello world!</h1>' + if util.is_in_jupyter(): + from IPython.core.display import display, HTML + return display(HTML(html)) + ++table(["Name", "Type", "Description"]) + +footrow + +cell returns + +cell bool + +cell #[code True] if in Jupyter, #[code False] if not. + +h(2, "update_exc") util.update_exc +tag function