static bool BuildUdn(string XmlDir, string UdnDir, string SitemapDir, string MetadataPath, string StatsPath, List<string> Filters = null) { // Read the metadata MetadataLookup.Load(MetadataPath); // Read the input module index XmlDocument Document = Utility.ReadXmlDocument(Path.Combine(XmlDir, "modules.xml")); // Read the list of modules List<KeyValuePair<string, string>> InputModules = new List<KeyValuePair<string,string>>(); using (XmlNodeList NodeList = Document.SelectNodes("modules/module")) { foreach (XmlNode Node in NodeList) { string Name = Node.Attributes["name"].Value; string Source = Node.Attributes["source"].Value; InputModules.Add(new KeyValuePair<string, string>(Name, Source)); } } #if TEST_INDEX_PAGE // Just create empty modules List<DoxygenModule> Modules = new List<DoxygenModule>(); for (int Idx = 0; Idx < InputModules.Count; Idx++) { Modules.Add(new DoxygenModule(InputModules[Idx].Key, InputModules[Idx].Value)); } #else // Filter the input module list if (Filters != null && Filters.Count > 0) { InputModules = new List<KeyValuePair<string, string>>(InputModules.Where(x => Filters.Exists(y => y.StartsWith(x.Key + "/", StringComparison.InvariantCultureIgnoreCase)))); } // Read all the doxygen modules List<DoxygenModule> Modules = new List<DoxygenModule>(); for(int Idx = 0; Idx < InputModules.Count; Idx++) { Console.WriteLine("Reading module {0}... ({1}/{2})", InputModules[Idx].Key, Idx + 1, InputModules.Count); Modules.Add(DoxygenModule.Read(InputModules[Idx].Key, InputModules[Idx].Value, Path.Combine(XmlDir, InputModules[Idx].Key, "xml"))); } // Now filter all the entities in each module if(Filters != null && Filters.Count > 0) { FilterEntities(Modules, Filters); } #endif // Create the index page, and all the pages below it APIIndex Index = new APIIndex(Modules); // Build a list of pages to output List<APIPage> OutputPages = new List<APIPage>(Index.GatherPages().OrderBy(x => x.LinkPath)); // Dump the output stats if (StatsPath != null) { Console.WriteLine("Writing stats to " + StatsPath + "..."); Stats NewStats = new Stats(OutputPages.OfType<APIMember>()); NewStats.Write(StatsPath); } // Setup the output directory Utility.SafeCreateDirectory(UdnDir); // Build the manifest Console.WriteLine("Writing manifest..."); UdnManifest Manifest = new UdnManifest(Index); Manifest.PrintConflicts(); Manifest.Write(Path.Combine(UdnDir, APIFolder + "\\API.manifest")); // Write all the pages using (Tracker UdnTracker = new Tracker("Writing UDN pages...", OutputPages.Count)) { foreach(int Idx in UdnTracker.Indices) { APIPage Page = OutputPages[Idx]; // Create the output directory string MemberDirectory = Path.Combine(UdnDir, Page.LinkPath); if (!Directory.Exists(MemberDirectory)) { Directory.CreateDirectory(MemberDirectory); } // Write the page Page.WritePage(Manifest, Path.Combine(MemberDirectory, "index.INT.udn")); } } // Write the sitemap contents Console.WriteLine("Writing sitemap contents..."); Index.WriteSitemapContents(Path.Combine(SitemapDir, SitemapContentsFileName)); // Write the sitemap index Console.WriteLine("Writing sitemap index..."); Index.WriteSitemapIndex(Path.Combine(SitemapDir, SitemapIndexFileName)); return true; }
static bool BuildCodeUdn(string EngineDir, string XmlDir, string UdnDir, string SitemapDir, string MetadataPath, string ArchivePath, string SitemapArchivePath, List<string> Filters, BuildActions Actions) { string ApiDir = Path.Combine(UdnDir, "API"); if((Actions & BuildActions.Clean) != 0) { Console.WriteLine("Cleaning '{0}'", ApiDir); Utility.SafeDeleteDirectoryContents(ApiDir, true); Utility.SafeDeleteDirectoryContents(SitemapDir, true); } if ((Actions & BuildActions.Build) != 0) { Directory.CreateDirectory(ApiDir); Directory.CreateDirectory(SitemapDir); // Read the metadata MetadataLookup.Load(MetadataPath); // Read the list of modules List<string> InputModules = new List<string>(File.ReadAllLines(Path.Combine(XmlDir, "modules.txt"))); // Build the doxygen modules List<DoxygenModule> Modules = new List<DoxygenModule>(); foreach (string InputModule in InputModules) { Modules.Add(new DoxygenModule(Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(InputModule)), Path.GetDirectoryName(InputModule))); } // Find all the entities if (!bIndexOnly) { Console.WriteLine("Reading Doxygen output..."); // Read the engine module and split it into smaller modules DoxygenModule RootModule = DoxygenModule.Read("UE4", EngineDir, Path.Combine(XmlDir, "xml")); foreach (DoxygenEntity Entity in RootModule.Entities) { DoxygenModule Module = Modules.Find(x => Entity.File.StartsWith(x.BaseSrcDir)); Entity.Module = Module; Module.Entities.Add(Entity); } // Now filter all the entities in each module if (Filters != null && Filters.Count > 0) { FilterEntities(Modules, Filters); } // Remove all the empty modules Modules.RemoveAll(x => x.Entities.Count == 0); } // Create the index page, and all the pages below it APIIndex Index = new APIIndex(Modules); // Build a list of pages to output List<APIPage> OutputPages = new List<APIPage>(Index.GatherPages().OrderBy(x => x.LinkPath)); // Remove any pages that don't want to be written int NumRemoved = OutputPages.RemoveAll(x => !x.ShouldOutputPage()); Console.WriteLine("Removed {0} pages", NumRemoved); // Dump the output stats string StatsPath = Path.Combine(SitemapDir, "Stats.txt"); Console.WriteLine("Writing stats to '" + StatsPath + "'"); Stats NewStats = new Stats(OutputPages.OfType<APIMember>()); NewStats.Write(StatsPath); // Setup the output directory Utility.SafeCreateDirectory(UdnDir); // Build the manifest Console.WriteLine("Writing manifest..."); UdnManifest Manifest = new UdnManifest(Index); Manifest.PrintConflicts(); Manifest.Write(Path.Combine(UdnDir, APIFolder + "\\API.manifest")); // Write all the pages using (Tracker UdnTracker = new Tracker("Writing UDN pages...", OutputPages.Count)) { foreach (int Idx in UdnTracker.Indices) { APIPage Page = OutputPages[Idx]; // Create the output directory string MemberDirectory = Path.Combine(UdnDir, Page.LinkPath); if (!Directory.Exists(MemberDirectory)) { Directory.CreateDirectory(MemberDirectory); } // Write the page Page.WritePage(Manifest, Path.Combine(MemberDirectory, "index.INT.udn")); } } // Write the sitemap contents Console.WriteLine("Writing sitemap contents..."); Index.WriteSitemapContents(Path.Combine(SitemapDir, "API.hhc")); // Write the sitemap index Console.WriteLine("Writing sitemap index..."); Index.WriteSitemapIndex(Path.Combine(SitemapDir, "API.hhk")); } if ((Actions & BuildActions.Archive) != 0) { Console.WriteLine("Creating archive '{0}'", ArchivePath); Utility.CreateTgzFromDir(ArchivePath, ApiDir); Console.WriteLine("Creating archive '{0}'", SitemapArchivePath); Utility.CreateTgzFromDir(SitemapArchivePath, SitemapDir); } return true; }