public static DoxygenEntity FromXml(DoxygenModule InModule, string Name, XmlNode Node, XmlNode NamespaceNode) { DoxygenEntity Entity = new DoxygenEntity(InModule); Entity.Id = Node.Attributes["id"].Value; Entity.Name = Name; Entity.Kind = Node.Attributes["kind"].Value; Entity.Node = Node; Entity.NamespaceNode = NamespaceNode; XmlNode LocationNode = Entity.Node.SelectSingleNode("location"); if (LocationNode != null) { Entity.File = LocationNode.Attributes["file"].Value.Replace('/', '\\'); XmlAttribute LineAttribute = LocationNode.Attributes["line"]; if (LineAttribute != null) { Entity.Line = int.Parse(LineAttribute.Value); Entity.Column = int.Parse(LocationNode.Attributes["column"].Value); } XmlAttribute BodyFileAttribute = LocationNode.Attributes["bodyfile"]; XmlAttribute BodyStartAttribute = LocationNode.Attributes["bodystart"]; XmlAttribute BodyEndAttribute = LocationNode.Attributes["bodyend"]; if (BodyFileAttribute != null && BodyStartAttribute != null && BodyEndAttribute != null) { Entity.BodyFile = BodyFileAttribute.Value.Replace('/', '\\'); Entity.BodyStart = Int32.Parse(BodyStartAttribute.Value); Entity.BodyEnd = Int32.Parse(BodyEndAttribute.Value); } } return(Entity); }
public static DoxygenEntity FromXml(DoxygenModule InModule, string Name, XmlNode Node, XmlNode NamespaceNode) { DoxygenEntity Entity = new DoxygenEntity(InModule); Entity.Id = Node.Attributes["id"].Value; Entity.Name = Name; Entity.Kind = Node.Attributes["kind"].Value; Entity.Node = Node; Entity.NamespaceNode = NamespaceNode; XmlNode LocationNode = Entity.Node.SelectSingleNode("location"); if (LocationNode != null) { Entity.File = LocationNode.Attributes["file"].Value.Replace('/', '\\'); XmlAttribute LineAttribute = LocationNode.Attributes["line"]; if (LineAttribute != null) { Entity.Line = int.Parse(LineAttribute.Value); Entity.Column = int.Parse(LocationNode.Attributes["column"].Value); } XmlAttribute BodyFileAttribute = LocationNode.Attributes["bodyfile"]; XmlAttribute BodyStartAttribute = LocationNode.Attributes["bodystart"]; XmlAttribute BodyEndAttribute = LocationNode.Attributes["bodyend"]; if (BodyFileAttribute != null && BodyStartAttribute != null && BodyEndAttribute != null) { Entity.BodyFile = BodyFileAttribute.Value.Replace('/', '\\'); Entity.BodyStart = Int32.Parse(BodyStartAttribute.Value); Entity.BodyEnd = Int32.Parse(BodyEndAttribute.Value); } } return Entity; }
public static DoxygenModule Read(string Name, string BaseSrcDir, string BaseXmlDir) { DoxygenModule Module = TryRead(Name, BaseSrcDir, BaseXmlDir); if (Module == null) { throw new IOException("Couldn't read doxygen module"); } return(Module); }
protected static void ReadMembers(DoxygenModule Module, DoxygenCompound Compound, string NamePrefix, DoxygenEntity Parent, XmlNode NamespaceNode, List <DoxygenEntity> Entities) { using (XmlNodeList NodeList = Compound.Node.SelectNodes("sectiondef/memberdef")) { foreach (XmlNode Node in NodeList) { XmlNode NameNode = Node.SelectSingleNode("name"); string Name = NamePrefix + NameNode.InnerText; DoxygenEntity Entity = DoxygenEntity.FromXml(Module, Name, Node, NamespaceNode); Entity.Parent = Parent; Entities.Add(Entity); } } }
public DoxygenEntity(DoxygenModule InModule) { Module = InModule; Line = Column = -1; BodyStart = BodyEnd = -1; }
protected static void ReadMembers(DoxygenModule Module, DoxygenCompound Compound, string NamePrefix, DoxygenEntity Parent, XmlNode NamespaceNode, List<DoxygenEntity> Entities) { using (XmlNodeList NodeList = Compound.Node.SelectNodes("sectiondef/memberdef")) { foreach (XmlNode Node in NodeList) { XmlNode NameNode = Node.SelectSingleNode("name"); string Name = NamePrefix + NameNode.InnerText; DoxygenEntity Entity = DoxygenEntity.FromXml(Module, Name, Node, NamespaceNode); Entity.Parent = Parent; Entities.Add(Entity); } } }
public static DoxygenModule TryRead(string Name, string BaseSrcDir, string BaseXmlDir) { // Load the index XmlDocument Document; if (!TryReadXmlDocument(Path.Combine(BaseXmlDir, "index.xml"), out Document)) return null; // Create all the compound entities List<string> CompoundIdList = new List<string>(); using (XmlNodeList NodeList = Document.SelectNodes("doxygenindex/compound")) { foreach (XmlNode Node in NodeList) { CompoundIdList.Add(Node.Attributes["refid"].Value); } } // Read all the compound id nodes List<DoxygenCompound> Compounds = new List<DoxygenCompound>(); foreach (string CompoundId in CompoundIdList) { string EntityPath = Path.Combine(BaseXmlDir, CompoundId + ".xml"); XmlDocument EntityDocument; if(TryReadXmlDocument(EntityPath, out EntityDocument)) { Compounds.Add(DoxygenCompound.FromXml(EntityDocument.SelectSingleNode("doxygen/compounddef"))); } else { Console.WriteLine("Couldn't read entity document: '{0}'", EntityPath); } } // Create the module DoxygenModule Module = new DoxygenModule(Name, BaseSrcDir); // Create all the other namespaces Dictionary<string, DoxygenEntity> Scopes = new Dictionary<string, DoxygenEntity>(); foreach (DoxygenCompound Compound in Compounds) { if (Compound.Kind == "namespace") { ReadMembers(Module, Compound, Compound.Name + "::", null, Compound.Node, Module.Entities); } else if (Compound.Kind == "class" || Compound.Kind == "struct" || Compound.Kind == "union") { DoxygenEntity Entity = DoxygenEntity.FromXml(Module, Compound.Name, Compound.Node, null); ReadMembers(Module, Compound, "", Entity, null, Entity.Members); Scopes.Add(Entity.Name, Entity); } } // Go back over all the scopes and fixup their parents foreach (KeyValuePair<string, DoxygenEntity> Scope in Scopes) { int ScopeIdx = Scope.Key.LastIndexOf("::"); if (ScopeIdx != -1 && Scopes.TryGetValue(Scope.Key.Substring(0, ScopeIdx), out Scope.Value.Parent)) { Scope.Value.Parent.Members.Add(Scope.Value); } else { Module.Entities.Add(Scope.Value); } } // Create the module return Module; }
public static APIModule Build(APIPage InParent, DoxygenModule InModule) { // Find the description and category string ModuleSettingsPath = "Module." + InModule.Name; string Description = Program.Settings.FindValueOrDefault(ModuleSettingsPath + ".Description", ""); // Get the filter settings IniSection FilterSection = Program.Settings.FindSection(ModuleSettingsPath + ".Filter"); IniSection WithholdSection = Program.Settings.FindSection(ModuleSettingsPath + ".Withhold"); // Build a module from all the members APIModule Module = new APIModule(InParent, InModule.Name, Description); // Normalize the base directory string NormalizedBaseSrcDir = Path.GetFullPath(InModule.BaseSrcDir).ToLowerInvariant(); if (!NormalizedBaseSrcDir.EndsWith("\\")) NormalizedBaseSrcDir += "\\"; // Separate the members into categories, based on their path underneath the module source directory Dictionary<APIFilter, List<DoxygenEntity>> MembersByFilter = new Dictionary<APIFilter,List<DoxygenEntity>>(); foreach (DoxygenEntity Entity in InModule.Entities) { string FilterPath = null; // Try to get the filter path from the ini section if (FilterSection != null) { FilterPath = FilterSection.Find(Entity.Name); } // If we didn't have one set explicitly, generate one from the subdirectory if(FilterPath == null) { string EntityFile = String.IsNullOrEmpty(Entity.File)? "" : Path.GetFullPath(Entity.File); if(EntityFile.ToLowerInvariant().StartsWith(NormalizedBaseSrcDir)) { int MinIndex = EntityFile.IndexOf('\\', NormalizedBaseSrcDir.Length); if(MinIndex == -1) { FilterPath = ""; } else if (IsVisibleFolder(EntityFile.Substring(NormalizedBaseSrcDir.Length, MinIndex - NormalizedBaseSrcDir.Length))) { int MaxIndex = EntityFile.LastIndexOf('\\'); FilterPath = EntityFile.Substring(MinIndex + 1, Math.Max(MaxIndex - MinIndex - 1, 0)); } } } // Add this entity to the right filters if(FilterPath != null) { // Create all the categories for this entry APIFilter ParentFilter = Module; if (FilterPath.Length > 0) { string[] Folders = FilterPath.Split('\\'); for (int Idx = 0; Idx < Folders.Length; Idx++) { APIFilter NextFilter = ParentFilter.Filters.FirstOrDefault(x => String.Compare(x.Name, Folders[Idx], true) == 0); if (NextFilter == null) { NextFilter = new APIFilter(ParentFilter, Folders[Idx]); ParentFilter.Filters.Add(NextFilter); } ParentFilter = NextFilter; } } // Add this entity to the pending list for this filter Utility.AddToDictionaryList(ParentFilter, Entity, MembersByFilter); } } // Try to fixup all of the filters foreach (KeyValuePair<APIFilter, List<DoxygenEntity>> Members in MembersByFilter) { APIFilter Filter = Members.Key; Filter.Members.AddRange(APIMember.CreateChildren(Filter, Members.Value)); } return Module; }
public DoxygenEntity(DoxygenModule InModule) { Module = InModule; Line = Column = -1; }
public static DoxygenModule TryRead(string Name, string BaseSrcDir, string BaseXmlDir) { // Load the index XmlDocument Document; if (!TryReadXmlDocument(Path.Combine(BaseXmlDir, "index.xml"), out Document)) { return(null); } // Create all the compound entities List <string> CompoundIdList = new List <string>(); using (XmlNodeList NodeList = Document.SelectNodes("doxygenindex/compound")) { foreach (XmlNode Node in NodeList) { CompoundIdList.Add(Node.Attributes["refid"].Value); } } // Read all the compound id nodes List <DoxygenCompound> Compounds = new List <DoxygenCompound>(); foreach (string CompoundId in CompoundIdList) { string EntityPath = Path.Combine(BaseXmlDir, CompoundId + ".xml"); XmlDocument EntityDocument; if (TryReadXmlDocument(EntityPath, out EntityDocument)) { Compounds.Add(DoxygenCompound.FromXml(EntityDocument.SelectSingleNode("doxygen/compounddef"))); } else { Console.WriteLine("Couldn't read entity document: '{0}'", EntityPath); } } // Create the module DoxygenModule Module = new DoxygenModule(Name, BaseSrcDir); // Create all the other namespaces Dictionary <string, DoxygenEntity> Scopes = new Dictionary <string, DoxygenEntity>(); foreach (DoxygenCompound Compound in Compounds) { if (Compound.Kind == "namespace") { ReadMembers(Module, Compound, Compound.Name + "::", null, Compound.Node, Module.Entities); } else if (Compound.Kind == "class" || Compound.Kind == "struct" || Compound.Kind == "union") { DoxygenEntity Entity = DoxygenEntity.FromXml(Module, Compound.Name, Compound.Node, null); ReadMembers(Module, Compound, "", Entity, null, Entity.Members); Scopes.Add(Entity.Name, Entity); } } // Go back over all the scopes and fixup their parents foreach (KeyValuePair <string, DoxygenEntity> Scope in Scopes) { int ScopeIdx = Scope.Key.LastIndexOf("::"); if (ScopeIdx != -1 && Scopes.TryGetValue(Scope.Key.Substring(0, ScopeIdx), out Scope.Value.Parent)) { Scope.Value.Parent.Members.Add(Scope.Value); } else { Module.Entities.Add(Scope.Value); } } // Create the module return(Module); }