-
Notifications
You must be signed in to change notification settings - Fork 16
Feature/html formatting #22
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| using System; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
|
|
@@ -209,7 +209,7 @@ public void WriteType(INamedTypeSymbol type, INamedTypeSymbol oldType) | |
| if (type.GetInterfaces(oldType).Any()) | ||
| { | ||
| isEmpty = false; | ||
| sw.Write("<br/>Implements "); | ||
| sw.Write("<br/>Implements <span class='code'>"); | ||
| int i = 0; | ||
| foreach(var iface in type.GetInterfaces(oldType)) | ||
| { | ||
|
|
@@ -220,6 +220,7 @@ public void WriteType(INamedTypeSymbol type, INamedTypeSymbol oldType) | |
| if (iface.wasRemoved) sw.Write("</span>"); | ||
| i++; | ||
| } | ||
| sw.Write("</span>"); // MA - End <span class="code>.../span> | ||
| } | ||
| sw.WriteLine("</div>"); //End header box | ||
|
|
||
|
|
@@ -261,7 +262,7 @@ private string GetIcon(ISymbol type, string content) | |
| } | ||
| if (icon == "") | ||
| return content; | ||
| return $"<li class='{icon}'>{content}</li>"; | ||
| return $"<li class='{icon} code'>{content}</li>"; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's a good idea to create a style users can easily override, but not sure this should be the style name, or that it should default to a mono-space font. |
||
| } | ||
|
|
||
| public void WriteEnum(INamedTypeSymbol enm) => WriteEnum(enm, null); | ||
|
|
@@ -295,7 +296,7 @@ private string FormatType(ITypeSymbol type) | |
| if (p.Kind == SymbolDisplayPartKind.Punctuation || p.Kind == SymbolDisplayPartKind.Space) | ||
| t += System.Web.HttpUtility.HtmlEncode(p.ToString()); | ||
| else if (p.Symbol is ITypeSymbol its) | ||
| t += LinkifyType(its, false); | ||
| t += $"<span class='type'>{LinkifyType(its, false)}</span>"; | ||
| else | ||
| { | ||
|
|
||
|
|
@@ -304,7 +305,11 @@ private string FormatType(ITypeSymbol type) | |
| return t; | ||
| } | ||
| else { | ||
| return LinkifyType(type); | ||
| if (parts[0].Kind == SymbolDisplayPartKind.Keyword) | ||
| { | ||
| return $"<span class='keyword'>{LinkifyType(type)}</span>"; | ||
| } | ||
| return $"<span class='type'>{LinkifyType(type)}</span>"; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -316,27 +321,29 @@ private string LinkifyType(ITypeSymbol type, bool includeGeneric = true) | |
| } | ||
| var name = includeGeneric ? type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat) : type.Name; | ||
| if (allSymbols.Contains(type)) | ||
| return $"<a href='#{type.GetFullTypeName()}'>{System.Web.HttpUtility.HtmlEncode(name)}</a>"; | ||
| return $"<a class='type' href='#{type.GetFullTypeName()}'>{System.Web.HttpUtility.HtmlEncode(name)}</a>"; | ||
| else | ||
| return Briefify(type, name); | ||
| } | ||
|
|
||
| private static string AccessorToString(Accessibility a) | ||
| { | ||
| string format = "<span class='keyword'>{0}</span>"; | ||
|
|
||
| switch(a) | ||
| { | ||
| case Accessibility.Public: | ||
| return "public"; | ||
| return string.Format(format, "public"); | ||
| case Accessibility.Private: | ||
| return "private"; | ||
| return string.Format(format, "private"); | ||
| case Accessibility.Internal: | ||
| return "internal"; | ||
| return string.Format(format, "internal"); | ||
| case Accessibility.Protected: | ||
| return "protected"; | ||
| return string.Format(format, "protected"); | ||
| case Accessibility.ProtectedOrInternal: | ||
| return GeneratorSettings.ShowInternalMembers ? "protected internal" : "protected"; | ||
| return string.Format(format, GeneratorSettings.ShowInternalMembers ? "protected internal" : "protected"); | ||
| case Accessibility.ProtectedAndInternal: | ||
| return "private protected"; | ||
| return string.Format(format, "private protected"); | ||
| default: | ||
| return string.Empty; | ||
| } | ||
|
|
@@ -363,7 +370,7 @@ private string FormatMember(ISymbol member) | |
| { | ||
| name += AccessorToString(p.GetMethod.DeclaredAccessibility) + " "; | ||
| } | ||
| name += "get; "; | ||
| name += "<span class='keyword'>get</span>; "; | ||
| } | ||
| if (p.SetMethod != null && ((p.SetMethod.DeclaredAccessibility == Accessibility.Public || p.SetMethod.DeclaredAccessibility == Accessibility.Protected || p.SetMethod.DeclaredAccessibility == Accessibility.ProtectedOrInternal) || | ||
| (GeneratorSettings.ShowInternalMembers && p.SetMethod.DeclaredAccessibility == Accessibility.Internal || p.SetMethod.DeclaredAccessibility == Accessibility.ProtectedAndInternal) || | ||
|
|
@@ -373,7 +380,7 @@ private string FormatMember(ISymbol member) | |
| { | ||
| name += AccessorToString(p.SetMethod.DeclaredAccessibility) + " "; | ||
| } | ||
| name += "set; "; | ||
| name += "<span class='keyword'>set</span>; "; | ||
| } | ||
|
|
||
| name += "} : " + FormatType(p.Type); | ||
|
|
@@ -382,11 +389,13 @@ private string FormatMember(ISymbol member) | |
| { | ||
| if (m.TypeArguments.Any()) | ||
| { | ||
| name += System.Web.HttpUtility.HtmlEncode("<" + string.Join(", ", m.TypeArguments.Select(t => t.ToDisplayString())) + ">"); | ||
| name += System.Web.HttpUtility.HtmlEncode("<") | ||
| + string.Join(", ", m.TypeArguments.Select(t => $"<span class='type'>{t.ToDisplayString()}</span>")) | ||
| + System.Web.HttpUtility.HtmlEncode(">"); | ||
| } | ||
|
|
||
| name += "("; | ||
| name += string.Join(", ", m.Parameters.Select(pr => FormatType(pr.Type) + " " + Briefify(pr) + (pr.HasExplicitDefaultValue ? (" = " + (pr.ExplicitDefaultValue?.ToString() ?? "null")) : ""))); | ||
| name += string.Join(", ", m.Parameters.Select(pr => FormatType(pr.Type) + " " + Briefify(pr) + (pr.HasExplicitDefaultValue ? (" = " + (pr.ExplicitDefaultValue?.ToString() ?? "<span class='keyword'>null</span>")) : ""))); | ||
| name += ")"; | ||
| if (!m.ReturnsVoid) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,26 +5,30 @@ | |
| <meta charset="utf-8" /> | ||
| <title>OMD</title> | ||
| <style> | ||
| body { padding: 0; } | ||
| body { padding: 0; font-family: "Segoe UI", Helvetica, Arial, sans-serif } | ||
| ul { list-style:none; padding-left: 20px; margin-right:10px; } | ||
| .objectBox { border-style:solid; border-width:1px; margin:10px; float:left; border-radius:10px;} | ||
| .objectBox > .header { font-size:10px; padding:10px; border-radius:10px 10px 0 0;} | ||
| .objectBox > .header > .code { font-size:10px; } | ||
| .objectBox > .header.noMembers { border-radius: 10px; } | ||
| .objectBox > .header > span { font-size:20px; } | ||
| .objectBox > .header > span:not(.code) { font-size:20px; } | ||
| .code { font-family: "Consolas", "Courier New", "Courier", monospace; font-size: 14px; } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer a sans-serif style font here as default |
||
| .class { background: linear-gradient(to right, rgb(211, 220, 239), white); } | ||
| .struct { background: linear-gradient(to right, rgb(211, 220, 239), white); } | ||
| .enum { background: linear-gradient(to right, rgb(221, 214, 239), white); } | ||
| .interface { background: linear-gradient(to right, rgb(231, 240, 220), white); } | ||
| .delegate { background: linear-gradient(to right, rgb(237, 218, 220), white); } | ||
| .keyword { color: blue; } | ||
| .type { color: #2C91AF; } | ||
|
|
||
| .members > h4 { font-size:14px; background:rgb(240, 242, 239); display:block; padding:5px; margin:0; font-weight:normal; } | ||
| .typeExisting { border-color:#ddd; } | ||
| .typeRemoved { border-color:red; border-style:dashed; border-width:3px; text-decoration: line-through;border-style:dashed; border-width:3px; } | ||
| .memberRemoved { color: red; text-decoration: line-through; } | ||
|
|
||
| .static { background-image: url(data:image/gif;base64,R0lGODlhDQAKAPcPAOhfF/nXxfbDqOx9Q/GbbvOvi/Klffvh0+6HUe+RYOlpJutzNPjNtvzr4v718AAAAAAAAAAAAA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5PjxgYABIgEQELjwQYOTDyUOMCAgQEiHElMeLCCw4MMFBCIGBAA7); background-repeat: no-repeat; background-position: left center; margin-left:-35px; padding-left:35px; } | ||
| .static { background-image: url(data:image/gif;base64,R0lGODlhDQAKAPcPAOhfF/nXxfbDqOx9Q/GbbvOvi/Klffvh0+6HUe+RYOlpJutzNPjNtvzr4v718AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAA8ALAAAAAANAAoAAAhMAB8IDJBAAYCDBxccEGgAocODAQQ+LBCAQYEBER88RCDAgcCPBB4e5PjxgYABIgEQELjwQYOTDyUOMCAgQEiHElMeLCCw4MMFBCIGBAA7); background-repeat: no-repeat; background-position: left 3px; margin-left:-35px; padding-left:35px; } | ||
|
|
||
| .members li { background-repeat: no-repeat; padding-left:20px; background-position: left center; } | ||
| .members li { background-repeat: no-repeat; padding-left:20px; background-position: left 2px; } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch on the vertical alignment! 👍 |
||
| .pubevent { background-image: url(data:image/gif;base64,R0lGODlhCgAMANU3APzksP7y2ebl4u+9kOvj1Pf39vDGkunm4V5HMIyCXOLd1a6XYN7YzpeDU+fQiZVvH+qwf6eUYFhTS8/Bofbv0/jz3vv6+Nva1Ih6SuilfObPienl36CLRsC5pKyXamtPKWpiSN3Mjp94HciyeIxoIumqfuXg1+mggefj3q2CIPXAbsq+n93FguXh2vn048a4kPLMlHlsRu7Cif/kf/rRdufIWeGHgv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADcALAAAAAAKAAwAAAZXwNvNFXJoWCPPRFgDzGQZm6Rwq9QCtJINJGACaBAbpnujXFU2zkV4q81msMHJhtjcFo1Ygmb7mNgWL3wkDGw3K3wPLYYEBjYiCoY3HQMpKJI3BBEHmDdBADs=); padding-left:20px; background-position: left center; } | ||
| .protevent { background-image: url(data:image/gif;base64,R0lGODlhEAAQAOZPAOGHgt28WvjYaOfIWaOALvrRdtO4f+7AL//kf8ipX49uIu3iyubl4vDr3//PMvzksO+9kP7y2a6XYN3Mjufj3umggaaFOJVvH93FgvDo1uTbxu7blv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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAFgALAAAAAAQABAAAAehgFiCg4SFhoMiHi0oSU02U4dYAgwJOjQAPRSHKgIPAzgAHBKRkwMWABWjhyGdGAA3MpqHAgkJKT5AAEIaggsHEEQENT9SIwMARUuDBwEEDVBMWBvHJyyDCzkvggQ7R8dXSIQKQR0GBitDLgAgJYUGAfABExFPSkaGJgEF+xMQPBmHCARAUAABAgckIjU4ACMCFQdRrERSMONClRgfnCiIFAgAOw==); } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather we don't monospace it all.