argparse を使用して ipython マジックを作成しています。ライブラリは、呼び出し時にいくつかのドキュメントを適切に出力していますparser.print_doc()
。ただし、代わりにドキュメントを文字列として取得して__doc__
、ipython セルに添付できるようにする方法はありますか?
これが私がやりたいことの例です:
@magics_class
class MagicClass(Magics):
parser = argparse.ArgumentParser(description='Some description.')
parser.add_argument('foo', nargs='*', help='Foo variables.')
[…]
def __init__(self):
# attach the doc from the parser to the __doc__ object of the
# class
self.__doc__.append(parser.get_help_as_string())
[…]