private void Process_ApiMethodObj(ApiControllerObj controllerItem, XmlCommentHelper xmlCommentHelper, string dateTimeString, string subControllerFolderPath, string subControllerFolderPath_Old) { foreach (ApiMethodObj methodItem in controllerItem.MethodArray) { string methodTypes = GetMethodType(methodItem.SupportedHttpMethodArray); bool hasPostApi = methodTypes.Contains("POST"); StringBuilder sbr_mdFileForMethod = BasicApiTemplate.GetTemplateStringBuilder(hasPostApi, false, dateTimeString, this.VersionInfo, this.ImagePath); sbr_mdFileForMethod.Replace(TemplateConsts.PLACEHOLDER_API_NAME, methodItem.MethodName); sbr_mdFileForMethod.Replace(TemplateConsts.PLACEHOLDER_CONTROLLER_NAME, methodItem.ControllerName); MethodXmlElement xmlMethodObj = null; if (xmlCommentHelper != null) { xmlMethodObj = xmlCommentHelper.GetMemberDefinition(methodItem); } if (xmlMethodObj == null || string.IsNullOrWhiteSpace(xmlMethodObj.Summary) || (string.IsNullOrWhiteSpace(xmlMethodObj.Returns) && string.IsNullOrWhiteSpace(xmlMethodObj.Returns_WithSuccess) && string.IsNullOrWhiteSpace(xmlMethodObj.Returns_WithFail)) ) { methodItem.IsCommentingMissing = true; } sbr_mdFileForMethod.Replace(TemplateConsts.PLACEHOLDER_ADDITIONAL_INFO, xmlMethodObj?.Summary); sbr_mdFileForMethod.Replace(TemplateConsts.PLACEHOLDER_URL, $"/api/{ methodItem.ControllerName.Replace("Controller", "")}/{methodItem.MethodName}"); sbr_mdFileForMethod.Replace(TemplateConsts.PLACEHOLDER_METHOD_TYPE, methodTypes); this.SetTemplateData_MethodParameters(methodItem, xmlMethodObj, ref sbr_mdFileForMethod); this.SetTemplateData_Example(methodItem, xmlMethodObj, ref sbr_mdFileForMethod); this.SetTemplateData_ReturnType(methodItem, xmlMethodObj, ref sbr_mdFileForMethod); string fileNameOnly = this.GetValidFileName(methodItem.MethodName); string fullMdFileAndPath = ""; methodItem.MDFileNameWithoutExtension = this.CreateMD_File_UsingOldNotes_IfApplicable(fileNameOnly, subControllerFolderPath, subControllerFolderPath_Old, sbr_mdFileForMethod, out fullMdFileAndPath); MdToHtml.GenerateHtmlFile(fullMdFileAndPath); } }
private void GenerateMD(List <ApiControllerObj> apiControllerList, string savePath, string xmlPath, string oldMdPathHint) { string dateTimeString = DateTime.Now.ToString("yyyy/MM/dd H:mm:ss"); XmlCommentHelper xmlCommentHelper = null;//isXmlExist = false; if (!string.IsNullOrEmpty(xmlPath) && File.Exists(xmlPath)) { xmlCommentHelper = new XmlCommentHelper(xmlPath); } foreach (ApiControllerObj controllerItem in apiControllerList) { var folderName = controllerItem.GetFolderName(); string subControllerFolderPath = Path.Combine(savePath, folderName); string subControllerFolderPath_Old = null; if (!Directory.Exists(subControllerFolderPath)) { Directory.CreateDirectory(subControllerFolderPath); } if (oldMdPathHint != null) { subControllerFolderPath_Old = Path.Combine(oldMdPathHint, folderName); if (!Directory.Exists(subControllerFolderPath_Old)) { subControllerFolderPath_Old = null; } } this.Process_ApiMethodObj(controllerItem, xmlCommentHelper, dateTimeString, subControllerFolderPath, subControllerFolderPath_Old); } string assemblyName = Path.GetFileName(DllFullFilePath); MdIndexGenerator gen = new MdIndexGenerator(savePath, apiControllerList, VersionInfo, assemblyName, this.ImagePath, true, "html"); MdToHtml.GenerateHtmlFile(gen.IndexFilePathAndName); }