Exemplo n.º 1
0
        public override void Link()
        {
            // Parse the metadata
            MetadataDirective = MetadataCache.FindMetadataForMember(Node, "UPROPERTY");

            ParseBriefAndFullDescription(Node, out BriefDescription, out FullDescription);

            XmlNode BitfieldNode = Node.SelectSingleNode("bitfield");

            if (BitfieldNode != null)
            {
                Bitfield = BitfieldNode.InnerText;
            }
            IsMutable = Node.Attributes.GetNamedItem("mutable").InnerText == "yes";
            IsStatic  = Node.Attributes.GetNamedItem("static").InnerText == "yes";

            XmlNode DefNode = Node.SelectSingleNode("definition");

            if (DefNode != null)
            {
                Definition = ConvertToMarkdown(DefNode);
            }

            XmlNode type = Node.SelectSingleNode("type");

            Type = APIMember.RemoveElaborations(ConvertToMarkdown(type));

            XmlNode ArgsStringNode = Node.SelectSingleNode("argsstring");

            if (ArgsStringNode != null)
            {
                ArgsString = ConvertToMarkdown(ArgsStringNode);
            }

            IsolatedType = Type;
            if (!String.IsNullOrEmpty(ArgsString))
            {
                IsolatedType += ArgsString;
            }
            if (!String.IsNullOrEmpty(Bitfield))
            {
                IsolatedType += ": " + Bitfield;
            }
            AbbreviatedType = Markdown.Truncate(IsolatedType, 15, "...");

            XmlNodeList SimpleNodes = Node.SelectNodes("detaileddescription/para/simplesect");

            foreach (XmlNode node in SimpleNodes)
            {
                switch (node.Attributes.GetNamedItem("kind").InnerText)
                {
                case "warning":
                    Warnings.Add(ConvertToMarkdown(node.SelectSingleNode("para")).TrimStart(':'));
                    break;
                }
            }

            SnippetText = APISnippets.LoadSnippetTextForSymbol(FullName);
        }
Exemplo n.º 2
0
        public override void Link()
        {
            // Get the description
            ParseBriefAndFullDescription(Node, out BriefDescription, out FullDescription);

            // Try to link autogenerated exec functions to their original implementation
            if (Utility.IsNullOrWhitespace(BriefDescription) && Utility.IsNullOrWhitespace(FullDescription) && Name.Length >= 5 && Name.StartsWith("exec") && Char.IsUpper(Name[4]))
            {
                APIRecord ParentRecord = Parent as APIRecord;
                if (ParentRecord != null)
                {
                    APIMember TargetMember = ParentRecord.Children.OfType <APIFunction>().FirstOrDefault(x => x.Name == Name.Substring(4));
                    if (TargetMember == null)
                    {
                        TargetMember = ParentRecord.Children.OfType <APIFunctionGroup>().FirstOrDefault(x => x.Name == Name.Substring(4));
                    }
                    if (TargetMember != null)
                    {
                        BriefDescription = String.Format("Wrapper for [{0}]({1}).", TargetMember.Name, TargetMember.LinkPath);
                    }
                }
            }

            // Get the @see directives
            ParseSeeAlso(Node, SeeAlso);

            string RealKeyName = (Entity.Parent != null) ? (Entity.Parent.Name + "::" + Entity.Name) : Entity.Name;

            SnippetText = APISnippets.LoadSnippetTextForSymbol(RealKeyName);

            // Get the modifiers
            IsVirtual = Node.Attributes.GetNamedItem("virt").InnerText == "virtual";
            IsStatic  = Node.Attributes.GetNamedItem("static").InnerText == "yes";

            // Get the metadata
            MetadataDirective = MetadataCache.FindMetadataForMember(Node, "UFUNCTION");

            // Get the template parameters
            TemplateSignature = ParseTemplateSignature(Node);

            // If it's a specialization, add it to the parent class
            if (bIsTemplateSpecialization)
            {
                int StripIdx = FullName.LastIndexOf('<');
                if (StripIdx != -1)
                {
                    APIFunction OriginalTemplateFunction;
                    if (TemplateFunctions.TryGetValue(FullName.Substring(0, StripIdx), out OriginalTemplateFunction))
                    {
                        OriginalTemplateFunction.TemplateSpecializations.Add(this);
                    }
                }
            }

            // Get the parameter declaration nodes
            XmlNodeList ParameterNodes = Node.SelectNodes("param");

            foreach (XmlNode ParameterNode in ParameterNodes)
            {
                Parameters.Add(new APIFunctionParam(this, ParameterNode));
            }

            // If the only parameter is "void", don't bother including it
            if (Parameters.Count == 1 && Parameters[0].Node.SelectSingleNode("type").InnerText == "void")
            {
                Parameters.Clear();
            }

            // Get the parameter description nodes
            XmlNodeList ParameterItemNodes = Node.SelectNodes("detaileddescription/para/parameterlist/parameteritem");

            foreach (XmlNode ParameterItemNode in ParameterItemNodes)
            {
                ParameterSummaries.Add(new APIFunctionParamSummary(this, ParameterItemNode));
            }

            // Get the return type
            XmlNode ReturnTypeNode = Node.SelectSingleNode("type");

            ReturnType = RemoveElaborations(ConvertToMarkdown(ReturnTypeNode));

            // Parse the reimplements list
            using (XmlNodeList ReimplementsList = Node.SelectNodes("reimplements"))
            {
                foreach (XmlNode ReimplementsNode in ReimplementsList)
                {
                    APIFunction Function = ResolveRefLink(ReimplementsNode.Attributes["refid"].Value) as APIFunction;
                    if (Function != null)
                    {
                        Reimplements.Add(Function);
                    }
                }
            }

            // Parse the reimplemented-by list
            using (XmlNodeList ReimplementedByList = Node.SelectNodes("reimplementedby"))
            {
                foreach (XmlNode ReimplementedByNode in ReimplementedByList)
                {
                    APIFunction Function = ResolveRefLink(ReimplementedByNode.Attributes["refid"].Value) as APIFunction;
                    if (Function != null)
                    {
                        ReimplementedBy.Add(Function);
                    }
                }
            }

            // Parse any other notes
            XmlNodeList SimpleNodes = Node.SelectNodes("detaileddescription/para/simplesect");

            foreach (XmlNode node in SimpleNodes)
            {
                switch (node.Attributes.GetNamedItem("kind").InnerText)
                {
                case "return":
                    ReturnDescription = ConvertToMarkdown(node.SelectSingleNode("para"));
                    break;

                case "warning":
                    Warnings.Add(ConvertToMarkdown(node.SelectSingleNode("para")).TrimStart(':'));
                    break;
                }
            }

            // Parse the source lines

            /*
             * XmlNode LocationNode = Node.SelectSingleNode("location");
             * if(LocationNode != null)
             * {
             *      XmlAttribute BodyFileAttribute = LocationNode.Attributes["bodyfile"];
             *      if(BodyFileAttribute != null)
             *      {
             *              string BodyFile = BodyFileAttribute.Value;
             *              if(!BodyFile.ToLowerInvariant().Split('\\', '/').Any(x => Program.ExcludeSourceDirectoriesHash.Contains(x)))
             *              {
             *                      SourceFile File = SourceFileCache.Read(BodyFile);
             *                      if (File != null)
             *                      {
             *                              int BodyStart = Math.Min(Math.Max(Int32.Parse(LocationNode.Attributes["bodystart"].Value) - 1, 0), File.LineOffsets.Length - 1);
             *                              int BodyStartOffset = File.LineOffsets[BodyStart];
             *
             *                              int BodyEnd = Math.Min(Int32.Parse(LocationNode.Attributes["bodyend"].Value), File.LineOffsets.Length - 1);
             *                              int BodyEndOffset = File.LineOffsets[BodyEnd];
             *
             *                              SourceLines = File.Text.Substring(BodyStartOffset, BodyEndOffset - BodyStartOffset).Split('\n');
             *                      }
             *              }
             *      }
             * }
             */
        }