Skip to content

Commit a42708b

Browse files
authored
Improve documentation tags in generated code (#250)
1 parent c2756df commit a42708b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

generator/plugins/dotnet/dotnet_helpers.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,28 @@
66

77
from generator import model
88

9+
BASIC_LINK_RE = re.compile(r"{@link +(\w+) ([\w ]+)}")
10+
BASIC_LINK_RE2 = re.compile(r"{@link +(\w+)\.(\w+) ([\w \.`]+)}")
11+
BASIC_LINK_RE3 = re.compile(r"{@link +(\w+)}")
12+
BASIC_LINK_RE4 = re.compile(r"{@link +(\w+)\.(\w+)}")
913
PARTS_RE = re.compile(r"(([a-z0-9])([A-Z]))")
1014

1115

16+
def _fix_links(line: str) -> str:
17+
line = BASIC_LINK_RE.sub(r'<see cref="\1">\2</see>', line)
18+
line = BASIC_LINK_RE2.sub(r'<see cref="\1.\2">\3</see>', line)
19+
line = BASIC_LINK_RE3.sub(r'<see cref="\1" />', line)
20+
line = BASIC_LINK_RE4.sub(r'<see cref="\1.\2" />', line)
21+
return line
22+
23+
1224
def lines_to_doc_comments(lines: List[str]) -> List[str]:
1325
if not lines:
1426
return []
27+
1528
return (
1629
["/// <summary>"]
17-
+ [f"/// {line}" for line in lines if not line.startswith("@")]
30+
+ [f"/// {_fix_links(line)}" for line in lines if not line.startswith("@")]
1831
+ ["/// </summary>"]
1932
)
2033

0 commit comments

Comments
 (0)