'Expose a standalone function as magic function for IPython.
This will create an IPython magic (line, cell or both) from a
standalone function.  The functions should have the following
signatures:
* For line magics: `def f(line)`
* For cell magics: `def f(line, cell)`
* For a function that does both: `def f(line, cell=None)`
In the latter case, the function will be called with `cell==None` when
invoked as `%f`, and with cell as a string when invoked as `%%f`.
Parameters
func : callable
Function to be registered as a magic.
magic_kind : str
Kind of magic, one of \'line\', \'cell\' or \'line_cell\'
magic_name : optional str
If given, the name the magic will have in the IPython namespace.  By
default, the name of the function itself is used.'

def register_function(self, func, magic_kind='line', magic_name=None):

    validate_type(magic_kind)
    magic_name = (func.__name__ if (magic_name is None) else magic_name)
    setattr(self.user_magics, magic_name, func)
    record_magic(self.magics, magic_kind, magic_name, func)
