public void printInterface(DoxInterface di, 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(di, 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.");
        }
Пример #3
0
        private void parseInterface(Type Interface)
        {
            if (Interface.Namespace == null || Interface.Name.Any(c => c == '<' || c == '>'))
            {
                //this.Log(LogKind.Warning,Class.ToString()+ " isn't in any namespace.");
                return;
            }
            FieldInfo[] field = Interface.GetFields(BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);
            PropertyInfo[] propertys = Interface.GetProperties(
            BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);
            MethodInfo[] methods = Interface.GetMethods(BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);
            ConstructorInfo[] constructors = Interface.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);
            Type[] NestedTypes = Interface.GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static);

            DoxNamespace dns = (DoxNamespace)Model.Compounds.FirstOrDefault(c => c.Identifier.Equals(Interface.Namespace));
            if(dns == null)
            {
                CompoundIndex ci = new CompoundIndex();
                this.Index.Compounds.Add(ci);
                ci.Name = Interface.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);
            }
            DoxInterface dc = new DoxInterface();
            dc.Abstract = Interface.IsAbstract;
            dc.Identifier = Interface.FullName;
            dc.Kind = CompoundKind.Interface;
            dc.Name = Interface.FullName;
            dc.Sealed = Interface.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);
        }