Skip to content

Commit 7a0fce7

Browse files
committed
fix: update conf.py to fix error in preview
1 parent d74bf46 commit 7a0fce7

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

docs/conf.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,21 @@ def setup(app: Sphinx):
125125

126126
CLI_OPT_NAME = re.compile(r"^\s*(\-\w)(?:\s+[A-Z_\[\]]*)?(?:,\s+(\-\-[a-z\-]+))?")
127127
in_options_section = False
128+
skip_lines = set() # Track lines we've already processed
129+
130+
lines = result.stdout.splitlines()
131+
132+
for i, line in enumerate(lines):
133+
if i in skip_lines:
134+
continue
128135

129-
for line in result.stdout.splitlines():
130136
stripped = line.strip()
131137

132138
# Start processing options when we see the "options:" line
133139
if stripped.lower() == "options:":
134140
in_options_section = True
135141
doc.append(line)
142+
doc.append("") # Add blank line after options header
136143
continue
137144

138145
if in_options_section:
@@ -141,12 +148,39 @@ def setup(app: Sphinx):
141148
short_opt = match.group(1)
142149
long_opt = match.group(2)
143150

144-
# Always add a blank line before std:option to avoid indentation issues
151+
# Add the std:option directive
145152
if short_opt and long_opt:
146-
doc.extend(["", f".. std:option:: {short_opt}, {long_opt}", ""])
153+
doc.append(f".. std:option:: {short_opt}, {long_opt}")
147154
elif short_opt:
148-
doc.extend(["", f".. std:option:: {short_opt}", ""])
155+
doc.append(f".. std:option:: {short_opt}")
156+
157+
doc.append("") # Blank line after directive
158+
159+
# Collect all description lines for this option
160+
description_lines = []
161+
162+
# Add the current line (contains the option and start of description)
163+
parts = line.split(None, 2) # Split on whitespace, max 2 splits
164+
if len(parts) > 2:
165+
description_lines.append(parts[2])
166+
167+
# Look ahead for continuation lines
168+
j = i + 1
169+
while j < len(lines) and lines[j].startswith(
170+
" "
171+
):
172+
description_lines.append(lines[j].strip())
173+
skip_lines.add(j)
174+
j += 1
175+
176+
# Add description with proper indentation
177+
for desc_line in description_lines:
178+
doc.append(f" {desc_line}")
179+
180+
doc.append("") # Blank line after option description
181+
continue
149182

183+
# For non-option lines that we haven't processed, add as-is
150184
doc.append(line)
151185

152186
cli_doc = Path(app.srcdir, "cli_args.rst")

0 commit comments

Comments
 (0)