Skip to content

Commit f8142eb

Browse files
committed
Check if directive is a CodeBlock directive
Avoids problems on styleguide with python link
1 parent 17beaed commit f8142eb

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

source/_extensions/redown.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from pathlib import Path
1515
from sphinx.application import Sphinx
1616
from dataclasses import dataclass
17+
from sphinx.directives.code import CodeBlock
1718

1819

1920
LINK_CORE = r"""
@@ -73,7 +74,15 @@ def replace(match: re.Match) -> str:
7374

7475
for line in code.splitlines(keepends=True):
7576
if line.strip().startswith(":") and not firstCode:
76-
ret += cindent + line
77+
colon_start = line.find(":")
78+
colon_end = line.rfind(":")
79+
if colon_start != -1 and colon_end != -1 and colon_start < colon_end:
80+
option = line[colon_start + 1 : colon_end].strip()
81+
if option in CodeBlock.option_spec:
82+
ret += cindent + line
83+
else:
84+
ret += "\n" + cindent + line
85+
firstCode = True
7786
elif line.strip() == "":
7887
if not firstCode:
7988
firstCode = True

source/docs/beta/tasks/task-3-port-code.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Desired Feedback
1313

1414
Please keep the following questions in mind as you complete the task and include this information, as appropriate, in your Task 3 report.
1515

16-
1. Note any required changes to your robot program not detailed in the :doc:`documentation for porting robot code </docs/yearly-overview/yearly-changelog>`.
17-
2. What problems or difficulties did you encounter?
18-
3. What questions did you have during the process?
19-
4. Any specific suggestions on improving the documentation? (Were any instructions unclear?)
20-
5. Compare the Free RAM on the DS diagnostics tab to similar code running on the 2024 image.
21-
6. Is there anything else you want to tell us related to this task?
16+
1. Note any required changes to your robot program not detailed in the :doc:`documentation for porting robot code </docs/yearly-overview/yearly-changelog>`.
17+
2. What problems or difficulties did you encounter?
18+
3. What questions did you have during the process?
19+
4. Any specific suggestions on improving the documentation? (Were any instructions unclear?)
20+
5. Compare the Free RAM on the DS diagnostics tab to similar code running on the 2024 image.
21+
6. Is there anything else you want to tell us related to this task?

0 commit comments

Comments
 (0)