module ipythonhelper.magic_class_example
¶
Short summary¶
module pyquickhelper.ipythonhelper.magic_class_example
Example of a class which defines magic commands.
Classes¶
class |
truncated documentation |
---|---|
Functions¶
function |
truncated documentation |
---|---|
Registers magics functions, can be called from a notebook. |
Properties¶
property |
truncated documentation |
---|---|
|
return the context or None |
|
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 |
---|---|
Defines the way to parse the magic command |
Methods¶
method |
truncated documentation |
---|---|
Defines |
Documentation¶
Example of a class which defines magic commands.
-
class
pyquickhelper.ipythonhelper.magic_class_example.
MagicClassExample
(**kwargs)[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 commandhtmlhelp
and the associated parser. Functionload_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)"
Create a configurable given a config config.
- configConfig
If this is empty, default values are used. If config is a
Config
instance, it will be used to configure the instance.- parentConfigurable instance, optional
The parent Configurable instance of this object.
Subclasses of Configurable must call the
__init__()
method ofConfigurable
before doing anything else and usingsuper()
:class MyConfigurable(Configurable): def __init__(self, config=None): super(MyConfigurable, self).__init__(config=config) # Then any other code you need to finish initialization.
This ensures that instances will be configured properly.
-
htmlhelp
(line)[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
.