diff -r 05692e3d37bf -r 3ccdf551bde7 eric5-api.py --- a/eric5-api.py Sat May 15 10:19:07 2010 +0200 +++ b/eric5-api.py Sat May 15 15:29:39 2010 +0200 @@ -43,15 +43,22 @@ print() print("Options:") print() - print(" -b name or --base name") + print(" -b name or --base=name") print(" Use the given name as the name of the base package.") + print(" -e eol-type or --eol=eol-type") + print(" Use the given eol type to terminate lines.") + print(" Valid values are 'cr', 'lf' and 'crlf'.") + print(" --exclude-file=pattern") + print(" Specify a filename pattern of files to be excluded.") + print(" This option may be repeated multiple times.") print(" -h or --help") print(" Show this help and exit.") + print(" -l language or --language=language") + print(" Generate an API file for the given programming language.") + print(" Supported programming languages are:") print(" -o filename or --output=filename") print(" Write the API information to the named file. A '%L' placeholder") print(" is replaced by the language of the API file (see --language).") - print(" --oldstyle") - print(" Generate API files for QScintilla prior to 1.7.") print(" -p or --private") print(" Include private methods and functions.") print(" -R, -r or --recursive") @@ -64,12 +71,6 @@ print(" -x directory or --exclude=directory") print(" Specify a directory basename to be excluded.") print(" This option may be repeated multiple times.") - print(" --exclude-file=pattern") - print(" Specify a filename pattern of files to be excluded.") - print(" This option may be repeated multiple times.") - print(" -l language or --language=language") - print(" Generate an API file for the given programming language.") - print(" Supported programming languages are:") for lang in sorted(DocumentationTools.supportedExtensionsDictForApis.keys()): print(" * %s" % lang) print(" The default is 'Python'.") @@ -99,9 +100,9 @@ import getopt try: - opts, args = getopt.getopt(sys.argv[1:], "b:hl:o:pRrt:Vx:", - ["base=", "exclude=", "exclude-file=", "extension=", "help", - "language=", "oldstyle", "output=", "private", "recursive", + opts, args = getopt.getopt(sys.argv[1:], "b:e:hl:o:pRrt:Vx:", + ["base=", "eol=", "exclude=", "exclude-file=", "extension=", "help", + "language=", "output=", "private", "recursive", "version", ]) except getopt.error: usage() @@ -111,11 +112,11 @@ excludePatterns = [] outputFileName = "" recursive = False - newStyle = True basePackage = "" includePrivate = False progLanguages = [] extensions = [] + newline = None for k, v in opts: if k in ["-o", "--output"]: @@ -134,19 +135,25 @@ if not v.startswith("."): v = ".%s" % v extensions.append(v) - elif k in ["--oldstyle"]: - newStyle = False elif k in ["-b", "--base"]: basePackage = v elif k in ["-p", "--private"]: includePrivate = True elif k in ["-l", "--language"]: if v not in progLanguages: - if v not in list(DocumentationTools.supportedExtensionsDictForApis.keys()): + if v not in \ + list(DocumentationTools.supportedExtensionsDictForApis.keys()): sys.stderr.write("Wrong language given: %s. Aborting\n" % v) sys.exit(1) else: progLanguages.append(v) + elif k in ["-e", "--eol"]: + if v.lower() == "cr": + newline = '\r' + elif v.lower() == "lf": + newline = '\n' + elif v.lower() == "crlf": + newline = '\r\n' if not args: usage() @@ -232,7 +239,7 @@ module = Utilities.ModuleParser.readModule(file, basename = basename, inpackage = inpackage) apiGenerator = APIGenerator(module) - api = apiGenerator.genAPI(newStyle, basePackage, includePrivate) + api = apiGenerator.genAPI(True, basePackage, includePrivate) except IOError as v: sys.stderr.write("%s error: %s\n" % (file, v[1])) continue @@ -249,8 +256,8 @@ if outdir and not os.path.exists(outdir): os.makedirs(outdir) try: - out = open(outputFile, "w", encoding = "utf-8") - out.write("\n".join(sorted(apis))) + out = open(outputFile, "w", encoding = "utf-8", newline = newline) + out.write("\n".join(sorted(apis)) + "\n") out.close() except IOError as v: sys.stderr.write("%s error: %s\n" % (outputFile, v[1]))