/// <summary> /// Gets the Documentation as Text /// </summary> /// <param name="type">Type of the documentation</param> /// <returns>Formated documentation</returns> public string GetDocumentation(DocumentationType type, int maxLength) { if (type == DocumentationType.Description) { return(GetDocumentationDescription().GetDocumentation(maxLength)); } else if (type == DocumentationType.Tags) { return(GetTagDocumentationParameters().GetDocumentation(maxLength, true)); } else if (type == DocumentationType.Attributes) { return(GetAttributesDocumentationParameters().GetDocumentation(maxLength, false)); } else if (type == DocumentationType.StatusCodes) { Documentation codes = GetDocumentationStatusCodes(); Documentation prolog = this.GetStatusCodeProlog(codes.Title, codes.SubTitle); Documentation modes = this.GetStatusModes(codes.Title, codes.SubTitle); codes.Title = string.Empty; codes.SubTitle = string.Empty; prolog.Title = string.Empty; modes.Title = string.Empty; modes.SubTitle = string.Empty; string part1 = prolog.GetDocumentation(maxLength, false); string part2 = codes.GetDocumentation(maxLength, false); string part3 = modes.GetDocumentation(maxLength, false); return(part1 + Documentation.NL + part2 + Documentation.NL + part3); } else { return(""); } }
/// <summary> /// Saves the whole documentation as markdown text /// </summary> /// <param name="fileName">Filename of the markdown file</param> public void SaveMarkdown(string fileName) { StringBuilder sb = new StringBuilder(); sb.Append(GetDocumentationDescription().GetDocumentation(0, false, true, true, false)); sb.Append(Documentation.NL); sb.Append(GetTagDocumentationParameters().GetDocumentation(0, true, false, true, true)); sb.Append(Documentation.NL); sb.Append(GetAttributesDocumentationParameters().GetDocumentation(0, false, false, true, true)); sb.Append(Documentation.NL); Documentation codes = GetDocumentationStatusCodes(); Documentation prolog = this.GetStatusCodeProlog(codes.Title, codes.SubTitle); Documentation modes = this.GetStatusModes(codes.Title, codes.SubTitle); codes.Title = string.Empty; codes.SubTitle = string.Empty; prolog.Title = string.Empty; modes.Title = string.Empty; modes.SubTitle = string.Empty; string part1 = prolog.GetDocumentation(0, false, true); string part2 = codes.GetDocumentation(0, false, true); string part3 = modes.GetDocumentation(0, false, true); sb.Append(part1); sb.Append(Documentation.NL); sb.Append(part2); sb.Append(Documentation.NL); sb.Append(part3); sb.Append(Documentation.NL); sb.Append(Documentation.NL); sb.Append("## Example configuration"); sb.Append(Documentation.NL); sb.Append(Documentation.NL); sb.Append("```xml"); sb.Append(Documentation.NL); string demo = Task.CreateDemoFile(this.Type); sb.Append(demo); sb.Append(Documentation.NL); sb.Append("```"); try { FileStream fs = new FileStream(fileName, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.Write(sb.ToString()); sw.Flush(); fs.Flush(); fs.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } }