In my source code documentation I often use:
Get a <see cref="Quote"/> for the specified <see cref="apiOrder"/> object.
And this translates nicely into the below string in the XmlDocument.xml, which contains the compiled web api help pages.
Get a <see cref="T:Supertext.API.POCO.Quote"/> for the specified <see cref="!:apiOrder"/> object.
But for some reasons, all these references are not being displayed. What we get is this:
Get a for the specified object
We found a few sources, but nothing seems to work. Does not help:
Web Api Help Page- don't escape html in xml documentation
Outdated:
http://thesoftwaredudeblog.wordpress.com/2014/01/04/using-microsoft-asp-net-web-api-2-help-page-part-2/
Any ideas?
Each API has a link to a page with more detailed information, including example request and response bodies. You can add help pages to an existing Web API project by using NuGet Package Manager. This option is useful you start from a different project template than the "Web API" template.
Click on New Project and select the MVC4 application. Now select the Web API application from the template. Now we see the Areas folder in Solution Explorer. The Areas folder contains the help page folder. Now we execute the application. When we execute the application we will see the API help page Link.
This update integrates help pages into the Web API project template. Next, create a new ASP.NET MVC 4 project and select the Web API project template. The project template creates an example API controller named ValuesController. The template also creates the API help pages.
The XML file can be processed to format this word in some distinct way, such as with a bold or italic font. cref = " member ": A reference to an exception that is available from the current compilation environment.
In the WebAPI 2 Help, there is a class called, XmlDocumentationProvider
. In this class there is a method named, GetTagValue
which handles the Summary and Returns tags. There is also a method named GetDocumentation
(there are multiples, but it is the one with the HttpParameterDescriptor
parameter) which handles the Param tags.
I wrote a function that uses a RegEx to find all "See Cref"s and replace them with the last object name found.
The RegEx:
private static Regex SeeCodeReferenceRegEx = new Regex("<see cref=\\\"\\w:([\\w]+\\.)*(\\w+)\\\" */>", RegexOptions.Compiled);
The function:
private static string CleanValue(string value)
{
value = value.Trim();
var matches = SeeCodeReferenceRegEx.Matches(value);
foreach (Match match in matches)
value = value.Replace(match.Groups[0].Value, match.Groups[2].Value);
return value;
}
In GetTagValue
, replace:
return node.Value.Trim();
with:
return CleanValue(node.InnerXml);
In GetDocumentation
replace:
return parameterNode.Value.Trim();
with:
return CleanValue(parameterNode.InnerXml);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With