diff --git a/src/TypeScriptDefinitionGenerator/Generator/IntellisenseParser.cs b/src/TypeScriptDefinitionGenerator/Generator/IntellisenseParser.cs
index df1959e..66cbbbb 100644
--- a/src/TypeScriptDefinitionGenerator/Generator/IntellisenseParser.cs
+++ b/src/TypeScriptDefinitionGenerator/Generator/IntellisenseParser.cs
@@ -442,15 +442,32 @@ private static string GetSummary(vsCMInfoLocation location, string xmlComment, s
try
{
- string summary = "";
+ var summary = new System.Text.StringBuilder();
if (!string.IsNullOrWhiteSpace(xmlComment))
{
- summary = XElement.Parse(xmlComment)
- .Descendants("summary")
- .Select(x => x.Value)
- .FirstOrDefault();
+ var s = XElement.Parse(xmlComment).Descendants("summary").FirstOrDefault();
+ foreach (var e in s.Nodes())
+ {
+ switch (e.NodeType)
+ {
+ case System.Xml.XmlNodeType.None:
+ break;
+ case System.Xml.XmlNodeType.Element:
+ if ((e as XElement).Name == "see") {
+ summary.Append("'" + (e as XElement).Attribute("cref").Value + "'");
+ }
+
+ break;
+ case System.Xml.XmlNodeType.Text:
+ summary.Append((e as XText).Value);
+ break;
+
+ default:
+ break;
+ }
+ }
}
- if (!string.IsNullOrEmpty(summary)) return summary.Trim();
+ if (summary.Length > 0) return summary.ToString().Trim();
if (!string.IsNullOrWhiteSpace(inlineComment)) return inlineComment.Trim();
return null;
}
diff --git a/src/TypeScriptDefinitionGenerator/Generator/IntellisenseWriter.cs b/src/TypeScriptDefinitionGenerator/Generator/IntellisenseWriter.cs
index 868ef67..55fbf39 100644
--- a/src/TypeScriptDefinitionGenerator/Generator/IntellisenseWriter.cs
+++ b/src/TypeScriptDefinitionGenerator/Generator/IntellisenseWriter.cs
@@ -10,8 +10,6 @@ namespace TypeScriptDefinitionGenerator
{
internal static class IntellisenseWriter
{
- private static readonly Regex _whitespaceTrimmer = new Regex(@"^\s+|\s+$|\s*[\r\n]+\s*", RegexOptions.Compiled);
-
///
/// Generates TypeScript file for given C# class/enum (IntellisenseObject).
///
@@ -43,9 +41,8 @@ public static string WriteTypeScript(IList objects, string s
foreach (IntellisenseObject io in ns)
{
- if (!string.IsNullOrEmpty(io.Summary))
- sbBody.Append(prefixModule).AppendLine("/** " + _whitespaceTrimmer.Replace(io.Summary, "") + " */");
-
+ WriteTypeScriptComment(io.Summary, sbBody, prefixModule);
+
if (io.IsEnum)
{
string type = "enum ";
@@ -157,17 +154,32 @@ private static string CleanEnumInitValue(string value)
return "0";
}
- private static void WriteTypeScriptComment(IntellisenseProperty p, StringBuilder sb, string prefix)
+ private static void WriteTypeScriptComment(string comment, StringBuilder sb, string prefix)
{
- if (string.IsNullOrEmpty(p.Summary)) return;
- sb.Append(prefix).AppendLine("/** " + _whitespaceTrimmer.Replace(p.Summary, "") + " */");
+ if (string.IsNullOrEmpty(comment)) return;
+ string[] commentLines = comment.Split(
+ new[] { "\r\n", "\r", "\n" },
+ StringSplitOptions.None
+ );
+ bool isFirstLine = true;
+ foreach (var commentLine in commentLines)
+ {
+ if (isFirstLine)
+ {
+ sb.Append(prefix).AppendLine("/** ");
+ isFirstLine = false;
+ }
+
+ sb.Append(prefix).Append(" * ").AppendLine(commentLine.Replace("*/", "+/"));
+ }
+ sb.Append(prefix).AppendLine(" */");
}
private static void WriteTSEnumDefinition(StringBuilder sb, string prefix, IEnumerable props)
{
foreach (var p in props)
{
- WriteTypeScriptComment(p, sb, prefix);
+ WriteTypeScriptComment(p.Summary, sb, prefix);
if (p.InitExpression != null)
{
@@ -185,7 +197,7 @@ private static void WriteTSInterfaceDefinition(StringBuilder sb, string prefix,
{
foreach (var p in props)
{
- WriteTypeScriptComment(p, sb, prefix);
+ WriteTypeScriptComment(p.Summary, sb, prefix);
sb.AppendFormat("{0}{1}: ", prefix, Utility.CamelCasePropertyName(p.NameWithOption));
if (p.Type.IsKnownType) sb.Append(p.Type.TypeScriptName);