@@ -13,33 +13,45 @@ public class PlainTextRenderer
13
13
/// Converts an XML documentation node to the plain text.
14
14
/// </summary>
15
15
/// <param name="documentation"></param>
16
+ /// <param name="forceSingleLine"></param>
17
+ /// <param name="useShortTypeNames"></param>
16
18
/// <returns></returns>
17
- public static string Render ( MemberDocumentation ? documentation )
19
+ public static string Render (
20
+ MemberDocumentation ? documentation ,
21
+ bool forceSingleLine = false ,
22
+ bool useShortTypeNames = true )
18
23
{
19
24
if ( documentation == null )
20
25
{
21
26
return string . Empty ;
22
27
}
23
28
24
- return new PlainTextRenderer ( documentation ) . Render ( ) ;
29
+ return new PlainTextRenderer ( documentation , new RendererOptions
30
+ {
31
+ ForceSingleLine = forceSingleLine ,
32
+ UseShortTypeNames = useShortTypeNames
33
+ } ) . Render ( ) ;
25
34
}
26
35
27
36
/// <summary>
28
37
/// The documentation instance to be rendered by this renderer.
29
38
/// This field is initialized in the constructor and remains readonly afterward.
30
39
/// </summary>
31
- protected readonly MemberDocumentation Documentation ;
40
+ private readonly MemberDocumentation _documentation ;
41
+
42
+ private readonly RendererOptions _options ;
32
43
33
- protected PlainTextRenderer ( MemberDocumentation documentation )
44
+ private PlainTextRenderer ( MemberDocumentation documentation , RendererOptions rendererOptions )
34
45
{
35
- Documentation = documentation ;
46
+ _options = rendererOptions ;
47
+ _documentation = documentation ;
36
48
}
37
49
38
50
/// <summary>
39
51
/// Renders the current documentation to plain text.
40
52
/// </summary>
41
53
/// <returns>A normalized plain text representation of the documentation.</returns>
42
- protected string Render ( ) => Normalize ( Render ( Documentation . Node ) ) ;
54
+ private string Render ( ) => Normalize ( Render ( _documentation . Node ) ) ;
43
55
44
56
/// <summary>
45
57
/// Renders the content of an XML node to plain text.
@@ -70,9 +82,9 @@ private string Normalize(string input)
70
82
. Where ( o => ! string . IsNullOrWhiteSpace ( o ) )
71
83
. ToList ( ) ;
72
84
73
- var result = string . Join ( " \n ", lines ) ;
85
+ var separator = _options . ForceSingleLine ? " " : " \n ";
74
86
75
- return result ;
87
+ return string . Join ( separator , lines ) ;
76
88
}
77
89
78
90
/// <summary>
@@ -102,9 +114,9 @@ private string RenderXmlElement(XmlElement element)
102
114
/// </summary>
103
115
/// <param name="element"></param>
104
116
/// <returns></returns>
105
- protected virtual string RenderReference ( XmlElement element )
117
+ private string RenderReference ( XmlElement element )
106
118
{
107
- var documentationReference = Documentation . GetReference ( element ) ;
119
+ var documentationReference = _documentation . GetReference ( element ) ;
108
120
109
121
if ( documentationReference == null )
110
122
{
@@ -134,18 +146,28 @@ private string RenderSimpleDocumentationReference(DocumentationReference documen
134
146
135
147
if ( cref . Prefix is "T:" )
136
148
{
137
- return cref . ShortType ;
149
+ if ( _options . UseShortTypeNames )
150
+ {
151
+ return cref . ShortType ;
152
+ }
153
+
154
+ return cref . Type ;
138
155
}
139
156
140
157
if ( cref . Prefix is "M:" or "P:" or "F:" )
141
158
{
142
- return $ "{ cref . ShortType } .{ cref . Member } ";
159
+ if ( _options . UseShortTypeNames )
160
+ {
161
+ return $ "{ cref . ShortType } .{ cref . Member } ";
162
+ }
163
+
164
+ return $ "{ cref . Type } .{ cref . Member } ";
143
165
}
144
166
145
167
return string . Empty ;
146
168
}
147
169
148
- private static string RenderDocumentationReference ( DocumentationReference documentationReference )
170
+ private string RenderDocumentationReference ( DocumentationReference documentationReference )
149
171
{
150
172
if ( documentationReference . Target == null )
151
173
{
@@ -167,10 +189,6 @@ private static string RenderDocumentationReference(DocumentationReference docume
167
189
} ;
168
190
169
191
return text ;
170
-
171
- // var renderer = new PlainTextRenderer(documentationReference.Target);
172
- //
173
- // return renderer.Render();
174
192
}
175
193
176
194
/// <summary>
0 commit comments