public void Humanize_TrimsWhiteSpaceFromStartAndEnd() { var input = @" A line of text "; var output = XmlCommentsTextHelper.Humanize(input); Assert.Equal("A line of text", output); }
private static void ApplyResponseComments(Operation operation, XPathNavigator methodNode) { var responseNodes = methodNode.Select(ResponsesXPath); while (responseNodes.MoveNext()) { var responseNode = responseNodes.Current; var code = responseNode.GetAttribute("code", ""); var response = operation.Responses.ContainsKey(code) ? operation.Responses[code] : operation.Responses[code] = new Response(); response.Description = XmlCommentsTextHelper.Humanize(responseNode.InnerXml); } }
private void ApplyPropertyComments(Schema propertySchema, PropertyInfo propertyInfo) { var commentId = XmlCommentsIdHelper.GetCommentIdForProperty(propertyInfo); var propertyNode = _xmlNavigator.SelectSingleNode(string.Format(MemberXPath, commentId)); if (propertyNode == null) { return; } var summaryNode = propertyNode.SelectSingleNode(SummaryTag); if (summaryNode != null) { propertySchema.Description = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml); } }
public void Humanize_TrimsCommonSpaceTabIndentations() { // Common indentation seen in visual studio: {space}{tab} var input = @" ## Heading 1 A line of text " ; var output = XmlCommentsTextHelper.Humanize(input); Assert.Equal( @"## Heading 1 A line of text", output ); }
public void Humanize_DoesNotTrimInconsistentIndentations() { var input = @" Space Indentation Line 1 Space Indentation Line 2 Misplaced Tab Indentation Space Indentation Line 4 "; var output = XmlCommentsTextHelper.Humanize(input); Assert.Equal( @" Space Indentation Line 1 Space Indentation Line 2 Misplaced Tab Indentation Space Indentation Line 4", output); }
private static void ApplyParamComments(Operation operation, XPathNavigator methodNode) { if (operation.Parameters == null) { return; } var paramNodes = methodNode.Select(ParameterTag); while (paramNodes.MoveNext()) { var paramNode = paramNodes.Current; var parameter = operation.Parameters .SingleOrDefault(param => param.Name == paramNode.GetAttribute("name", "")); if (parameter != null) { parameter.Description = XmlCommentsTextHelper.Humanize(paramNode.InnerXml); } } }
public void Apply(Schema schema, SchemaFilterContext context) { var jsonObjectContract = context.JsonContract as JsonObjectContract; if (jsonObjectContract == null) { return; } var commentId = XmlCommentsIdHelper.GetCommentIdForType(context.SystemType); var typeNode = _xmlNavigator.SelectSingleNode(string.Format(MemberXPath, commentId)); if (typeNode != null) { var summaryNode = typeNode.SelectSingleNode(SummaryTag); if (summaryNode != null) { schema.Description = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml); } } if (schema.Properties == null) { return; } foreach (var entry in schema.Properties) { var jsonProperty = jsonObjectContract.Properties[entry.Key]; if (jsonProperty == null) { continue; } var propertyInfo = jsonProperty.PropertyInfo(); if (propertyInfo != null) { ApplyPropertyComments(entry.Value, propertyInfo); } } }
public void Humanize_TrimsCommonSpaceIndentations() { var input = @" ## Heading 1 * list item 1 ## Heading 2 POST /api/test { ""prop1"": { ""name"": ""value"" } } "; var output = XmlCommentsTextHelper.Humanize(input); Assert.Equal( @"## Heading 1 * list item 1 ## Heading 2 POST /api/test { ""prop1"": { ""name"": ""value"" } }" , output ); }