private static void Main(string[] args) { long totalStartTime = Environment.TickCount; List <string> options = new List <string>(); List <string> filesNames = new List <string>(); foreach (string arg in args) { if (arg.StartsWith("-")) { if (arg.Length > 1) { options.Add(arg.Substring(1)); } else { PrintUsageAndExit(); } } else { filesNames.Add(arg); } } ProcessOptions(options); if ((docGenOptions & DocumentationGenerationOptions.IncludeInternalMembers) != 0) { Utils.IncludeInternalMembers = true; } if ((docGenOptions & DocumentationGenerationOptions.IncludePrivateMembers) != 0) { Utils.IncludePrivateMembers = true; } if (verboseLevel > 2) { Console.WriteLine("ImmDoc.NET"); string yearString; if (DateTime.Now.Year > 2007) { yearString = "2007 - " + DateTime.Now.Year; } else { yearString = "2007"; } Console.WriteLine("Copyright (C) " + yearString + " Marek \"Immortal\" Stój"); Console.WriteLine(); } List <int> indicesToBeRemoved; if (filesNames.Count == 0) { // add files from the current directory filesNames.AddRange(Directory.GetFiles(Environment.CurrentDirectory, "*.exe")); filesNames.AddRange(Directory.GetFiles(Environment.CurrentDirectory, "*.dll")); filesNames.AddRange(Directory.GetFiles(Environment.CurrentDirectory, "*.xml")); filesNames.AddRange(Directory.GetFiles(Environment.CurrentDirectory, "*.docs")); } else { // remove files with unknown extensions indicesToBeRemoved = new List <int>(); for (int i = 0; i < filesNames.Count; i++) { string fullFileName = filesNames[i]; string ext = Path.GetExtension(fullFileName).ToLower(); if (ext != ".exe" && ext != ".dll" && ext != ".xml" && ext != ".docs") { if (verboseLevel > 2) { Console.WriteLine("Excluded file {0} (unsupported type).", Path.GetFileName(fullFileName)); } indicesToBeRemoved.Add(i); } } Utils.RemoveItems(filesNames, indicesToBeRemoved); } // remove program files indicesToBeRemoved = new List <int>(); string programExeFileNameLower = Path.GetFileName(ASSEMBLY_CODE_BASE).ToLower(); for (int i = 0; i < filesNames.Count; i++) { string fileName = Path.GetFileName(filesNames[i]); if (fileName.ToLower() == programExeFileNameLower) { if (verboseLevel > 2) { Console.WriteLine("Excluded file {0} (program executable).", fileName); } indicesToBeRemoved.Add(i); } } Utils.RemoveItems(filesNames, indicesToBeRemoved); // remove vshost files indicesToBeRemoved = new List <int>(); for (int i = 0; i < filesNames.Count; i++) { string fullFileName = filesNames[i]; if (fullFileName.ToLower().EndsWith(".vshost.exe")) { if (verboseLevel > 2) { Console.WriteLine("Excluded file {0} (file generated by Visual Studio).", Path.GetFileName(fullFileName)); } indicesToBeRemoved.Add(i); } } Utils.RemoveItems(filesNames, indicesToBeRemoved); long processingStartTime = Environment.TickCount; ProcessFilesNames(filesNames, excludedNamespaces); if (verboseLevel > 2) { Console.WriteLine(); } float processingTime = (Environment.TickCount - processingStartTime) / 1000.0f; Documenter documenter = new HTMLDocumenter(assembliesInfo, chmFileNameWithoutExtension); documenter.DirectoryDeleteStarted += documenter_DirectoryDeleteStarted; documenter.DirectoryDeleteFinished += documenter_DirectoryDeleteFinished; documenter.GeneratingStarted += documenter_GeneratingStarted; documenter.GeneratingFinished += documenter_GeneratingFinished; preparationStartTime = Environment.TickCount; bool success = documenter.GenerateDocumentation(outputDirectory, docGenOptions); if (verboseLevel > 2) { Console.WriteLine(); Console.WriteLine("Processing time : {0:F2} s", processingTime); Console.WriteLine("Preparation time : {0:F2} s", preparationTime); Console.WriteLine("Generating time : {0:F2} s", generatingTime); Console.WriteLine("Total time : {0:F2} s", (Environment.TickCount - totalStartTime) / 1000.0f); Console.WriteLine(); Console.WriteLine("Warnings: {0}", Logger.WarningsCount); Console.WriteLine("Errors: {0}", Logger.ErrorsCount); } if (verboseLevel > 1 && Logger.WarningsCount > 0) { if (verboseLevel > 2) { Console.Error.WriteLine(); } Logger.WriteWarnings(Console.Error); } if (!success || Logger.ErrorsCount > 0) { if (verboseLevel > 0 && Logger.ErrorsCount > 0) { if (verboseLevel > 2 || (verboseLevel > 1 && Logger.WarningsCount > 0)) { Console.Error.WriteLine(); } Logger.WriteErrors(Console.Error); } Environment.Exit(1); } else { Environment.Exit(0); } }
private static void Main(string[] args) { long totalStartTime = Environment.TickCount; List <string> options = new List <string>(); List <string> filesNames = new List <string>(); foreach (string arg in args) { if (arg.StartsWith("-")) { if (arg.Length > 1) { options.Add(arg.Substring(1)); } else { PrintUsageAndExit(); } } else { filesNames.Add(arg); } } ProcessOptions(options); if ((docGenOptions & DocumentationGenerationOptions.IncludeInternalMembers) != 0) { Utils.IncludeInternalMembers = true; } if ((docGenOptions & DocumentationGenerationOptions.IncludePrivateMembers) != 0) { Utils.IncludePrivateMembers = true; } if (verboseLevel > 2) { Console.WriteLine("DotDoc"); Console.WriteLine("(Программа Подготовки Документации для сборок .Net Framework)"); Console.WriteLine(); string yearString; if (DateTime.Now.Year > 2007) { yearString = "2016 - " + DateTime.Now.Year; } else { yearString = "2016"; } Console.WriteLine("Copyright (C) " + "2007 - " + DateTime.Now.Year + " Marek \"Immortal\" Stуj"); Console.WriteLine("Copyright (C) " + yearString + " Виталий \"BestCS\" Кулич"); Console.WriteLine(); } List <int> indicesToBeRemoved; if (filesNames.Count == 0) { // add files from the current directory filesNames.AddRange(Directory.GetFiles(Environment.CurrentDirectory, "*.exe")); filesNames.AddRange(Directory.GetFiles(Environment.CurrentDirectory, "*.dll")); filesNames.AddRange(Directory.GetFiles(Environment.CurrentDirectory, "*.xml")); filesNames.AddRange(Directory.GetFiles(Environment.CurrentDirectory, "*.docs")); } else { // remove files with unknown extensions indicesToBeRemoved = new List <int>(); for (int i = 0; i < filesNames.Count; i++) { string fullFileName = filesNames[i]; string ext = Path.GetExtension(fullFileName).ToLower(); if (ext != ".exe" && ext != ".dll" && ext != ".xml" && ext != ".docs") { if (verboseLevel > 2) { Console.WriteLine("Исключён файл {0} (неподдерживаемый тип).", Path.GetFileName(fullFileName)); } indicesToBeRemoved.Add(i); } } Utils.RemoveItems(filesNames, indicesToBeRemoved); } // remove program files indicesToBeRemoved = new List <int>(); string programExeFileNameLower = Path.GetFileName(ASSEMBLY_CODE_BASE).ToLower(); for (int i = 0; i < filesNames.Count; i++) { string fileName = Path.GetFileName(filesNames[i]); if (fileName.ToLower() == programExeFileNameLower || fileName.ToLower() == "bestcs.docnet.dll") { if (verboseLevel > 2) { Console.WriteLine("Исключён файл {0} (исполнимый модуль программы).", fileName); } indicesToBeRemoved.Add(i); } } Utils.RemoveItems(filesNames, indicesToBeRemoved); // remove vshost files indicesToBeRemoved = new List <int>(); for (int i = 0; i < filesNames.Count; i++) { string fullFileName = filesNames[i]; if (fullFileName.ToLower().EndsWith(".vshost.exe")) { if (verboseLevel > 2) { Console.WriteLine("Исключён файл {0} (генерирован Visual Studio).", Path.GetFileName(fullFileName)); } indicesToBeRemoved.Add(i); } } Utils.RemoveItems(filesNames, indicesToBeRemoved); long processingStartTime = Environment.TickCount; ProcessFilesNames(filesNames, excludedNamespaces); if (verboseLevel > 2) { Console.WriteLine(); } float processingTime = (Environment.TickCount - processingStartTime) / 1000.0f; Documenter documenter = new HTMLDocumenter(assembliesInfo, chmFileNameWithoutExtension); documenter.DirectoryDeleteStarted += documenter_DirectoryDeleteStarted; documenter.DirectoryDeleteFinished += documenter_DirectoryDeleteFinished; documenter.GeneratingStarted += documenter_GeneratingStarted; documenter.GeneratingFinished += documenter_GeneratingFinished; preparationStartTime = Environment.TickCount; bool success = documenter.GenerateDocumentation(outputDirectory, docGenOptions); if (verboseLevel > 2) { Console.WriteLine(); Console.WriteLine("Время обработки : {0:F2} s", processingTime); Console.WriteLine("Время подготовки : {0:F2} s", preparationTime); Console.WriteLine("Время генерации : {0:F2} s", generatingTime); Console.WriteLine("Общее время : {0:F2} s", (Environment.TickCount - totalStartTime) / 1000.0f); Console.WriteLine(); Console.WriteLine("Предупреждений: {0}", Logger.WarningsCount); Console.WriteLine("Ошибок: {0}", Logger.ErrorsCount); } if (verboseLevel > 1 && Logger.WarningsCount > 0) { if (verboseLevel > 2) { Console.Error.WriteLine(); } Logger.WriteWarnings(Console.Error); } if (!success || Logger.ErrorsCount > 0) { if (verboseLevel > 0 && Logger.ErrorsCount > 0) { if (verboseLevel > 2 || (verboseLevel > 1 && Logger.WarningsCount > 0)) { Console.Error.WriteLine(); } Logger.WriteErrors(Console.Error); } Environment.Exit(1); } else { Environment.Exit(0); } }