Ejemplo n.º 1
0
        public void printClass(DoxClass dc, bool detailed)
        {
            DocSect dsec = new DocSect();
            DocTable dt = new DocTable();
            bool endOfTable = true;
            if (detailed == false)
            {
                if (this.currentTable == null)
                {
                    dt.ColCount = 2;
                    dt.RowCount = 2;
                    header_row(dt);
                }
                else
                {
                    dt = this.currentTable;
                    endOfTable = false;
                }
                DocPara dp = new DocPara();
                dsec.Paragraphs.Add(dp);
                this.currentTable = dt;
            }
            printClassifier(dc, detailed);
            if (detailed == false && endOfTable == true)
            {
                DocPara dp = new DocPara();
                dp.Commands.Add(dt);
                dsec.Paragraphs.Add(dp);
                this.PrintDocCmd(dsec);
                this.currentTable = null;

            }
        }
        private void ParseCompounds(string path)
        {
            this.currentFileName = @"..\..\javadoc\html\" + path;
            HtmlDocument document = new HtmlDocument();
            try
            {
                document.Load(currentFileName);
            }
            catch(Exception)
            {
                this.Log(LogKind.Warning, "Can't open "+path);
                return;
            }
            HtmlNode root = document.DocumentNode;

            String packagename = path.Split('/')[0];
            DoxNamespace ns = (DoxNamespace) Model.Compounds.First(c => c.Name == packagename);

            // Get the HtmlNode, what represents the html tag
            HtmlNode htmlnode = root.ChildNodes.First(node => node.Name == "html");
            HtmlNode bodyNode = null;
            try
            {
                bodyNode = htmlnode.ChildNodes.First(node => node.Name == "body");
            }
            // If the aren't any body tag, than the html is invalid or corrupted
            catch (InvalidOperationException)
            {
                this.Log(LogKind.Error, "Missing body tag in the html. In " + packagename);
                return;
            }

            // Get the div tag, within the compound informations are.
            HtmlNode compoundDivNode = null;
            try
            {
                compoundDivNode = bodyNode.ChildNodes.First(node => node.Name == "div" && node.Attributes.FirstOrDefault(attr => attr.Name == "class" && attr.Value == "contentContainer") != null);
            }
            // If the program can't find the package, than it exit with error.
            catch (InvalidOperationException)
            {
                this.Log(LogKind.Error, "Can't find the compounds in the package. ");
                return;
            }

            //Get the list of the compoundinformations
            HtmlNode compoundListNode = null;
            try
            {
                compoundListNode = compoundDivNode.ChildNodes.First(node => node.Name == "ul");
            }
            // If the program can't find the list of the compounds, than it exit with error.
            catch (InvalidOperationException)
            {
                this.Log(LogKind.Error, "Can't find the list of the compounds in the package.");
                return;
            }

            foreach (HtmlNode CompoundTypeList in compoundListNode.ChildNodes.Where(node => node.Name == "li"))
            {
                HtmlNode CompoundTypeTable = CompoundTypeList.ChildNodes.First(node => node.Name == "table");
                string Type = normalizeHtml(CompoundTypeTable.ChildNodes.First(node => node.Name == "tr").ChildNodes.First(node => node.Name == "th").InnerText);

                foreach (HtmlNode CompoundNode in CompoundTypeTable.ChildNodes.First(node => node.Name=="tbody").ChildNodes.Where(node => node.Name=="tr"))
                {
                    HtmlNode[] CompoundRows = CompoundNode.ChildNodes.Where(node => node.Name == "td").ToArray();
                    CompoundIndex ci = new CompoundIndex();
                    this.Index.Compounds.Add(ci);
                    ParseCompound(ci, Type);
                    ci.Name = CompoundRows[0].InnerText;
                    ci.Identifier = ns.Name + "_" + ci.Name;

                    DoxClassifier c;
                    if (Type == "Class")
                    {
                        ci.Kind = CompoundKind.Class;
                        c = new DoxClass();
                    }
                    else if (Type == "Interface")
                    {
                        ci.Kind = CompoundKind.Interface;
                        c = new DoxInterface();
                    }
                    else if (Type == "Exception" || Type == "Error")
                    {
                        ci.Kind = CompoundKind.Exception;
                        c = new DoxClass();

                    }
                    else if (Type == "Enum")
                    {
                        ci.Kind = CompoundKind.Enum;
                        c = new DoxEnum();
                    }
                    else
                    {
                        this.Log(LogKind.Warning, Type + " isn't a valid compound type.");
                        continue;
                    }

                    c.Identifier = ci.Identifier;
                    c.Name = ci.Name;
                    c.Kind = ci.Kind;

                    this.ProcessCompounds.Add(CompoundRows[0].ChildNodes.First(node => node.Name == "a").Attributes.First(attr => attr.Name == "href").Value);

                    // NEED TO CHANGE!
                    String description = normalizeHtml(CompoundRows[1].InnerText);

                    ci.Compound = c;
                    ns.Classifiers.Add(c);
                    this.Model.Compounds.Add(c);
                    this.Index.CompoundIndexRefs.Add(ci.Identifier, ci);
                    this.Model.CompoundRefs.Add(ci.Identifier, ci.Compound);
                }

            }
            HtmlNode briefDescriptionNode = compoundDivNode.ChildNodes.FirstOrDefault(node => node.Name == "div" && node.Attributes.First(attr => attr.Name == "class" && attr.Value == "block")!=null);
            if(briefDescriptionNode != null)
            {
                String briefDescription = normalizeHtml(briefDescriptionNode.InnerText);
            }
            this.Log(LogKind.Info, "Processing of " + this.currentFileName + " has ended.");
        }
Ejemplo n.º 3
0
        private void ParseClass(Type Class)
        {
            if(Class.Namespace == null || Class.Name.Any(c => c == '<' || c == '>'))
            {
                //this.Log(LogKind.Warning,Class.ToString()+ " isn't in any namespace.");
                return;
            }
            FieldInfo[] field = Class.GetFields(BindingFlags.NonPublic | BindingFlags.Public
             | BindingFlags.Instance | BindingFlags.Static);
            PropertyInfo[] propertys = Class.GetProperties(
            BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);
            MethodInfo[] methods = Class.GetMethods(BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);
            ConstructorInfo[] constructors = Class.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);
            Type[] NestedTypes = Class.GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);

            DoxNamespace dns = (DoxNamespace)Model.Compounds.FirstOrDefault(c => c.Identifier.Equals(Class.Namespace));
            if(dns == null)
            {
                CompoundIndex ci = new CompoundIndex();
                this.Index.Compounds.Add(ci);
                ci.Name = Class.Namespace;
                ci.Identifier = ci.Name;
                ci.Kind = CompoundKind.Namespace;

                DoxNamespace c = new DoxNamespace();
                c.Identifier = ci.Identifier;
                c.Name = ci.Name;
                c.Kind = ci.Kind;

                dns = c;

                ci.Compound = c;
                this.Model.Compounds.Add(c);
                this.Index.CompoundIndexRefs.Add(ci.Identifier, ci);
                this.Model.CompoundRefs.Add(ci.Identifier, ci.Compound);
            }
            DoxClass dc = new DoxClass();
            dc.Abstract = Class.IsAbstract;
            dc.Identifier = Class.FullName;
            dc.Kind = CompoundKind.Class;
            dc.Name = Class.FullName;
            dc.Sealed = Class.IsSealed;

            if (propertys.Length > 0)
            {
                parseProperty(propertys, dc);
            }
            if (field.Length > 0)
            {
                parseField(field, dc);
            }
            if (constructors.Length > 0)
            {
                parseCtor(constructors, dc);
            }
            if(methods.Length > 0)
            {
                parseMethod(methods, dc);
            }

            dns.Classifiers.Add(dc);
            CompoundIndex compi = new CompoundIndex();
            this.Index.Compounds.Add(compi);
            compi.Name = dc.Name;
            compi.Identifier = dc.Identifier;
            compi.Kind = CompoundKind.Namespace;
            compi.Compound = dc;
            this.Model.Compounds.Add(dc);
            this.Index.CompoundIndexRefs.Add(compi.Identifier, compi);
            this.Model.CompoundRefs.Add(compi.Identifier, compi.Compound);
        }