mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
codegen: Do not add extra paragraph elements while parsing
When parsing a comment we're adding <para> elements ourselves, but the DocBook generator already wraps any block of text that does not start with a <para> element with one.
This commit is contained in:
parent
c6a9113da6
commit
5013d08315
@ -345,9 +345,17 @@ class DocbookCodeGenerator:
|
||||
|
||||
def expand_paras(self, s, expandParamsAndConstants):
|
||||
s = self.expand(s, expandParamsAndConstants).strip()
|
||||
res = []
|
||||
if not s.startswith("<para"):
|
||||
s = "<para>%s</para>" % s
|
||||
return s
|
||||
res.append("<para>")
|
||||
for line in s.split("\n"):
|
||||
line = line.strip()
|
||||
if not line:
|
||||
line = "</para><para>"
|
||||
res.append(line)
|
||||
if not s.endswith("</para>"):
|
||||
res.append("</para>")
|
||||
return "\n".join(res)
|
||||
|
||||
def generate_expand_dicts(self):
|
||||
self.expand_member_dict = {}
|
||||
|
@ -85,7 +85,7 @@ class DBusXMLParser:
|
||||
symbol = line[0:colon_index]
|
||||
rest_of_line = line[colon_index + 2 :].strip()
|
||||
if len(rest_of_line) > 0:
|
||||
body += "<para>" + rest_of_line + "</para>"
|
||||
body += f"{rest_of_line}\n"
|
||||
comment_state = DBusXMLParser.COMMENT_STATE_PARAMS
|
||||
elif comment_state == DBusXMLParser.COMMENT_STATE_PARAMS:
|
||||
if line.startswith("@"):
|
||||
@ -93,9 +93,9 @@ class DBusXMLParser:
|
||||
if colon_index == -1:
|
||||
comment_state = DBusXMLParser.COMMENT_STATE_BODY
|
||||
if not in_para:
|
||||
body += "<para>"
|
||||
body += "\n"
|
||||
in_para = True
|
||||
body += orig_line + "\n"
|
||||
body += f"{orig_line}\n"
|
||||
else:
|
||||
param = line[1:colon_index]
|
||||
docs = line[colon_index + 2 :]
|
||||
@ -104,21 +104,20 @@ class DBusXMLParser:
|
||||
comment_state = DBusXMLParser.COMMENT_STATE_BODY
|
||||
if len(line) > 0:
|
||||
if not in_para:
|
||||
body += "<para>"
|
||||
body += "\n"
|
||||
in_para = True
|
||||
body += orig_line + "\n"
|
||||
elif comment_state == DBusXMLParser.COMMENT_STATE_BODY:
|
||||
if len(line) > 0:
|
||||
if not in_para:
|
||||
body += "<para>"
|
||||
in_para = True
|
||||
body += orig_line + "\n"
|
||||
else:
|
||||
if in_para:
|
||||
body += "</para>"
|
||||
body += "\n"
|
||||
in_para = False
|
||||
if in_para:
|
||||
body += "</para>"
|
||||
body += "\n"
|
||||
|
||||
if symbol != "":
|
||||
self.doc_comment_last_symbol = symbol
|
||||
|
Loading…
Reference in New Issue
Block a user