From: Raymond Hettinger Date: Tue, 3 Jul 2012 21:42:33 +0000 (-0700) Subject: Add examples to the module docstring X-Git-Tag: v3.3.0b2~321 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0712f40308ad48a2d3c3175211c9bde6084f1eae;p=python Add examples to the module docstring --- diff --git a/Tools/scripts/highlight.py b/Tools/scripts/highlight.py index 70da649315..022e02d80b 100755 --- a/Tools/scripts/highlight.py +++ b/Tools/scripts/highlight.py @@ -1,5 +1,21 @@ #!/usr/bin/env python3 -'Add syntax highlighting to Python source code' +'''Add syntax highlighting to Python source code + +Example command-line calls: + + # Show syntax highlighted code in the terminal window + $ ./highlight.py -a myfile.py + + # Colorize myfile.py and display in a browser + $ ./highlight.py -b myfile.py + + # Create an HTML section that can be embedded in an existing webpage + ./highlight.py -s myfile.py + + # Create a complete HTML file + $ ./highlight.py myfile.py > myfile.html + +''' __all__ = ['colorize', 'build_page', 'default_css', 'default_html', 'ansi_colorize', 'default_ansi'] @@ -150,14 +166,14 @@ if __name__ == '__main__': sourcefile = args.sourcefile with open(sourcefile) as f: - page = f.read() + source = f.read() if args.ansi: - encoded = colorize_ansi(page) + encoded = colorize_ansi(source) elif args.section: - encoded = colorize_html(page) + encoded = colorize_html(source) else: - encoded = build_page(page, title=sourcefile) + encoded = build_page(source, title=sourcefile) if args.browser: htmlfile = os.path.splitext(os.path.basename(sourcefile))[0] + '.html'