Commit 4b8b9430 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Merge branch 'master' of https://github.com/pepr/doxygen into pepr-master

parents 0bb9b762 6212c2d2
...@@ -64,13 +64,30 @@ ...@@ -64,13 +64,30 @@
2013/06/25 - TranslatorDecoder checks removed after removing the class. 2013/06/25 - TranslatorDecoder checks removed after removing the class.
2013/09/04 - Coloured status in langhowto. *ALMOST up-to-date* category 2013/09/04 - Coloured status in langhowto. *ALMOST up-to-date* category
of translators introduced. of translators introduced.
2014/06/16 - unified for Python 2.6+ and 3.0+
""" """
from __future__ import print_function
import codecs
import os import os
import platform
import re import re
import sys import sys
import textwrap
def xopen(fname, mode='r', encoding='utf-8-sig'):
'''Unified file opening for Python 2 an Python 3.
Python 2 does not have the encoding argument. Python 3 has one, and
the default 'utf-8-sig' is used (skips the BOM automatically).
'''
major, minor, patch = (int(e) for e in platform.python_version_tuple())
if major == 2:
return open(fname, mode=mode) # Python 2 without encoding
else:
return open(fname, mode=mode, encoding=encoding) # Python 3 with encoding
def fill(s): def fill(s):
...@@ -99,58 +116,6 @@ def fill(s): ...@@ -99,58 +116,6 @@ def fill(s):
return '\n'.join(lines) return '\n'.join(lines)
# The following function dedent() is the verbatim copy from the textwrap.py
# module. The textwrap.py was introduced in Python 2.3. To make this script
# working also in older Python versions, I have decided to copy it.
# Notice that the textwrap.py is copyrighted:
#
# Copyright (C) 1999-2001 Gregory P. Ward.
# Copyright (C) 2002, 2003 Python Software Foundation.
# Written by Greg Ward <gward@python.net>
#
# The explicit permission to use the code here was sent by Guido van Rossum
# (4th June, 2004).
#
def dedent(text):
"""dedent(text : string) -> string
Remove any whitespace than can be uniformly removed from the left
of every line in `text`.
This can be used e.g. to make triple-quoted strings line up with
the left edge of screen/whatever, while still presenting it in the
source code in indented form.
For example:
def test():
# end first line with \ to avoid the empty line!
s = '''\
hello
world
'''
print repr(s) # prints ' hello\n world\n '
print repr(dedent(s)) # prints 'hello\n world\n'
"""
lines = text.expandtabs().split('\n')
margin = None
for line in lines:
content = line.lstrip()
if not content:
continue
indent = len(line) - len(content)
if margin is None:
margin = indent
else:
margin = min(margin, indent)
if margin is not None and margin > 0:
for i in range(len(lines)):
lines[i] = lines[i][margin:]
return '\n'.join(lines)
class Transl: class Transl:
"""One instance is build for each translator. """One instance is build for each translator.
...@@ -237,7 +202,7 @@ class Transl: ...@@ -237,7 +202,7 @@ class Transl:
# Open the file for reading and extracting tokens until the eof. # Open the file for reading and extracting tokens until the eof.
# Initialize the finite automaton. # Initialize the finite automaton.
f = open(self.fname) f = xopen(self.fname)
lineNo = 0 lineNo = 0
line = '' # init -- see the pos initialization below line = '' # init -- see the pos initialization below
linelen = 0 # init linelen = 0 # init
...@@ -256,8 +221,6 @@ class Transl: ...@@ -256,8 +221,6 @@ class Transl:
else: else:
lineNo += 1 lineNo += 1
line = f.readline() line = f.readline()
if line.startswith('\xef\xbb\xbf'):
line = line[3:] # skip the BOM
linelen = len(line) linelen = len(line)
pos = 0 pos = 0
if line == '': # eof if line == '': # eof
...@@ -1108,6 +1071,7 @@ class Transl: ...@@ -1108,6 +1071,7 @@ class Transl:
for p in myDic: for p in myDic:
if p not in reqDic: if p not in reqDic:
self.obsoleteMethods.append(p) self.obsoleteMethods.append(p)
self.obsoleteMethods.sort()
# Build the list of missing methods and the list of implemented # Build the list of missing methods and the list of implemented
# required methods. # required methods.
...@@ -1118,6 +1082,8 @@ class Transl: ...@@ -1118,6 +1082,8 @@ class Transl:
self.implementedMethods.append(p) self.implementedMethods.append(p)
else: else:
self.missingMethods.append(p) self.missingMethods.append(p)
self.missingMethods.sort()
self.implementedMethods.sort()
# Check whether adapter must be used or suggest the newest one. # Check whether adapter must be used or suggest the newest one.
# Change the status and set the note accordingly. # Change the status and set the note accordingly.
...@@ -1386,8 +1352,8 @@ class TrManager: ...@@ -1386,8 +1352,8 @@ class TrManager:
self.langLst = [] self.langLst = []
for obj in list(self.__translDic.values()): for obj in list(self.__translDic.values()):
self.langLst.append((obj.langReadable, obj)) self.langLst.append((obj.langReadable, obj))
#self.langLst.sort(lambda a, b: cmp(a[0], b[0]))
self.langLst.sort(key=lambda a: a[0]) self.langLst.sort(key=lambda x: x[0])
# Create the list with readable language names. If the language has # Create the list with readable language names. If the language has
# also the English-based version, modify the item by appending # also the English-based version, modify the item by appending
...@@ -1429,7 +1395,7 @@ class TrManager: ...@@ -1429,7 +1395,7 @@ class TrManager:
self.numLang -= 1 # the couple will be counted as one self.numLang -= 1 # the couple will be counted as one
# Extract the version of Doxygen. # Extract the version of Doxygen.
f = open(os.path.join(self.doxy_path, 'VERSION')) f = xopen(os.path.join(self.doxy_path, 'VERSION'))
self.doxVersion = f.readline().strip() self.doxVersion = f.readline().strip()
f.close() f.close()
...@@ -1477,7 +1443,7 @@ class TrManager: ...@@ -1477,7 +1443,7 @@ class TrManager:
# Read content of the file as one string. # Read content of the file as one string.
assert os.path.isfile(fname) assert os.path.isfile(fname)
f = open(fname) f = xopen(fname)
cont = f.read() cont = f.read()
f.close() f.close()
...@@ -1554,7 +1520,7 @@ class TrManager: ...@@ -1554,7 +1520,7 @@ class TrManager:
output = os.path.join(self.doc_path, self.translatorReportFileName) output = os.path.join(self.doc_path, self.translatorReportFileName)
# Open the textual report file for the output. # Open the textual report file for the output.
f = open(output, 'w') f = xopen(output, 'w')
# Output the information about the version. # Output the information about the version.
f.write('(' + self.doxVersion + ')\n\n') f.write('(' + self.doxVersion + ')\n\n')
...@@ -1582,7 +1548,7 @@ class TrManager: ...@@ -1582,7 +1548,7 @@ class TrManager:
# The e-mail addresses of the maintainers will be collected to # The e-mail addresses of the maintainers will be collected to
# the auxiliary file in the order of translator classes listed # the auxiliary file in the order of translator classes listed
# in the translator report. # in the translator report.
fmail = open('mailto.txt', 'w') fmail = xopen('mailto.txt', 'w')
# Write the list of "up-to-date" translator classes. # Write the list of "up-to-date" translator classes.
if self.upToDateIdLst: if self.upToDateIdLst:
...@@ -1754,7 +1720,7 @@ class TrManager: ...@@ -1754,7 +1720,7 @@ class TrManager:
self.lastModificationTime = tim self.lastModificationTime = tim
# Process the content of the maintainers file. # Process the content of the maintainers file.
f = codecs.open(fname, 'r', 'utf-8') f = xopen(fname)
inside = False # inside the record for the language inside = False # inside the record for the language
lineReady = True lineReady = True
classId = None classId = None
...@@ -1818,7 +1784,7 @@ class TrManager: ...@@ -1818,7 +1784,7 @@ class TrManager:
# #
# Read the template of the documentation, and remove the first # Read the template of the documentation, and remove the first
# attention lines. # attention lines.
f = codecs.open(fTplName, 'r', 'utf-8') f = xopen(fTplName)
doctpl = f.read() doctpl = f.read()
f.close() f.close()
...@@ -1830,7 +1796,7 @@ class TrManager: ...@@ -1830,7 +1796,7 @@ class TrManager:
# document template. # document template.
tplDic = {} tplDic = {}
s = 'Do not edit this file. It was generated by the %s script.\n * Instead edit %s and %s' % (self.script_name, self.languageTplFileName, self.maintainersFileName) s = 'Do not edit this file. It was generated by the %s script. * Instead edit %s and %s' % (self.script_name, self.languageTplFileName, self.maintainersFileName)
tplDic['editnote'] = s tplDic['editnote'] = s
tplDic['doxVersion'] = self.doxVersion tplDic['doxVersion'] = self.doxVersion
...@@ -1866,7 +1832,7 @@ class TrManager: ...@@ -1866,7 +1832,7 @@ class TrManager:
</table> </table>
\\endhtmlonly \\endhtmlonly
''' '''
htmlTableTpl = dedent(htmlTableTpl) htmlTableTpl = textwrap.dedent(htmlTableTpl)
htmlTrTpl = '\n <tr bgcolor="#ffffff">%s\n </tr>' htmlTrTpl = '\n <tr bgcolor="#ffffff">%s\n </tr>'
htmlTdTpl = '\n <td>%s</td>' htmlTdTpl = '\n <td>%s</td>'
htmlTdStatusColorTpl = '\n <td bgcolor="%s">%s</td>' htmlTdStatusColorTpl = '\n <td bgcolor="%s">%s</td>'
...@@ -1915,7 +1881,7 @@ class TrManager: ...@@ -1915,7 +1881,7 @@ class TrManager:
# The marked adresses (they start with the mark '[unreachable]', # The marked adresses (they start with the mark '[unreachable]',
# '[resigned]', whatever '[xxx]') will not be displayed at all. # '[resigned]', whatever '[xxx]') will not be displayed at all.
# Only the mark will be used instead. # Only the mark will be used instead.
rexMark = re.compile(r'(?P<mark>\[.*?\])') rexMark = re.compile('(?P<mark>\\[.*?\\])')
le = [] le = []
for maintainer in self.__maintainersDic[obj.classId]: for maintainer in self.__maintainersDic[obj.classId]:
address = maintainer[1] address = maintainer[1]
...@@ -1954,7 +1920,7 @@ class TrManager: ...@@ -1954,7 +1920,7 @@ class TrManager:
\normalsize \normalsize
\endlatexonly \endlatexonly
''' '''
latexTableTpl = dedent(latexTableTpl) latexTableTpl = textwrap.dedent(latexTableTpl)
latexLineTpl = '\n' + r' %s & %s & {\tt\tiny %s} & %s \\' latexLineTpl = '\n' + r' %s & %s & {\tt\tiny %s} & %s \\'
# Loop through transl objects in the order of sorted readable names # Loop through transl objects in the order of sorted readable names
...@@ -2013,14 +1979,21 @@ class TrManager: ...@@ -2013,14 +1979,21 @@ class TrManager:
tplDic['informationTable'] = htmlTable + '\n' + latexTable tplDic['informationTable'] = htmlTable + '\n' + latexTable
# Insert the symbols into the document template and write it down. # Insert the symbols into the document template and write it down.
f = codecs.open(fDocName, 'w', 'utf-8') f = xopen(fDocName, 'w')
f.write(doctpl % tplDic) f.write(doctpl % tplDic)
f.close() f.close()
if __name__ == '__main__': if __name__ == '__main__':
# Create the manager, build the transl objects, and parse the related # The Python 2.6+ or 3.3+ is required.
# sources. major, minor, patch = (int(e) for e in platform.python_version_tuple())
print(major, minor, patch)
if (major == 2 and minor < 6) or (major == 3 and minor < 0):
print('Python 2.6+ or Python 3.0+ are required for the script')
sys.exit(1)
# The translator manager builds the transl objects, parses the related
# sources, and keeps them in memory.
trMan = TrManager() trMan = TrManager()
# Generate the language.doc. # Generate the language.doc.
......
#! python2 #!python2
from __future__ import print_function from __future__ import print_function
...@@ -92,8 +92,7 @@ def copyBinaries(dist_dir, subdir): ...@@ -92,8 +92,7 @@ def copyBinaries(dist_dir, subdir):
# Source file should exist. # Source file should exist.
sdir, fname = getThisScriptPathAndName() sdir, fname = getThisScriptPathAndName()
src = os.path.normpath(os.path.join(sdir, '..', 'bin', subdir, 'doxygen.exe')) src = os.path.normpath(os.path.join(sdir, '..', 'bin', subdir, 'doxygen.exe'))
assert os.path.isfile(src) if os.path.isfile(src):
# Destination directory must not exist. It must be created first. # Destination directory must not exist. It must be created first.
dst_dir = os.path.normpath(os.path.join(dist_dir, 'bin', subdir)) dst_dir = os.path.normpath(os.path.join(dist_dir, 'bin', subdir))
assert not os.path.isdir(dst_dir) assert not os.path.isdir(dst_dir)
...@@ -102,6 +101,9 @@ def copyBinaries(dist_dir, subdir): ...@@ -102,6 +101,9 @@ def copyBinaries(dist_dir, subdir):
# Copy the file. # Copy the file.
print("Copying '{}'".format(src)) print("Copying '{}'".format(src))
shutil.copy2(src, dst_dir) shutil.copy2(src, dst_dir)
else:
print("The binary '" + src + "'")
print('was not found. It will not be present in the distribution.')
def getBinariesZipBareName(): def getBinariesZipBareName():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment