gdbus-codegen: preserve relative indentation in doc comments

This commit also changes the generators for rst, xml and dockbook
to preserve indentation.

Closes #3032
This commit is contained in:
André
2023-08-14 23:31:05 -03:00
parent 006e102e04
commit 9a6ca0ef75
5 changed files with 56 additions and 12 deletions

View File

@@ -20,6 +20,7 @@
# Author: David Zeuthen <davidz@redhat.com>
import re
import textwrap
from os import path
from . import utils
@@ -340,12 +341,12 @@ class DocbookCodeGenerator:
return s
def expand_paras(self, s, expandParamsAndConstants):
s = self.expand(s, expandParamsAndConstants).strip()
s = textwrap.dedent(self.expand(s, expandParamsAndConstants)).rstrip()
res = []
if not s.startswith("<para>"):
res.append("<para>")
for line in s.split("\n"):
line = line.strip()
line = line.rstrip()
if not line:
line = "</para><para>"
res.append(line)