- In the file HelpPage/App_Start/HelpPageConfig.cs uncomment the following line:
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
- Open up the project properties for you Web API project and under the build tab enable the Xml documentation file (set the file path to App_Data\XmlDocument.XML)
This gives you the basic setup to get the XML comments outputting to your Help Pages. But how about making it look sexier? For example, let's say I had the following XML comment I wanted to display:
/// <summary>
/// Get a list of products within the given product kit.
/// </summary>
/// <param name="id">Id of the parent product kit</param>
/// <returns>This api method returns a list of products in JSON format. To get a list of products in XML format add the following HTTP header:<br />
/// <br />
/// Accept: application/xml<br />
/// </returns>
This will strip out the HTML tags and output on a single line like this:

To allow breaks in our comments we need to make a couple of changes. Firstly, we need to change how our XmlDocumentationProvider retrieves the tag value from the XML comment. Find the GetTagValue function in this class and change the line as follows:
private static string GetTagValue(XPathNavigator parentNode, string tagName)
{
if (parentNode != null)
{
XPathNavigator node = parentNode.SelectSingleNode(tagName);
if (node != null)
{
return node.InnerXml;
}
}
return null;
}
Next, we need to modify all the display templates that display these tags to show the raw value instead. The Display Template you will need to modify are HelpPages/Views/Help/DisplayTemplates/ApiGroup.cshtml and HelpPageApiModel.cshtml located at. Find any of the following lines:
<p>@controllerDocumentation</p>
<p>api.Documentation</p>
<p>@description.ResponseDescription.Documentation</p>
And replace them with the equivalent as per this code:
<p>@Html.Raw(controllerDocumentation)</p>
<p>@Html.Raw(api.Documentation)</p>
<p>@Html.Raw(description.ResponseDescription.Documentation)</p>
This could cover you for all areas you want to add breaks or html formatting to. For example, our description in the given example should look much better now:

This comment has been removed by the author.
ReplyDeleteCasino Tycoon - Hotel Reviews, Ratings, Photos & Maps
ReplyDeleteCasino Tycoon, 익산 출장샵 Casino Tycoon, 부천 출장안마 Hotel 출장샵 and Tower Casino is a casino 사천 출장마사지 in Las Vegas, Nevada, United States and is open daily 24 태백 출장샵 hours.