paulb@57 | 1 | #!/usr/bin/env python |
paulb@57 | 2 | |
paulb@57 | 3 | import sys, os |
paulb@57 | 4 | import simplify |
paulb@31 | 5 | import fixnames |
paulb@57 | 6 | import viewer |
paulb@67 | 7 | from annotate import AnnotationError, annotate_all as aa |
paulb@19 | 8 | |
paulb@57 | 9 | builtins = simplify.simplify(os.path.join("lib", "builtins.py"), 1) |
paulb@57 | 10 | module = simplify.simplify(sys.argv[1]) |
paulb@57 | 11 | fixnames.fix(builtins) |
paulb@57 | 12 | fixnames.fix(module, builtins) |
paulb@57 | 13 | |
paulb@62 | 14 | stream = sys.stdout |
paulb@62 | 15 | v = viewer.Viewer(stream) |
paulb@62 | 16 | |
paulb@62 | 17 | if "-a" in sys.argv: |
paulb@62 | 18 | try: |
paulb@62 | 19 | aa([module], builtins) |
paulb@67 | 20 | except AnnotationError, exc: |
paulb@62 | 21 | v.report(exc) |
paulb@62 | 22 | |
paulb@90 | 23 | if "-d" in sys.argv: |
paulb@96 | 24 | try: |
paulb@96 | 25 | dirname = "%s-docs" % module.name |
paulb@96 | 26 | if not os.path.exists(dirname): |
paulb@96 | 27 | os.mkdir(dirname) |
paulb@96 | 28 | viewer.makedoc(module, os.path.join(dirname, "%s%shtml" % (module.name, os.path.extsep))) |
paulb@96 | 29 | viewer.makedoc(builtins, os.path.join(dirname, "%s%shtml" % (builtins.name, os.path.extsep))) |
paulb@96 | 30 | except viewer.ViewerError, exc: |
paulb@96 | 31 | raise |
paulb@90 | 32 | |
paulb@57 | 33 | # vim: tabstop=4 expandtab shiftwidth=4 |