Skip to content

Commit 9fb5dd5

Browse files
authored
Merge pull request #11692 from albert-github/feature/bug_tblr_language
Consistency language version table between HTML and LaTeX
2 parents 445ff9a + 4863daa commit 9fb5dd5

File tree

1 file changed

+14
-88
lines changed

1 file changed

+14
-88
lines changed

doc/translator.py

Lines changed: 14 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,28 +1870,23 @@ def generateLanguageDoc(self):
18701870

18711871
# Define templates for HTML table parts of the documentation.
18721872
htmlTableTpl = '''
1873-
\\htmlonly
1874-
</p>
1875-
<table align="center" cellspacing="0" cellpadding="0" border="0">
1876-
<tr bgcolor="#000000">
1877-
<td>
1878-
<table cellspacing="1" cellpadding="2" border="0">
1879-
<tr bgcolor="#4040c0">
1880-
<td ><b><font size="+1" color="#ffffff"> Language </font></b></td>
1881-
<td ><b><font size="+1" color="#ffffff"> Maintainer </font></b></td>
1882-
<td ><b><font size="+1" color="#ffffff"> Contact address </font>
1883-
<font size="-2" color="#ffffff">(replace the at and dot)</font></b></td>
1884-
<td ><b><font size="+1" color="#ffffff"> Status </font></b></td>
1873+
\\latexonly
1874+
\\footnotesize
1875+
\\endlatexonly
1876+
<table align="center" class=doxtable cellspacing="1" cellpadding="2">
1877+
<tr>
1878+
<th >Language</th>
1879+
<th >Maintainer</th>
1880+
<th >Contact address (replace the at and dot)</th>
1881+
<th >Status</td>
18851882
</tr>
18861883
<!-- table content begin -->
18871884
%s
18881885
<!-- table content end -->
1889-
</table>
1890-
</td>
1891-
</tr>
18921886
</table>
1893-
<p>
1894-
\\endhtmlonly
1887+
\\latexonly
1888+
\\normalsize
1889+
\\endlatexonly
18951890
'''
18961891
htmlTableTpl = textwrap.dedent(htmlTableTpl)
18971892
htmlTrTpl = '\n <tr bgcolor="#ffffff">%s\n </tr>'
@@ -1963,85 +1958,16 @@ def generateLanguageDoc(self):
19631958

19641959
# The last element contains the readable form of the status.
19651960
bgcolor = self.getBgcolorByReadableStatus(obj.readableStatus)
1966-
lst.append(htmlTdStatusColorTpl % (bgcolor, obj.readableStatus))
1961+
lst.append(htmlTdStatusColorTpl % (bgcolor, obj.readableStatus.replace(".","\\.")))
19671962

19681963
# Join the table data to one table row.
19691964
trlst.append(htmlTrTpl % (''.join(lst)))
19701965

19711966
# Join the table rows and insert into the template.
19721967
htmlTable = htmlTableTpl % (''.join(trlst))
19731968

1974-
# Define templates for LaTeX table parts of the documentation.
1975-
latexTableTpl = r'''
1976-
\latexonly
1977-
\footnotesize
1978-
\begin{longtable}{|l|l|l|l|}
1979-
\hline
1980-
{\bf Language} & {\bf Maintainer} & {\bf Contact address} & {\bf Status} \\
1981-
\hline
1982-
%s
1983-
\hline
1984-
\end{longtable}
1985-
\normalsize
1986-
\endlatexonly
1987-
'''
1988-
latexTableTpl = textwrap.dedent(latexTableTpl)
1989-
latexLineTpl = '\n' + r' %s & %s & {\tt\tiny %s} & %s \\'
1990-
1991-
# Loop through transl objects in the order of sorted readable names
1992-
# and add generate the content of the LaTeX table.
1993-
trlst = []
1994-
for name, obj in self.langLst:
1995-
# For LaTeX, more maintainers for the same language are
1996-
# placed on separate rows in the table. The line separator
1997-
# in the table is placed explicitly above the first
1998-
# maintainer. Prepare the arguments for the LaTeX row template.
1999-
maintainers = []
2000-
if obj.classId in self.__maintainersDic:
2001-
maintainers = self.__maintainersDic[obj.classId]
2002-
2003-
lang = obj.langReadable
2004-
maintainer = None # init
2005-
email = None # init
2006-
if obj.status == 'En':
2007-
# Check whether there is the coupled non-English.
2008-
classId = obj.classId[:-2]
2009-
if classId in self.__translDic:
2010-
langNE = self.__translDic[classId].langReadable
2011-
maintainer = 'see the %s language' % langNE
2012-
email = '~'
2013-
2014-
if not maintainer and (obj.classId in self.__maintainersDic):
2015-
lm = [ m[0] for m in self.__maintainersDic[obj.classId] ]
2016-
maintainer = maintainers[0][0]
2017-
email = maintainers[0][1]
2018-
2019-
status = obj.readableStatus
2020-
2021-
# Use the template to produce the line of the table and insert
2022-
# the hline plus the constructed line into the table content.
2023-
# The underscore character must be escaped.
2024-
trlst.append('\n \\hline')
2025-
s = latexLineTpl % (lang, maintainer, email, status)
2026-
s = s.replace('_', '\\_')
2027-
trlst.append(s)
2028-
2029-
# List the other maintainers for the language. Do not set
2030-
# lang and status for them.
2031-
lang = '~'
2032-
status = '~'
2033-
for m in maintainers[1:]:
2034-
maintainer = m[0]
2035-
email = m[1]
2036-
s = latexLineTpl % (lang, maintainer, email, status)
2037-
s = s.replace('_', '\\_')
2038-
trlst.append(s)
2039-
2040-
# Join the table lines and insert into the template.
2041-
latexTable = latexTableTpl % (''.join(trlst))
2042-
20431969
# Put the HTML and LaTeX parts together and define the dic item.
2044-
tplDic['informationTable'] = htmlTable + '\n' + latexTable
1970+
tplDic['informationTable'] = htmlTable
20451971

20461972
# Insert the symbols into the document template and write it down.
20471973
f = xopen(fDocName, 'w')

0 commit comments

Comments
 (0)