/// <summary> /// Creates a ul tag with list items for each resource, linking /// to the section containing documentation for each resource /// using the resource name as an id/fragment. /// </summary> /// <param name="descriptions"></param> /// <returns></returns> public virtual XElement BuildNav(SimpleApiDocumentation descriptions) { var toc = new XElement("ul", new XAttribute("class", "nav nav-list span4")); toc.Add(new XElement("li", new XAttribute("class", "nav-header"), new XText("Resources"))); foreach (var group in descriptions.Resources) { toc.Add(new XElement("li", new XElement("a", new XAttribute("href", "#" + @group.Name), new XText(@group.Name)))); } return(new XElement("div", new XAttribute("class", "row"), toc)); }
/// <summary> /// If <see cref="SimpleApiDocumentation.TopLevelDocumentation"/> has been provided, /// simply returns that markup. Otherwise builds an h1 element containing the /// text from <see cref="HtmlMediaTypeFormatter.Title"/> if available, or placeholder /// text otherwise. /// </summary> public virtual IEnumerable <XNode> BuildTopLevelDocumentation(SimpleApiDocumentation descriptions, SerializationContext context) { if (!string.IsNullOrWhiteSpace(descriptions.TopLevelDocumentation)) { return(ParseDocumentation(descriptions.TopLevelDocumentation)); } var title = context.Title; if (string.IsNullOrEmpty(title)) { title = "Api Documentation"; } return(new[] { new XElement("h1", new XText(title)) }); }
public virtual SimpleApiDocumentation GetApiDocumentation() { var apiExplorer = Configuration.Services.GetApiExplorer(); var documentation = new SimpleApiDocumentation(); foreach (var api in apiExplorer.ApiDescriptions) { if (api.Route.IsHiddenFromApiExplorer()) { continue; } var controllerDescriptor = api.ActionDescriptor.ControllerDescriptor; documentation.Add(controllerDescriptor.ControllerName, ConvertApiDescription(api)); documentation[controllerDescriptor.ControllerName].Documentation = DocumentationProvider.GetDocumentation(controllerDescriptor); } return(documentation); }