Generate documentation for one Python package in some format. 'pathOrName' can be either a filesystem path leading to a Python package or package name whose path will be resolved by importing the top-level module. The doc file will always be saved in the current directory with
(pathOrName, builder, opts={})
| 1163 | |
| 1164 | |
| 1165 | def documentPackage0(pathOrName, builder, opts={}): |
| 1166 | """Generate documentation for one Python package in some format. |
| 1167 | |
| 1168 | 'pathOrName' can be either a filesystem path leading to a Python |
| 1169 | package or package name whose path will be resolved by importing |
| 1170 | the top-level module. |
| 1171 | |
| 1172 | The doc file will always be saved in the current directory with |
| 1173 | a basename equal to that of the package, e.g. reportlab.lib. |
| 1174 | """ |
| 1175 | |
| 1176 | # Did we get a package path with OS-dependant seperators...? |
| 1177 | if os.sep in pathOrName: |
| 1178 | path = pathOrName |
| 1179 | name = os.path.splitext(os.path.basename(path))[0] |
| 1180 | # ... or rather a package name? |
| 1181 | else: |
| 1182 | name = pathOrName |
| 1183 | package = __import__(name) |
| 1184 | # Some special care needed for dotted names. |
| 1185 | if '.' in name: |
| 1186 | subname = 'package' + name[find(name, '.'):] |
| 1187 | package = eval(subname) |
| 1188 | path = os.path.dirname(package.__file__) |
| 1189 | |
| 1190 | cwd = os.getcwd() |
| 1191 | builder.beginPackage(name) |
| 1192 | os.path.walk(path, _packageWalkCallback, (builder, opts)) |
| 1193 | builder.endPackage(name) |
| 1194 | os.chdir(cwd) |
| 1195 | |
| 1196 | |
| 1197 | def main(): |
no test coverage detected