网络API帮助页面 - 不要逃避XML文档中的HTML [英] Web Api Help Page- don't escape html in xml documentation
问题描述
我使用的XML文档为我的ASP.NET Web API帮助页面的如下所示。
我想知道如果有一种方法可以包括这样它就会在网页上呈现的意见HTML,而不是它被删除/忽略/逃过一劫。
具体来说,我正在寻找一种方法来创建一个换行符,但能够创建项目列表等,将是伟大的!
I am using XML Documentation for my ASP.NET Web API Help Page as shown here.
I would like to know if there is a way to include html in the comments such that it will be rendered on the web page, instead of it being removed/ignored/escaped.
Specifically, I am looking for a way to create a newline, but being able to create bulleted lists, etc. would be great!
防爆/我希望能够做这样的事:
Ex/ I would like to be able to do something like this:
/// <summary>
/// CRUD operations for SalesDocument<br/>
/// This is a new line
/// </summary>
[RoutePrefix("api/SalesDocument")]
public partial class SalesDocumentController : ApiController
和有它显示帮助页面这样的:
And have it show on the help page like this:
CRUD operations for SalesDocument
This is a new line.
取而代之的是:(在这种情况下,&LT; BR /&GT;
被莫名其妙地删除 - 如果我尝试使用&LT; P&GT;
标签,他们刚刚逃脱)
Instead of this: (in this case, <br/>
gets removed somehow - if I try using <p>
tags, they are just escaped)
CRUD operations for SalesDocument This is a new line.
*我已经尝试了&LT;对方式&gt;
标记多个职位提示的建议,但这不是我的帮助页面上工作。
*I have already tried the <para>
tag as suggested by multiple posts for tooltips, but this does not work on my help page.
任何建议都大大AP preciated!
Any suggestions are greatly appreciated!
推荐答案
在安装 XmlDocumentationProvider.cs
文件的区\\ HelpPage
,你可以找一个名为GetTagValue的方法......在这里修改从'node.Value.Trim()的返回值来node.InnerXml。
In the installed XmlDocumentationProvider.cs
file at Areas\HelpPage
, you can look for a method called 'GetTagValue'...here modify the return value from 'node.Value.Trim()' to 'node.InnerXml'.
private static string GetTagValue(XPathNavigator parentNode, string tagName)
{
if (parentNode != null)
{
XPathNavigator node = parentNode.SelectSingleNode(tagName);
if (node != null)
{
return node.InnerXml;
}
}
return null;
}
现在打开安装文件区\\ HelpPage \\意见\\帮助\\ DisplayTemplates \\ ApiGroup.cshtml
并修改下面一行:
Now open the installed file Areas\HelpPage\Views\Help\DisplayTemplates\ApiGroup.cshtml
and modify the following line from:
<p>@controllerDocumentation</p>
到
<p>@Html.Raw(controllerDocumentation)</p>
这篇关于网络API帮助页面 - 不要逃避XML文档中的HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!