Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip JS end-comment tokens when generating typedefs #333

Merged
merged 2 commits into from
Jul 22, 2024
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
10 changes: 8 additions & 2 deletions src/NodeApi.Generator/TypeDefinitionsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,8 +2196,14 @@ private static string FormatDocText(XNode? node)
}
}

return s_newlineRegex.Replace(
(node?.ToString() ?? string.Empty).Replace("\r", "").Trim(), " ");
string text = node?.ToString() ?? string.Empty;
text = s_newlineRegex.Replace(text.Replace("\r", ""), " ");

// Remove end-comment tokens to prevent them from ending the JS doc-comments.
text = text.Replace("*/", string.Empty);

text = text.Trim();
return text;
}

private static string FormatDocMethodName(MethodInfo method)
Expand Down
2 changes: 1 addition & 1 deletion test/TypeDefsGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export enum TestEnum {
""".ReplaceLineEndings(),
GenerateTypeDefinition(typeof(TestEnum), new Dictionary<string, string>
{
["T:TestEnum"] = "enum",
["T:TestEnum"] = "enum */",
["F:TestEnum.Zero"] = "zero",
["F:TestEnum.One"] = "one",
}));
Expand Down
Loading