Generate documentation for one Python file in some format. This handles Python standard modules like string, custom modules on the Python search path like e.g. docpy as well as modules specified with their full path like C:/tmp/junk.py. The doc file will always be saved in the curr
(pathOrName, builder, opts={})
| 796 | # the same as in docpy.py (except for some defaults). |
| 797 | |
| 798 | def documentModule0(pathOrName, builder, opts={}): |
| 799 | """Generate documentation for one Python file in some format. |
| 800 | |
| 801 | This handles Python standard modules like string, custom modules |
| 802 | on the Python search path like e.g. docpy as well as modules |
| 803 | specified with their full path like C:/tmp/junk.py. |
| 804 | |
| 805 | The doc file will always be saved in the current directory with |
| 806 | a basename equal to that of the module, e.g. docpy. |
| 807 | """ |
| 808 | cwd = os.getcwd() |
| 809 | |
| 810 | # Append directory to Python search path if we get one. |
| 811 | dirName = os.path.dirname(pathOrName) |
| 812 | if dirName: |
| 813 | sys.path.append(dirName) |
| 814 | |
| 815 | # Remove .py extension from module name. |
| 816 | if pathOrName[-3:] == '.py': |
| 817 | modname = pathOrName[:-3] |
| 818 | else: |
| 819 | modname = pathOrName |
| 820 | |
| 821 | # Remove directory paths from module name. |
| 822 | if dirName: |
| 823 | modname = os.path.basename(modname) |
| 824 | |
| 825 | # Load the module. |
| 826 | try: |
| 827 | module = __import__(modname) |
| 828 | except: |
| 829 | print 'Failed to import %s.' % modname |
| 830 | os.chdir(cwd) |
| 831 | return |
| 832 | |
| 833 | # Do the real documentation work. |
| 834 | s = ModuleSkeleton0() |
| 835 | s.inspect(module) |
| 836 | builder.write(s) |
| 837 | |
| 838 | # Remove appended directory from Python search path if we got one. |
| 839 | if dirName: |
| 840 | del sys.path[-1] |
| 841 | |
| 842 | os.chdir(cwd) |
| 843 | |
| 844 | |
| 845 | def _packageWalkCallback((builder, opts), dirPath, files): |
no test coverage detected