Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/rda_python_miscs/pg_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,11 +882,11 @@ def create_table(self, lines, cnt, secid):
content += " " + self.replace_option_link(line, secid, 1).lstrip()
content += "\n\n"
elif re.search(r'=>$', line0):
line = re.sub(r'={1,}', '=', line0)
content = "| {}\n".format(line)
# line = re.sub(r'={1,}', '=', line0)
content = "| {}\n".format(line0)
for i in range(1, cnt):
line = lines[i]
line = re.sub(r'={2,}', '=', line)
# line = re.sub(r'={2,}', '=', line)
content += "| {}\n".format(line)
Comment on lines 884 to 890

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are commented-out re.sub(...) lines left in the =>$ table branch. If these substitutions are no longer needed for ReadTheDocs/Sphinx compatibility, it would be clearer to remove them; if they are sometimes needed, consider making the behavior explicit (e.g., a flag) and add a short comment explaining why the substitutions were disabled.

Copilot uses AI. Check for mistakes.
content += "\n"
else:
Expand Down Expand Up @@ -971,19 +971,20 @@ def build_rst_simple_table(self, rows):
for j, val in enumerate(row):
if j < ncols:
widths[j] = max(widths[j], len(val), 1)
sep = " ".join("=" * w for w in widths) + "\n"
# content = sep
content = ".. list-table::\n :widths: auto\n :header-rows: 1\n\n"
content = ".. list-table::\n :widths: auto\n :header-rows: 1\n"
for row in rows:
v = row[0] + "\n"
if len(row) == 1:
content += " " + row[0]
continue
v = row[0]
if len(v) > 1 and v[0] == '-': v = v[1:]
content += " * - " + v
content += "\n * - " + v
for c in range(1, ncols):
v = row[c] + "\n"
v = row[c]
if len(v) > 1 and v[0] == '-': v = v[1:]
content += " - " + v
content += "\n - " + v
Comment on lines +974 to +985

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The len(row) == 1 branch appends raw text inside a .. list-table:: directive without starting a * - row (and without ensuring a newline), which can produce invalid RST output. Also, iterating for c in range(1, ncols): v = row[c] will raise IndexError when rows have fewer columns than ncols (possible with re.split(r'\s{2,}', ...)). Consider normalizing each row to ncols by padding missing cells with empty strings (or guarding c < len(row)), and always emitting proper list-table row markup for every row.

Copilot uses AI. Check for mistakes.

return content
return content + "\n"

#
# description type (dtype): 0 - section, 1 - option, 2 - example, 3 - action
Expand Down Expand Up @@ -1011,9 +1012,9 @@ def create_synopsis(self, lines, cnt, secid, dtype):
line = self.replace_option_link(lines[i], secid, 2, dtype)
ms = re.match(r'^\s*{}\s+(.+)$'.format(self.DOCS['DOCNAM']), line)
if ms:
content += "| {}{}{} {}\n".format(self.Q1, self.DOCS['DOCNAM'], self.Q2, ms.group(1))
content += "| {}{}{} {}\n".format(self.Q1, self.DOCS['DOCNAM'], self.Q2, ms.group(1))
else:
content += "| "+line+"\n"
content += "| "+line+"\n"
content += "\n"

return content
Expand Down
Loading
Loading