eric5-api.py

branch
5_1_x
changeset 1344
54c50e65173f
parent 791
9ec2ac20e54e
child 1510
e75ecf2bd9dd
equal deleted inserted replaced
1340:142ad6decc3a 1344:54c50e65173f
166 progLanguages = ["Python3"] 166 progLanguages = ["Python3"]
167 167
168 for progLanguage in sorted(progLanguages): 168 for progLanguage in sorted(progLanguages):
169 basename = "" 169 basename = ""
170 apis = [] 170 apis = []
171 basesDict = {}
171 172
172 supportedExtensions = \ 173 supportedExtensions = \
173 DocumentationTools.supportedExtensionsDictForApis[progLanguage] 174 DocumentationTools.supportedExtensionsDictForApis[progLanguage]
174 supportedExtensions.extend(extensions) 175 supportedExtensions.extend(extensions)
175 if "%L" in outputFileName: 176 if "%L" in outputFileName:
178 if len(progLanguages) == 1: 179 if len(progLanguages) == 1:
179 outputFile = outputFileName 180 outputFile = outputFileName
180 else: 181 else:
181 root, ext = os.path.splitext(outputFileName) 182 root, ext = os.path.splitext(outputFileName)
182 outputFile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext) 183 outputFile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext)
184 basesFile = os.path.splitext(outputFile)[0] + '.bas'
183 185
184 for arg in args: 186 for arg in args:
185 if os.path.isdir(arg): 187 if os.path.isdir(arg):
186 if os.path.exists(os.path.join(arg, 188 if os.path.exists(os.path.join(arg,
187 Utilities.joinext("__init__", ".py"))): 189 Utilities.joinext("__init__", ".py"))):
238 try: 240 try:
239 module = Utilities.ModuleParser.readModule(file, 241 module = Utilities.ModuleParser.readModule(file,
240 basename = basename, inpackage = inpackage) 242 basename = basename, inpackage = inpackage)
241 apiGenerator = APIGenerator(module) 243 apiGenerator = APIGenerator(module)
242 api = apiGenerator.genAPI(True, basePackage, includePrivate) 244 api = apiGenerator.genAPI(True, basePackage, includePrivate)
245 bases = apiGenerator.genBases(includePrivate)
243 except IOError as v: 246 except IOError as v:
244 sys.stderr.write("{0} error: {1}\n".format(file, v[1])) 247 sys.stderr.write("{0} error: {1}\n".format(file, v[1]))
245 continue 248 continue
246 except ImportError as v: 249 except ImportError as v:
247 sys.stderr.write("{0} error: {1}\n".format(file, v)) 250 sys.stderr.write("{0} error: {1}\n".format(file, v))
248 continue 251 continue
249 252
250 for apiEntry in api: 253 for apiEntry in api:
251 if not apiEntry in apis: 254 if not apiEntry in apis:
252 apis.append(apiEntry) 255 apis.append(apiEntry)
256 for basesEntry in bases:
257 if bases[basesEntry]:
258 basesDict[basesEntry] = bases[basesEntry][:]
253 sys.stdout.write("-- {0} -- {1} ok\n".format(progLanguage, file)) 259 sys.stdout.write("-- {0} -- {1} ok\n".format(progLanguage, file))
254 260
255 outdir = os.path.dirname(outputFile) 261 outdir = os.path.dirname(outputFile)
256 if outdir and not os.path.exists(outdir): 262 if outdir and not os.path.exists(outdir):
257 os.makedirs(outdir) 263 os.makedirs(outdir)
260 out.write("\n".join(sorted(apis)) + "\n") 266 out.write("\n".join(sorted(apis)) + "\n")
261 out.close() 267 out.close()
262 except IOError as v: 268 except IOError as v:
263 sys.stderr.write("{0} error: {1}\n".format(outputFile, v[1])) 269 sys.stderr.write("{0} error: {1}\n".format(outputFile, v[1]))
264 sys.exit(3) 270 sys.exit(3)
271 try:
272 out = open(basesFile, "w", encoding="utf-8", newline=newline)
273 for baseEntry in sorted(basesDict.keys()):
274 out.write("{0} {1}\n".format(
275 baseEntry, " ".join(sorted(basesDict[baseEntry]))))
276 out.close()
277 except IOError as v:
278 sys.stderr.write("{0} error: {1}\n".format(basesFile, v[1]))
279 sys.exit(3)
265 280
266 sys.stdout.write('\nDone.\n') 281 sys.stdout.write('\nDone.\n')
267 sys.exit(0) 282 sys.exit(0)
268 283
269 if __name__ == '__main__': 284 if __name__ == '__main__':

eric ide

mercurial