module ipythonhelper.magic_class_example

Inheritance diagram of pyquickhelper.ipythonhelper.magic_class_example

Short summary

module pyquickhelper.ipythonhelper.magic_class_example

Example of a class which defines magic commands.

source on GitHub

Classes

class

truncated documentation

MagicClassExample

Functions

function

truncated documentation

register_file_magics

Registers magics functions, can be called from a notebook.

Properties

property

truncated documentation

Context

return the context or None

cross_validation_lock

A contextmanager for running a block with our cross validation lock set to True. At the end of the block, …

Static Methods

staticmethod

truncated documentation

htmlhelp_parser

Defines the way to parse the magic command %htmlhelp.

Methods

method

truncated documentation

htmlhelp

Defines %htmlhelp, it displays the help for an object in HTML.

Documentation

Example of a class which defines magic commands.

source on GitHub

class pyquickhelper.ipythonhelper.magic_class_example.MagicClassExample(shell=None, **kwargs)[source][source]

Bases: pyquickhelper.ipythonhelper.magic_class.MagicClassWithHelpers

Define a magic command

This class is an example of how a magic commands can be defined with parameters as if it was a regular command in a terminal. The class MagicClassExample defines magic command htmlhelp and the associated parser. Function load_ipython_extension register the magic command through %load_ext pyquickhelper. The magic command can be unit tested with:

mg = MagicClassExample()
mg.add_context(context={"MagicClassExample": MagicClassExample})
cmd = "MagicClassExample -f text"
res = mg.htmlhelp(cmd)
assert "NB(example of a magic command)"

source on GitHub

_trait_default_generators = {}[source]
htmlhelp(line)[source][source]

Defines %htmlhelp, it displays the help for an object in HTML.

%htmlhelp

Magic command htmlhelp convert docstring (RST) into HTML format for a better display in a notebook. It is equivalent to the code:

from pyquickhelper.helpgen import docstring2html
obj = <function or object>
docstring2html(obj, format="html")

See function docstring2html.

source on GitHub

static htmlhelp_parser()[source][source]

Defines the way to parse the magic command %htmlhelp.

source on GitHub

pyquickhelper.ipythonhelper.magic_class_example.register_file_magics(ip=None)[source][source]

Registers magics functions, can be called from a notebook.

Parameters

ip – from get_ipython()

source on GitHub