Skip to content

Commit

Permalink
Strip JS end-comment tokens when generating typedefs (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin authored Jul 22, 2024
1 parent e2e8576 commit baaafdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit baaafdc

Please sign in to comment.