Parse and check the command line arguments.
(argv=sys.argv)
| 192 | |
| 193 | |
| 194 | def main2(argv=sys.argv): |
| 195 | """ |
| 196 | Parse and check the command line arguments. |
| 197 | """ |
| 198 | parser = optparse.OptionParser( |
| 199 | usage="""\ |
| 200 | usage: %prog [options] -o <output_path> <module_path> [exclude_paths, ...] |
| 201 | |
| 202 | Look recursively in <module_path> for Python modules and packages and create |
| 203 | one reST file with automodule directives per package in the <output_path>. |
| 204 | |
| 205 | Note: By default this script will not overwrite already created files.""") |
| 206 | |
| 207 | parser.add_option('-o', '--output-dir', action='store', dest='destdir', |
| 208 | help='Directory to place all output', default='') |
| 209 | parser.add_option('-d', '--maxdepth', action='store', dest='maxdepth', |
| 210 | help='Maximum depth of submodules to show in the TOC ' |
| 211 | '(default: 4)', type='int', default=4) |
| 212 | parser.add_option('-f', '--force', action='store_true', dest='force', |
| 213 | help='Overwrite all files') |
| 214 | parser.add_option('-n', '--dry-run', action='store_true', dest='dryrun', |
| 215 | help='Run the script without creating files') |
| 216 | parser.add_option('-T', '--no-toc', action='store_true', dest='notoc', |
| 217 | help='Don\'t create a table of contents file') |
| 218 | parser.add_option('-s', '--suffix', action='store', dest='suffix', |
| 219 | help='file suffix (default: rst)', default='rst') |
| 220 | parser.add_option('-F', '--full', action='store_true', dest='full', |
| 221 | help='Generate a full project with sphinx-quickstart') |
| 222 | parser.add_option('-H', '--doc-project', action='store', dest='header', |
| 223 | help='Project name (default: root module name)') |
| 224 | parser.add_option('-A', '--doc-author', action='store', dest='author', |
| 225 | type='str', |
| 226 | help='Project author(s), used when --full is given') |
| 227 | parser.add_option('-V', '--doc-version', action='store', dest='version', |
| 228 | help='Project version, used when --full is given') |
| 229 | parser.add_option('-R', '--doc-release', action='store', dest='release', |
| 230 | help='Project release, used when --full is given, ' |
| 231 | 'defaults to --doc-version') |
| 232 | |
| 233 | (opts, args) = parser.parse_args(argv[1:]) |
| 234 | |
| 235 | if not args: |
| 236 | parser.error('A package path is required.') |
| 237 | |
| 238 | rootpath, excludes = args[0], args[1:] |
| 239 | if not opts.destdir: |
| 240 | parser.error('An output directory is required.') |
| 241 | if opts.header is None: |
| 242 | opts.header = path.normpath(rootpath).split(path.sep)[-1] |
| 243 | if opts.suffix.startswith('.'): |
| 244 | opts.suffix = opts.suffix[1:] |
| 245 | if not path.isdir(rootpath): |
| 246 | print('%s is not a directory.' % rootpath, file=sys.stderr) |
| 247 | sys.exit(1) |
| 248 | if not path.isdir(opts.destdir): |
| 249 | if not opts.dryrun: |
| 250 | os.makedirs(opts.destdir) |
| 251 | excludes = normalize_excludes(rootpath, excludes) |
nothing calls this directly
no test coverage detected