update hover feature
/ build_and_publish (release) Failing after 27s

This commit is contained in:
Christoph Brandau
2025-08-11 16:20:14 +02:00
parent b38fab1428
commit 2c2579319d
2 changed files with 112 additions and 4 deletions
+37 -4
View File
@@ -42,7 +42,7 @@ def extract_doc_block_above(lines: List[str], start_line_index: int) -> str | No
# Reverse to original order and strip comment prefixes
doc_lines.reverse()
cleaned = [_strip_comment_prefix(l) for l in doc_lines]
cleaned = [_strip_comment_prefix(line_text) for line_text in doc_lines]
# Simple tag -> markdown conversions for nicer rendering
md_lines: List[str] = []
@@ -55,12 +55,45 @@ def extract_doc_block_above(lines: List[str], start_line_index: int) -> str | No
"<Internal Example>": "### Internal Example",
}
in_example = False
code_block_open = False
def close_code_block_if_open():
nonlocal code_block_open
if code_block_open:
md_lines.append("```")
code_block_open = False
for line in cleaned:
stripped = line.strip()
# Convert tags to headings and manage example sections
if stripped in tag_map:
md_lines.append(tag_map[stripped])
else:
md_lines.append(line)
# If we hit any new tag, close a pending code block
close_code_block_if_open()
heading = tag_map[stripped]
md_lines.append(heading)
in_example = heading in ("### Example", "### Internal Example")
continue
if in_example:
low = stripped.lower()
if low.startswith("code:"):
# Open code block if needed and append the code content
code_text = line.split(":", 1)[1].strip()
if not code_block_open:
md_lines.append("```tcl")
code_block_open = True
md_lines.append(code_text)
continue
# Keep name/desc lines as regular text outside code
if low.startswith("name:") or low.startswith("desc:"):
md_lines.append(line)
continue
md_lines.append(line)
# Close any dangling code fence at the end of the block
close_code_block_if_open()
return "\n".join(md_lines).rstrip()