##// END OF EJS Templates
add __main__ entry to demo.py module
Moez Bouhlel -
Show More
@@ -627,3 +627,43 b' class ClearDemo(ClearMixin,Demo):'
627
627
628 class ClearIPDemo(ClearMixin,IPythonDemo):
628 class ClearIPDemo(ClearMixin,IPythonDemo):
629 pass
629 pass
630
631
632 def slide(file_path, noclear=False, format_rst=True, formatter="terminal",
633 style="native", auto_all=False, delimiter='...'):
634 if noclear:
635 demo_class = Demo
636 else:
637 demo_class = ClearDemo
638 demo = demo_class(file_path, format_rst=format_rst, formatter=formatter,
639 style=style, auto_all=auto_all)
640 while not demo.finished:
641 demo()
642 try:
643 py3compat.input('\n' + delimiter)
644 except KeyboardInterrupt:
645 exit(1)
646
647 if __name__ == '__main__':
648 import argparse
649 parser = argparse.ArgumentParser(description='Run python demos')
650 parser.add_argument('--noclear', '-C', action='store_true',
651 help='Do not clear terminal on each slide')
652 parser.add_argument('--rst', '-r', action='store_true',
653 help='Highlight comments and dostrings as rst')
654 parser.add_argument('--formatter', '-f', default='terminal',
655 help='pygments formatter name could be: terminal, '
656 'terminal256, terminal16m')
657 parser.add_argument('--style', '-s', default='default',
658 help='pygments style name')
659 parser.add_argument('--auto', '-a', action='store_true',
660 help='Run all blocks automatically without'
661 'confirmation')
662 parser.add_argument('--delimiter', '-d', default='...',
663 help='slides delimiter added after each slide run')
664 parser.add_argument('file', nargs=1,
665 help='python demo file')
666 args = parser.parse_args()
667 slide(args.file[0], noclear=args.noclear, format_rst=args.rst,
668 formatter=args.formatter, style=args.style, auto_all=args.auto,
669 delimiter=args.delimiter)
General Comments 0
You need to be logged in to leave comments. Login now