public void printInterfaces(bool detailed, DoxNamespace ns=null, List<DoxClassifier> Ininterfaces=null) { List<DoxClassifier> interfaces = null; if (Ininterfaces == null && ns != null) { interfaces = ns.Classifiers.Where(dc => dc.Kind == CompoundKind.Interface && dc.Members.Count > 0).OrderBy(c => c.Name).ToList(); } else if(Ininterfaces != null) { interfaces = Ininterfaces; } else { Log("Error DPrint-2: printInterfaces method should get a Namespace or list of classifiers"); } DocSect parentSect = this.currentsection; DocSect ds = new DocSect(); DocTable dt = new DocTable(); if (detailed == false) { ds.Title = "Interfaces: "; ds.Identifier = ""; DocPara dp = new DocPara(); ds.Paragraphs.Add(dp); dt.ColCount = 2; dt.RowCount = interfaces.Count + 1; header_row(dt); this.currentTable = dt; } foreach (DoxInterface di in interfaces) { if (di.Members.Count > 0) { printClassifier(di, detailed); } } if (detailed == false) { DocPara dp = new DocPara(); dp.Commands.Add(dt); ds.Paragraphs.Add(dp); if (parentSect != null) { parentSect.Sections.Add(ds); this.currentsection = parentSect; } else { this.PrintDocCmd(ds); } this.currentTable = null; } }
private void ParsePackages() { this.currentFileName = this.IndexFile; HtmlDocument document = new HtmlDocument(); try { document.Load(currentFileName); } catch (Exception) { this.Log(LogKind.Error, "Can't open " + this.currentFileName + "."); return; } HtmlNode root = document.DocumentNode; // Get the HtmlNode, what represents the html tag HtmlNode htmlnode = root.ChildNodes.First(node => node.Name == "html"); // Get the node, what represents the head tag HtmlNode headNode = null; try { headNode = htmlnode.ChildNodes.First(node => node.Name == "head"); } // If the aren't any head tag, than the html is invalid or corrupted catch(InvalidOperationException) { this.Log(LogKind.Error, "Missing head tag in the html. Program is terminating."); return; } // Find the comment, where the version of the javadoc was writen HtmlNode versionnode = headNode.ChildNodes.First(node => node.Name == "#comment"); String version = versionnode.InnerHtml; version = version.Split('(', ')')[1]; this.Index.Version = version; 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. Program is terminating."); return; } // Get the div tag, what contains the informations about the packages HtmlNode packageDivNode = null; try { packageDivNode = 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 packages. Program is terminating."); return; } // Get the table, where is the data of the packages. HtmlNode packageTableNode = null; try { packageTableNode = packageDivNode.ChildNodes.First(node => node.Name == "table").ChildNodes.First(node => node.Name == "tbody"); } catch (InvalidOperationException) { this.Log(LogKind.Error, "Can't find the data of the packages. Program is terminating."); return; } foreach (var packagerow in packageTableNode.ChildNodes.Where(node => node.Name == "tr")) { HtmlNode[] datas = packagerow.ChildNodes.Where(node => node.Name == "td").ToArray(); CompoundIndex ci = new CompoundIndex(); this.Index.Compounds.Add(ci); ci.Name = datas[0].ChildNodes.ElementAt(0).InnerHtml; ci.Identifier = ci.Name; ci.Kind = CompoundKind.Namespace; DoxNamespace c = new DoxNamespace(); c.Identifier = ci.Identifier; c.Name = ci.Name; c.Kind = ci.Kind; this.ProcessPackages.Add(datas[0].ChildNodes.ElementAt(0).Attributes.ElementAt(0).Value); // NEED TO CHANGE! HtmlNode desc = datas[1].ChildNodes.FirstOrDefault(node => node.Name == "div" && node.Attributes.FirstOrDefault(attr => attr.Name == "class" && attr.Value == "block") != null); if(desc != null) { String Description = normalizeHtml(desc.InnerText); DocPara newPara = new DocPara(); DocText desc_text = new DocText(); desc_text.Text = Description; newPara.Commands.Add(desc_text); c.Description.Paragraphs.Add(newPara); } ci.Compound = c; this.Model.Compounds.Add(c); this.Index.CompoundIndexRefs.Add(ci.Identifier, ci); this.Model.CompoundRefs.Add(ci.Identifier, ci.Compound); } this.Log(LogKind.Info, "Processing of " + this.currentFileName + " has ended."); }
public void printNameSpace(DoxNamespace ns, Boolean detailed) { if (detailed == true) { string name = NormalizeName(ns.Name); DocSect parentsec = this.currentsection; DocSect ds = new DocSect(); ds.Title = "Namespace: " + name; ds.Identifier = ns.Identifier; if (ns.BriefDescription != null && ns.BriefDescription.Paragraphs.Count > 0) { ds.Paragraphs.AddRange(ns.BriefDescription.Paragraphs); } else if(ns.Description != null) { ds.Paragraphs.AddRange(ns.Description.Paragraphs); } this.currentsection = ds; this.printClasses(detailed, ns); this.printInterfaces(detailed, ns); this.printStructs(detailed, ns); this.printEnums(detailed, ns); parentsec.Sections.Add(ds); } else { DocTableRow dtr = new DocTableRow(); DocTableCell dtc = new DocTableCell(); DocPara dp = new DocPara(); dp.Commands.Add(new DocText() { TextKind = DocTextKind.Plain, Text = ns.Name }); dtc.Paragraphs.Add(dp); dtr.Cells.Add(dtc); dp = new DocPara(); dtc = new DocTableCell(); if (ns.BriefDescription != null && ns.BriefDescription.Paragraphs.Count > 0) { dtc.Paragraphs.AddRange(ns.BriefDescription.Paragraphs); } else if(ns.Description != null) { dtc.Paragraphs.AddRange(ns.Description.Paragraphs); } dtc.Paragraphs.Add(dp); dtr.Cells.Add(dtc); this.currentTable.Rows.Add(dtr); } }
public void printClassifiers(bool detailed, DoxNamespace ns = null, List<DoxClassifier> Inclassifiers = null) { List<DoxClassifier> classifiers = null; if (Inclassifiers == null && ns != null) { classifiers = ns.Classifiers.OrderBy(c => c.Name).ToList(); } else if(Inclassifiers != null) { classifiers = Inclassifiers; } else { Log("Error DPrint-0: printClassifiers method should get a Namespace or list of classifiers"); } DocSect parentSect = this.currentsection; DocSect ds = new DocSect(); DocTable dt = new DocTable(); if (detailed == false) { ds.Title = "Classifiers: "; ds.Identifier = ""; DocPara dp = new DocPara(); ds.Paragraphs.Add(dp); dt.ColCount = 2; dt.RowCount = classifiers.Count + 1; header_row(dt); this.currentTable = dt; } foreach (DoxClassifier classifier in classifiers.Where(classifier => classifier.Members.Count > 0)) { printClassifier(classifier, detailed); } if (detailed == false) { DocPara dp = new DocPara(); dp.Commands.Add(dt); ds.Paragraphs.Add(dp); if(parentSect != null) { parentSect.Sections.Add(ds); this.currentsection = parentSect; } else { this.PrintDocCmd(ds); } this.currentTable = null; } }
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); }
private void parseEnum(Type Enum) { if (Enum.Namespace == null || Enum.Name.Any(c => c == '<' || c == '>')) { //this.Log(LogKind.Warning,Class.ToString()+ " isn't in any namespace."); return; } FieldInfo[] field = Enum.GetFields().Where(c => !c.Name.Equals("value__")).ToArray(); PropertyInfo[] propertys = Enum.GetProperties(); MethodInfo[] methods = Enum.GetMethods(); ConstructorInfo[] constructors = Enum.GetConstructors(); Type[] NestedTypes = Enum.GetNestedTypes(); DoxNamespace dns = (DoxNamespace)Model.Compounds.FirstOrDefault(c => c.Identifier.Equals(Enum.Namespace)); if (dns == null) { CompoundIndex ci = new CompoundIndex(); this.Index.Compounds.Add(ci); ci.Name = Enum.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); } DoxEnum dc = new DoxEnum(); dc.Abstract = Enum.IsAbstract; dc.Identifier = Enum.FullName.Replace('+', '.'); dc.Kind = CompoundKind.Enum; dc.Name = Enum.FullName; dc.Sealed = Enum.IsSealed; if (propertys.Length > 0) { parseProperty(propertys, dc); } if (field.Length > 0) { parseField(field, dc); } if (methods.Length > 0) { parseMethod(methods, dc); } if (constructors.Length > 0) { parseCtor(constructors, 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); }
void IApiDocTemplateProcessor.Process(NamespaceListTemplate template) { var namespaces = from c in this.model.Compounds where c.Kind == CompoundKind.Namespace orderby c.Name select c; foreach (var ns in namespaces) { this.currentNamespace = (DoxNamespace)ns; if (HasContent(this.currentNamespace, template)) { string name = generator.NormalizeName(ns.Name); generator.PrintSection("Namespace: " + name, ns.Identifier); this.generator.NextSectionLevel(); template.ProcessItems(this); this.generator.PreviousSectionLevel(); } this.currentNamespace = null; } }
public void Generate() { this.currentNamespace = null; this.currentClassifier = null; this.currentMember = null; template.Process(this); }
private static bool HasContent(DoxNamespace ns, NamespaceListTemplate template) { // TODO return ns.Classifiers.Count > 0; }