Logo Search packages:      
Sourcecode: ndoc version File versions  Download package

void NDoc::Documenter::LinearHtml::LinearHtmlDocumenter::MakeHtmlForTypeUsingCs ( XPathNavigator  nav,
XmlTextWriter  xtw,
string  namespaceName 
) [inline, private]

Document the current node's type using C#.

Parameters:
nav 
xtw 
namespaceName 

Definition at line 1247 of file LinearHtmlDocumenter.cs.

            {
                  string nodeName = nav.GetAttribute("name", "");
                  string nodeType = nav.LocalName;
                  string capsItemType = char.ToUpper(nodeType[0]) + nodeType.Substring(1);

                  // put in an h3 anchor for links to this type
                  xtw.WriteStartElement("h3");
                  xtw.WriteStartElement("a");
                  xtw.WriteAttributeString("name", GetTypeHtmlId(nodeName));
                  xtw.WriteEndElement();
                  xtw.WriteString(String.Format("{0} {1}", nodeName, capsItemType));
                  xtw.WriteEndElement(); // h3

                  //
                  // collect navigators to various members by category
                  //
                  Hashtable memberTypeHt = new Hashtable(); // memberType -> Hashtable (id -> navigator)
                  nav.MoveToFirstChild();
                  Hashtable navTable;

                  do 
                  {
                        // each member of type
                        string memberType = nav.LocalName;
                        string memberId = nav.GetAttribute("id", "");

                        if (!memberTypeHt.ContainsKey(memberType)) 
                        {
                              //Console.WriteLine("Add member type {0}", memberType);
                              memberTypeHt.Add(memberType, new Hashtable());
                        }
                        navTable = (Hashtable)memberTypeHt[memberType];
                        if (!navTable.ContainsKey(memberId)) navTable.Add(memberId, nav.Clone());
                  } while(nav.MoveToNext());

                  nav.MoveToParent();

                  //
                  // Summary/declaration
                  //
                  xtw.WriteElementString("h4", "Summary");
                  string declarationString = MakeHtmlTypeDeclaration(nav);

                  xtw.WriteRaw("<p><code>" + declarationString + "</code></p>");

                  //
                  // documentation/summary
                  //
                  XPathNavigator remarksNav = null;
                  if (memberTypeHt.ContainsKey("documentation"))
                  {
                        navTable = (Hashtable)memberTypeHt["documentation"];
                        XPathNavigator nav2 = (XPathNavigator)navTable[String.Empty];
                        XPathNavigator summaryNav = GetDescendantNodeWithName(nav2, "summary");
                        remarksNav = GetDescendantNodeWithName(nav2, "remarks");

                        if (summaryNav != null) WriteNodeFixCode(xtw, summaryNav, "p");
                  }

                  // attributes
                  if (memberTypeHt.ContainsKey("attribute"))
                  {
                        navTable = (Hashtable)memberTypeHt["attribute"];
                        StringBuilder sb = new StringBuilder("This type has the following attributes: ");

                        bool first = true;
                        foreach(string memberId in navTable.Keys)
                        {
                              if (!first) { sb.Append(", "); first = false; }
                              //XPathNavigator nav2 = (XPathNavigator)navTable[memberId];
                              //this.DumpNavTree(nav2, "    ");
                              string tmps = ((XPathNavigator)navTable[memberId]).GetAttribute("name", "");
                              sb.Append(tmps);
                        }
                        xtw.WriteElementString("p", sb.ToString());
                  }

                  //
                  // documentation/remarks
                  //
                  if (remarksNav != null)
                  {
                        xtw.WriteElementString("h4", "Remarks");
                        WriteNodeFixCode(xtw, remarksNav, "p");
                  }

                  //
                  // the members (properties, methods, fields, etc) in the type
                  //
                  if (nodeType == "enumeration")
                  {
                        // enumerations
                        string memberType = "field"; // members are all fields in enumerations

                        if (memberTypeHt.ContainsKey(memberType))
                        {
                              xtw.WriteElementString("h4", String.Format("{0} Members", "Enumeration"));
                              string[] columnNames = { "Field", "Summary" };
                              StartTable(xtw, memberType + "_TableId_" + nodeName, 600, columnNames);

                              //
                              // create a table entry for each member of this Type
                              //
                              navTable = (Hashtable)memberTypeHt[memberType]; // memberId -> navigator

                              // sort by member id (approximately the member name?)
                              SortedList sortedMemberIds = new SortedList(navTable);

                              foreach(string memberId in sortedMemberIds.Keys)
                              {
                                    XPathNavigator nav2 = (XPathNavigator)navTable[memberId];
                                    string memberName = nav2.GetAttribute("name", "");

                                    // get summary
                                    string summaryString = string.Empty;
                                    XPathNavigator summaryNav = GetDescendantNodeWithName(nav2, "summary");
                                    if (summaryNav != null) summaryString = summaryNav.Value;
                                    
                                    this.AddTableEntry(xtw, memberName, summaryString);
                              }

                              EndTable(xtw);
                        }
                        else
                        {
                              // hmm, an enumeration with no fields?
                              Console.WriteLine("Error: LinearHtml: MakeHtmlForTypeUsingCs: No fields in enumeration {0}?",
                                    nodeName);
                        }
                  }
                  else
                  {
                        // struct, class, etc.

                        //
                        // member types which use name/access/summary table
                        //
                        foreach(string memberType in orderedMemberTypes) // memberType in constructor, field, property...
                        {
                              if (memberTypeHt.ContainsKey(memberType))
                              {
                                    string capsMemberType = char.ToUpper(memberType[0]) + memberType.Substring(1);
                                    xtw.WriteElementString("h4", String.Format("{0} Members", capsMemberType));
                                    navTable = (Hashtable)memberTypeHt[memberType]; // memberId -> navigator
                                    // sort by member id (approximately the member name?)
                                    SortedList sortedMemberIds = new SortedList(navTable);

                                    if (MyConfig.IncludeTypeMemberDetails && 
                                          (memberType.Equals("method") || memberType.Equals("constructor")))
                                    {
                                          // method, with details
                                          foreach(string memberId in sortedMemberIds.Keys)
                                          {
                                                XPathNavigator nav2 = (XPathNavigator)navTable[memberId];
                                                MakeHtmlDetailsForMethod(nodeName, memberType, nav2, xtw);
                                          }
                                    }
                                    else
                                    {
                                          // not a method, or no details
                                          string[] columnNames = { "Name", "Access", "Summary" };
                                          StartTable(xtw, memberType + "_TableId_" + nodeName, 600, columnNames);

                                          //
                                          // create a table entry for each member of this Type
                                          //
                                          foreach(string memberId in sortedMemberIds.Keys)
                                          {
                                                XPathNavigator nav2 = (XPathNavigator)navTable[memberId];
                                                MakeHtmlForTypeMember(nodeName, memberType, nav2, xtw);
                                          }

                                          EndTable(xtw);
                                    }
                              }
                        }
                  }
            }


Generated by  Doxygen 1.6.0   Back to index