public void Add(string Name, APIPage Page) { APIPage ExistingPage; if (Entries.TryGetValue(Name, out ExistingPage)) { if (ExistingPage != Page) { List <APIPage> ConflictPages; if (!ConflictEntries.TryGetValue(Name, out ConflictPages)) { ConflictPages = new List <APIPage> { ExistingPage }; ConflictEntries.Add(Name, ConflictPages); } if (!ConflictPages.Contains(Page)) { ConflictPages.Add(Page); } } } else { Entries.Add(Name, Page); } }
public IEnumerable <APIPage> GatherPages() { // Visit all the pages and collect all their references HashSet <APIPage> PendingSet = new HashSet <APIPage> { this }; HashSet <APIPage> VisitedSet = new HashSet <APIPage>(); while (PendingSet.Count > 0) { APIPage Page = PendingSet.First(); List <APIPage> ReferencedPages = new List <APIPage>(); Page.GatherReferencedPages(ReferencedPages); foreach (APIPage ReferencedPage in ReferencedPages) { if (!VisitedSet.Contains(ReferencedPage)) { PendingSet.Add(ReferencedPage); } } PendingSet.Remove(Page); VisitedSet.Add(Page); } return(VisitedSet); }
public APIConstantIndex(APIPage InParent, IEnumerable <APIMember> Members) : base(InParent, "Constants", "Alphabetical list of all constants") { foreach (APIMember Member in Members) { if (Member.FullName == Member.Name) { if (Member is APIConstant) { // Add the constant as-is AddToDefaultCategory(new Entry(Member)); } else if (Member is APIEnum) { // Get the enum APIEnum Enum = (APIEnum)Member; // Get the scope prefix for all enum members string EnumPrefix = Enum.FullName; int LastScope = EnumPrefix.LastIndexOf("::"); EnumPrefix = (LastScope == -1) ? "" : EnumPrefix.Substring(0, LastScope + 2); // Add all the values foreach (APIEnumValue EnumValue in Enum.Values) { AddToDefaultCategory(new Entry(EnumPrefix + EnumValue.Name, Enum.LinkPath)); } } } } }
public static APIFunctionKey FromEntity(APIPage Parent, DoxygenEntity Entity) { string Name = Entity.Name; if (Parent != null && Parent is APIRecord) { if (Name == Parent.Name && (Parent is APIRecord) && Entity.Node.Attributes["static"].Value != "yes") { return(new APIFunctionKey(Name, APIFunctionType.Constructor)); } else if (Name == "~" + Parent.Name) { return(new APIFunctionKey(Name, APIFunctionType.Destructor)); } } if (Name.StartsWith("operator") && Name.Length > 8 && !Char.IsLetterOrDigit(Name[8]) && Name[8] != '_') { int NumParams = 0; using (XmlNodeList ParamNodeList = Entity.Node.SelectNodes("param")) { foreach (XmlNode ParamNode in ParamNodeList) { NumParams++; } } if ((Parent is APIRecord) && Entity.Node.Attributes["static"].Value != "yes") { NumParams++; } return(new APIFunctionKey(Name, (NumParams == 1) ? APIFunctionType.UnaryOperator : APIFunctionType.BinaryOperator)); } return(new APIFunctionKey(Name, APIFunctionType.Normal)); }
public APIEventParameters(APIPage InParent, APIMember InAttachedTo, DoxygenEntity InEntity) : base(InParent, InEntity.Name) { AttachedTo = InAttachedTo; Entity = InEntity; AddRefLink(Entity.Id, this); }
public Stat AddStat(APIMember Member, string Name) { for (APIPage Page = Member; Page != null; Page = Page.Parent) { APIModule Module = Page as APIModule; if (Module != null) { // Get the stats for this module ModuleStats ModuleStatsInst; if (!Modules.TryGetValue(Module.Name, out ModuleStatsInst)) { ModuleStatsInst = new ModuleStats(); Modules.Add(Module.Name, ModuleStatsInst); } // Find the name of this stat Stat StatInst; if (!ModuleStatsInst.Stats.TryGetValue(Name, out StatInst)) { StatInst = new Stat(); ModuleStatsInst.Stats.Add(Name, StatInst); } // Update the current return(StatInst); } } return(null); }
public APIVariable(APIPage InParent, XmlNode InNode) : base(InParent, InNode.SelectSingleNode("name").InnerText) { Node = InNode; Protection = ParseProtection(Node); AddRefLink(Node.Attributes["id"].InnerText, this); }
public static APIHierarchy Build(APIPage Parent, IEnumerable <APIRecord> Records) { // Create a root node APIHierarchyNode RootNode = new APIHierarchyNode(); // Build a set of all the records to include in the hierarchy HashSet <APIRecord> KnownRecords = new HashSet <APIRecord>(); foreach (APIRecord Record in Records) { KnownRecords.Add(Record); } // Filter out all the records which don't have another record in the hierarchy foreach (APIRecord Record in Records) { if (!Record.bIsTemplateSpecialization) { if (Record.BaseRecords == null || !Record.BaseRecords.Exists(y => KnownRecords.Contains(y.Value))) { APIHierarchyNode NewNode = new APIHierarchyNode(Record.FullName, Record.LinkPath, true); NewNode.AddChildren(Record); RootNode.Children.Add(NewNode); } } } // Return the new page return(new APIHierarchy(Parent, "Class Hierarchy", "Class Hierarchy", RootNode)); }
public APICategory(APIPage InParent, string InName, bool bInIsRootCategory = false) : base(InParent, InName) { SubCategories = new Dictionary <string, APICategory>(); Actions = new List <APIAction>(); bIsRootCategory = bInIsRootCategory; }
public APITypeDef(APIPage InParent, DoxygenEntity InEntity) : base(InParent, InEntity.Node.SelectSingleNode("name").InnerText) { Entity = InEntity; Node = Entity.Node; Id = Node.Attributes["id"].Value; AddRefLink(Id, this); }
public APIMemberIndex(APIPage InParent, string InName, string InDescription) : base(InParent, InName) { Description = InDescription; for (int Idx = 0; Idx < CharacterCategories.Length; Idx++) { Categories.Add(new Category(CharacterCategories.Substring(Idx, 1))); } }
public bool HasParent(APIPage InParent) { for (APIPage Page = Parent; Page != null; Page = Page.Parent) { if (Page == InParent) { return(true); } } return(false); }
public T FindParent <T>() where T : APIPage { for (APIPage NextPage = Parent; NextPage != null; NextPage = NextPage.Parent) { if (NextPage is T) { return((T)NextPage); } } return(null); }
public static IEnumerable <APIConstant> Read(APIPage Parent, DoxygenEntity Entity) { XmlNode EnumNode = Entity.Node; using (XmlNodeList ValueNodeList = EnumNode.SelectNodes("enumvalue")) { foreach (XmlNode ValueNode in ValueNodeList) { string Name = ValueNode.SelectSingleNode("name").InnerText; APIConstant Constant = new APIConstantEnum(Parent, Entity, ValueNode, Name); yield return(Constant); } } }
public APIEnumIndex(APIPage InParent, IEnumerable <APIMember> Members) : base(InParent, "Enums", "All enums") { foreach (APIMember Member in Members) { if (Member is APIEnum) { Entry NewEntry = new Entry(Member); if (NewEntry.SortName.Length >= 2 && IgnorePrefixLetters.Contains(NewEntry.SortName[0]) && Char.IsUpper(NewEntry.SortName[1])) { NewEntry.SortName = NewEntry.SortName.Substring(1); } AddToDefaultCategory(NewEntry); } } }
public APIFunction(APIPage InParent, DoxygenEntity InEntity, APIFunctionKey InKey, string InLinkPath) : base(InParent, InEntity.Name, InLinkPath) { Entity = InEntity; Node = Entity.Node; Protection = ParseProtection(Node); FunctionType = InKey.Type; AddRefLink(Entity.Node.Attributes["id"].Value, this); bIsTemplateSpecialization = Name.Contains('<'); if (Node.SelectSingleNode("templateparamlist") != null && !bIsTemplateSpecialization && !TemplateFunctions.ContainsKey(FullName)) { TemplateFunctions.Add(FullName, this); } }
public void Write(string OutputPath) { // Write the remaining entries to the output file using (StreamWriter Writer = new StreamWriter(OutputPath)) { foreach (KeyValuePair <string, APIPage> Entry in Entries.OrderBy(x => x.Key)) { APIPage TargetPage = Entry.Value; while (!TargetPage.ShouldOutputPage()) { TargetPage = TargetPage.Parent; } Writer.WriteLine("{0}, {1}", Entry.Key, TargetPage.LinkPath); } } }
public static bool CreateParametersStruct(APIPage Parent, List <APIMember> Children, DoxygenEntity Entity) { string Name = Entity.Name; int ClassMaxIdx = Name.IndexOf("_event"); if (ClassMaxIdx == -1) { return(false); } string ClassName = Name.Substring(0, ClassMaxIdx); APIRecord ClassRecord = Children.OfType <APIRecord>().FirstOrDefault(x => x.Name.EndsWith(ClassName) && x.Name.Length == ClassName.Length + 1); if (ClassRecord == null) { return(false); } if (!Name.EndsWith("_Parms")) { return(false); } int MemberMinIdx = ClassMaxIdx + 6; int MemberMaxIdx = Name.Length - 6; string MemberName = Name.Substring(MemberMinIdx, MemberMaxIdx - MemberMinIdx); APIRecord Delegate = Children.OfType <APIRecord>().FirstOrDefault(x => x.Name == "F" + MemberName); if (Delegate != null) { Delegate.DelegateEventParameters = new APIEventParameters(Parent, Delegate, Entity); Children.Add(Delegate.DelegateEventParameters); return(true); } APIFunction Function = ClassRecord.Children.OfType <APIFunction>().FirstOrDefault(x => x.Name == MemberName); if (Function != null) { Function.EventParameters = new APIEventParameters(Parent, Function, Entity); Children.Add(Function.EventParameters); return(true); } return(false); }
public APIRecordIndex(APIPage InParent, IEnumerable <APIMember> Members) : base(InParent, "Classes", "All classes") { foreach (APIMember Member in Members) { if ((Member is APIRecord && (!((APIRecord)Member).bIsTemplateSpecialization)) || (Member is APITypeDef) || (Member is APIEventParameters)) { if (Member.FindParent <APIRecord>() == null) { Entry NewEntry = new Entry(Member); if (NewEntry.SortName.Length >= 2 && IgnorePrefixLetters.Contains(NewEntry.SortName[0]) && Char.IsUpper(NewEntry.SortName[1])) { NewEntry.SortName = NewEntry.SortName.Substring(1); } AddToDefaultCategory(NewEntry); } } } }
public string FormatString(string Text) { StringBuilder Output = new StringBuilder(); for (int Idx = 0; Idx < Text.Length; Idx++) { if (Text[Idx] == '{') { if (Text[Idx + 1] == '{') { Output.Append(Text[++Idx]); } else { int EndIdx = Text.IndexOf('}', Idx + 1); string LinkText = Text.Substring(Idx + 1, EndIdx - Idx - 1); string LinkName = LinkText; int LinkNameIdx = LinkText.IndexOf('|'); if (LinkNameIdx != -1) { LinkName = LinkText.Substring(LinkNameIdx + 1); LinkText = LinkText.Substring(0, LinkNameIdx); } APIPage LinkPage = Find(LinkName); if (LinkPage != null) { Output.AppendFormat("[{0}]({1})", LinkText, LinkPage.LinkPath); } else { Output.Append(LinkText); } Idx = EndIdx; } } else { Output.Append(Text[Idx]); } } return(Output.ToString()); }
public APIAction(APIPage InParent, string InName, Dictionary <string, object> ActionProperties) : base(InParent, InName) { object Value; if (ActionProperties.TryGetValue("Tooltip", out Value)) { Tooltip = String.Concat(((string)Value).Split('\n').Select(Line => Line.Trim() + '\n')); } else { Tooltip = ""; } if (ActionProperties.TryGetValue("CompactTitle", out Value)) { CompactName = (string)Value; } if (ActionProperties.TryGetValue("NodeType", out Value)) { NodeType = (string)Value; } else { NodeType = "function"; } if (ActionProperties.TryGetValue("Pins", out Value)) { Pins = new List <APIActionPin>(); foreach (var Pin in (Dictionary <string, object>)Value) { Pins.Add(new APIActionPin(this, APIActionPin.GetPinName((Dictionary <string, object>)Pin.Value), (Dictionary <string, object>)Pin.Value)); } } if (ActionProperties.TryGetValue("ShowAddPin", out Value)) { bShowAddPin = Convert.ToBoolean((string)Value); } }
public APIFunctionGroup(APIPage InParent, APIFunctionKey InKey, IEnumerable <DoxygenEntity> InEntities) : base(InParent, InKey.Name, Utility.MakeLinkPath(InParent.LinkPath, InKey.GetLinkName())) { FunctionType = InKey.Type; // Build a list of prototypes for each function node, to be used for sorting List <DoxygenEntity> Entities = new List <DoxygenEntity>(InEntities.OrderBy(x => x.Node.SelectNodes("param").Count)); // Create the functions int LinkIndex = 1; foreach (DoxygenEntity Entity in Entities) { string NewLinkPath = Utility.MakeLinkPath(LinkPath, String.Format("{0}", LinkIndex)); APIFunction Function = new APIFunction(this, Entity, InKey, NewLinkPath); Children.Add(Function); LinkIndex++; } }
public void WriteReferencesSection(UdnWriter Writer, DoxygenEntity Entity) { List <UdnListItem> Items = new List <UdnListItem>(); // Get the module for (APIPage Page = this; Page != null; Page = Page.Parent) { APIModule Module = Page as APIModule; if (Module != null) { Items.Add(new UdnListItem("Module", String.Format("[{0}]({1})", Module.Name, Module.LinkPath), null)); break; } } // Get the header file if (Entity.File != null) { string NormalizedFileName = GetNormalizedFileName(Entity.File); if (NormalizedFileName != null) { Items.Add(new UdnListItem("Header", Utility.EscapeText(NormalizedFileName), null)); } } // Get the source file if (Entity.BodyFile != null && Entity.BodyFile != Entity.File) { string NormalizedFileName = GetNormalizedFileName(Entity.BodyFile); if (NormalizedFileName != null) { Items.Add(new UdnListItem("Source", Utility.EscapeText(NormalizedFileName), null)); } } // Write the section if (Items.Count > 0) { Writer.EnterSection("references", "References"); Writer.WriteList(Items); Writer.LeaveSection(); } }
public APIRecord(APIPage InParent, DoxygenEntity InEntity) : base(InParent, GetNameFromNode(InEntity.Node)) { // Set all the readonly vars Entity = InEntity; Node = InEntity.Node; RefId = Node.Attributes["id"].InnerText; Protection = ParseProtection(Node); // Set the record type switch (Node.Attributes["kind"].Value) { case "class": RecordType = Name.StartsWith("I")? APIRecordType.Interface : APIRecordType.Class; break; case "struct": RecordType = APIRecordType.Struct; break; case "union": RecordType = APIRecordType.Union; break; } // Register the record for incoming links AddRefLink(RefId, this); // Add it to the template list if (Node.SelectSingleNode("templateparamlist") != null) { bIsTemplate = true; bIsTemplateSpecialization = Name.Contains('<'); if (!bIsTemplateSpecialization && !TemplateRecords.ContainsKey(FullName)) { TemplateRecords.Add(FullName, this); } } }
public APIEnum(APIPage InParent, DoxygenEntity InEntity, string InName) : base(InParent, GetCleanName(InName)) { // Set the defaults Entity = InEntity; Node = InEntity.Node; Protection = ParseProtection(Node); // Read the values using (XmlNodeList ValueNodeList = Node.SelectNodes("enumvalue")) { foreach (XmlNode ValueNode in ValueNodeList) { APIEnumValue Value = new APIEnumValue(ValueNode); AddRefLink(Value.Id, this); Values.Add(Value); } } // Add it as a link target AddRefLink(Node.Attributes["id"].InnerText, this); }
public UdnManifest(APIPage Page) { Page.AddToManifest(this); }
public APIModule(APIPage InParent, string InName, string InDescription) : base(InParent, InName) { Description = InDescription; }
public APIFilter(APIPage InParent, string InName) : base(InParent, InName) { }
public APIAction(APIPage InParent, string InName, Dictionary <string, object> ActionProperties) : base(InParent, InName) { object Value; TooltipNormalText = ""; TooltipLine.LineType CurrentLineType = TooltipLine.LineType.Count; //Invalid if (ActionProperties.TryGetValue("Tooltip", out Value)) { //Create an interleaved list of normal text and note regions. Also, store all normal text as a single block (i.e. notes stripped out) in a separate place. foreach (string Line in ((string)Value).Split('\n')) { string TrimmedLine = Line.Trim(); if (TrimmedLine.StartsWith("@note")) { if (TrimmedLine.Length > 6) { if (CurrentLineType != TooltipLine.LineType.Note) { CurrentLineType = TooltipLine.LineType.Note; TooltipData.Add(new TooltipLine(CurrentLineType)); } TooltipData[TooltipData.Count - 1].Text += (TrimmedLine.Substring(6) + '\n'); } } else { if (CurrentLineType != TooltipLine.LineType.Normal) { CurrentLineType = TooltipLine.LineType.Normal; TooltipData.Add(new TooltipLine(CurrentLineType)); } TooltipData[TooltipData.Count - 1].Text += (TrimmedLine + '\n'); TooltipNormalText += (TrimmedLine + '\n'); } } } if (ActionProperties.TryGetValue("CompactTitle", out Value)) { CompactName = (string)Value; } if (ActionProperties.TryGetValue("NodeType", out Value)) { NodeType = (string)Value; } else { NodeType = "function"; } if (ActionProperties.TryGetValue("Pins", out Value)) { Pins = new List <APIActionPin>(); foreach (var Pin in (Dictionary <string, object>)Value) { Pins.Add(new APIActionPin(this, APIActionPin.GetPinName((Dictionary <string, object>)Pin.Value), (Dictionary <string, object>)Pin.Value)); } } if (ActionProperties.TryGetValue("ShowAddPin", out Value)) { bShowAddPin = Convert.ToBoolean((string)Value); } }
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); }