0

I am using argparse to create an ipython magic. The library is nicely printing some documentation when calling parser.print_doc(). However, is there a way to get the documentation as a string instead, so that I can attach it to __doc__ of my ipython cell?

Here is an example of what I want to do:

@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())
        […]

1 Answer 1

1

I think you're looking for the format_help() method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.