private int ParseParameter(ref DocumentationComment comment, string line, List <string> lines, int startIndex) { string parameterName = string.Empty; string description = string.Empty; int endIndex = startIndex; parameterName = line.Replace(".PARAMETER", "").Trim(); for (var i = startIndex + 1; i < lines.Count; i++) { if (lines[i].StartsWith(".")) { break; } description += lines[i].Trim() + "\r\n"; endIndex++; } comment.Parameters.Add(parameterName, description.Trim()); return(endIndex); }
private int ParseParameter(ref DocumentationComment comment, string line, List<string> lines, int startIndex) { string parameterName = string.Empty; string description = string.Empty; int endIndex = startIndex; parameterName = line.Replace(".PARAMETER", "").Trim(); for (var i = startIndex + 1; i < lines.Count; i++) { if (lines[i].StartsWith(".")) break; description += lines[i].Trim() + "\r\n"; endIndex++; } comment.Parameters.Add(parameterName, description.Trim()); return endIndex; }
private DocumentationComment ParseComment(List <string> lines) { var currentType = DocumentationType.None; var previousType = DocumentationType.None; var content = new StringBuilder(); var documentation = new DocumentationComment(); //foreach (var line in lines) for (var i = 0; i < lines.Count; i++) { var line = lines[i]; if (line.StartsWith(".SYNOPSIS")) { currentType = DocumentationType.Synopsis; continue; } else if (line.StartsWith(".DESCRIPTION")) { currentType = DocumentationType.Description; continue; } else if (line.StartsWith(".PARAMETER")) { currentType = DocumentationType.Parameter; } else if (line.StartsWith(".NOTES")) { currentType = DocumentationType.Notes; continue; } else if (line.StartsWith("Author:")) { currentType = DocumentationType.Author; } if (currentType != previousType) { switch (previousType) { case DocumentationType.Description: documentation.Description = content.ToString(); content.Clear(); break; case DocumentationType.Notes: documentation.Notes = content.ToString(); content.Clear(); break; case DocumentationType.Synopsis: documentation.Synopsis = content.ToString(); content.Clear(); break; } } switch (currentType) { case DocumentationType.Author: documentation.Author = ParseAuthor(line); break; case DocumentationType.Notes: case DocumentationType.Synopsis: case DocumentationType.Description: content.AppendLine(line.Trim()); break; case DocumentationType.Parameter: i = ParseParameter(ref documentation, line, lines, i); currentType = DocumentationType.None; break; } previousType = currentType; } if (content.Length > 0) { switch (currentType) { case DocumentationType.Description: documentation.Description = content.ToString(); break; case DocumentationType.Notes: documentation.Notes = content.ToString(); break; case DocumentationType.Synopsis: documentation.Synopsis = content.ToString(); break; } } return(documentation); }
private DocumentationComment ParseComment(List<string> lines) { var currentType = DocumentationType.None; var previousType = DocumentationType.None; var content = new StringBuilder(); var documentation = new DocumentationComment(); //foreach (var line in lines) for (var i = 0; i < lines.Count; i++) { var line = lines[i]; if (line.StartsWith(".SYNOPSIS")) { currentType = DocumentationType.Synopsis; continue; } else if (line.StartsWith(".DESCRIPTION")) { currentType = DocumentationType.Description; continue; } else if (line.StartsWith(".PARAMETER")) { currentType = DocumentationType.Parameter; } else if (line.StartsWith(".NOTES")) { currentType = DocumentationType.Notes; continue; } else if (line.StartsWith("Author:")) { currentType = DocumentationType.Author; } if (currentType != previousType) { switch (previousType) { case DocumentationType.Description: documentation.Description = content.ToString(); content.Clear(); break; case DocumentationType.Notes: documentation.Notes = content.ToString(); content.Clear(); break; case DocumentationType.Synopsis: documentation.Synopsis = content.ToString(); content.Clear(); break; } } switch (currentType) { case DocumentationType.Author: documentation.Author = ParseAuthor(line); break; case DocumentationType.Notes: case DocumentationType.Synopsis: case DocumentationType.Description: content.AppendLine(line.Trim()); break; case DocumentationType.Parameter: i = ParseParameter(ref documentation, line, lines, i); currentType = DocumentationType.None; break; } previousType = currentType; } if (content.Length > 0) { switch(currentType) { case DocumentationType.Description: documentation.Description = content.ToString(); break; case DocumentationType.Notes: documentation.Notes = content.ToString(); break; case DocumentationType.Synopsis: documentation.Synopsis = content.ToString(); break; } } return documentation; }