@@ -35,8 +35,11 @@ private XmlComment(Compilation compilation, string xml)
35
35
// Transform triple slash comment
36
36
var doc = XDocument . Parse ( xml , LoadOptions . PreserveWhitespace | LoadOptions . SetLineInfo ) ;
37
37
38
- ResolveCrefLink ( compilation , doc , $ "//{ DocumentationCommentXmlNames . SeeAlsoElementName } [@cref]") ;
39
- ResolveCrefLink ( compilation , doc , $ "//{ DocumentationCommentXmlNames . SeeElementName } [@cref]") ;
38
+ ResolveCrefLink ( compilation , doc , DocumentationCommentXmlNames . SeeAlsoElementName ) ;
39
+ ResolveCrefLink ( compilation , doc , DocumentationCommentXmlNames . SeeElementName ) ;
40
+
41
+ ResolveLangKeyword ( doc , DocumentationCommentXmlNames . SeeElementName ) ;
42
+
40
43
// Resolve <list> and <item> tags into bullets
41
44
ResolveListTags ( doc ) ;
42
45
// Resolve <code> tags into code blocks
@@ -171,18 +174,20 @@ private static void ResolveParaTags(XDocument document)
171
174
/// </summary>
172
175
/// <param name="compilation">The compilation to resolve type symbol declarations from.</param>
173
176
/// <param name="node">The target node to process crefs in.</param>
174
- /// <param name="nodeSelector ">The node type to process crefs for, can be `see` or `seealso`.</param>
175
- private static void ResolveCrefLink ( Compilation compilation , XNode node , string nodeSelector )
177
+ /// <param name="elementName ">The node type to process crefs for, can be `see` or `seealso`.</param>
178
+ private static void ResolveCrefLink ( Compilation compilation , XNode node , string elementName )
176
179
{
177
- if ( node == null || string . IsNullOrEmpty ( nodeSelector ) )
180
+ if ( node == null || string . IsNullOrEmpty ( elementName ) )
178
181
{
179
182
return ;
180
183
}
181
184
182
- var nodes = node . XPathSelectElements ( nodeSelector + "[@cref]" ) . ToArray ( ) ;
185
+ var attributeName = DocumentationCommentXmlNames . CrefAttributeName ;
186
+
187
+ var nodes = node . XPathSelectElements ( $ "//{ elementName } [@{ attributeName } ]") . ToArray ( ) ;
183
188
foreach ( var item in nodes )
184
189
{
185
- var cref = item . Attribute ( DocumentationCommentXmlNames . CrefAttributeName ) . Value ;
190
+ var cref = item . Attribute ( attributeName ) . Value ;
186
191
if ( string . IsNullOrEmpty ( cref ) )
187
192
{
188
193
continue ;
@@ -197,6 +202,33 @@ private static void ResolveCrefLink(Compilation compilation, XNode node, string
197
202
}
198
203
}
199
204
205
+ /// <summary>
206
+ /// Resolves the links in the XML documentation into language keywords.
207
+ /// </summary>
208
+ /// <param name="node">The target node to process crefs in.</param>
209
+ /// <param name="elementName">The node type to process langwords for, can be `see` or `seealso`.</param>
210
+ private static void ResolveLangKeyword ( XNode node , string elementName )
211
+ {
212
+ if ( node == null || string . IsNullOrEmpty ( elementName ) )
213
+ {
214
+ return ;
215
+ }
216
+
217
+ var attributeName = DocumentationCommentXmlNames . LangwordAttributeName ;
218
+
219
+ var nodes = node . XPathSelectElements ( $ "//{ elementName } [@{ attributeName } ]") . ToArray ( ) ;
220
+ foreach ( var item in nodes )
221
+ {
222
+ var langword = item . Attribute ( attributeName ) . Value ;
223
+ if ( string . IsNullOrEmpty ( langword ) )
224
+ {
225
+ continue ;
226
+ }
227
+
228
+ item . ReplaceWith ( new XText ( $ "`{ langword } `") ) ;
229
+ }
230
+ }
231
+
200
232
private static IEnumerable < string ? > GetMultipleExampleNodes ( XPathNavigator navigator , string selector )
201
233
{
202
234
var iterator = navigator . Select ( selector ) ;
0 commit comments