Beispiel #1
0
        private void appendDocumentation(String idString, String comment)
        {
            var xml = "<?xml version=\"1.0\"?><member name=\"" + idString + "\">" + comment + "</member>";

            try {
                var doc    = XmlHelper.load(new StringReader(xml));
                var member = doc.getDocumentElement();
                var copy   = (Element)document.importNode(member, false);
                members.appendChild(copy);
                foreach (var e in member.elements())
                {
                    copyTopLevelElement(e, copy);
                }
            } catch (org.xml.sax.SAXException) {
                context.addWarning(CompileErrorId.MalformedXmlComment, node, idString);
                members.appendChild(document.createComment(idString + " is documented with a malformed XML comment"));
            }
        }
Beispiel #2
0
 private void copyNestedElementChildren(Element copy, Element nested)
 {
     for (var n = nested.getFirstChild(); n != null; n = n.getNextSibling())
     {
         if (n.getNodeType() == Node.ELEMENT_NODE)
         {
             copyNestedElement((Element)n, copy);
         }
         else
         {
             copy.appendChild(document.importNode(n, true));
         }
     }
 }
Beispiel #3
0
        private void include(Element include, Element parent, bool nested)
        {
            var dir  = PathHelper.getDirectoryName(node.Filename);
            var file = include.getAttribute("file");

            if (Helper.isNullOrEmpty(file))
            {
                context.addWarning(CompileErrorId.MissingDocAttribute, node, "file", "include");
                parent.appendChild(document.importNode(include, true));
                return;
            }
            var path = include.getAttribute("path");

            if (Helper.isNullOrEmpty(file))
            {
                context.addWarning(CompileErrorId.MissingDocAttribute, node, "path", "include");
                parent.appendChild(document.importNode(include, true));
                return;
            }
            var filename    = PathHelper.combine(dir, include.getAttribute("file"));
            var includeFile = new File(filename);

            try {
                var doc      = XmlHelper.load(new FileInputStream(includeFile));
                var nodeList = doc.getNodeList(path);
                for (int i = 0; i < nodeList.getLength(); i++)
                {
                    var node = nodeList.item(i);
                    if (node.getNodeType() == Node.ELEMENT_NODE)
                    {
                        if (nested)
                        {
                            copyNestedElement((Element)node, parent);
                        }
                        else
                        {
                            copyTopLevelElement((Element)node, parent);
                        }
                    }
                    else
                    {
                        parent.appendChild(document.importNode(include, true));
                    }
                }
            } catch (XPathExpressionException) {
                context.addWarning(CompileErrorId.IncludePathInvalid, node, path);
                parent.appendChild(document.importNode(include, true));
            } catch (org.xml.sax.SAXException) {
                context.addWarning(CompileErrorId.IncludeFileInvalid, node, filename);
                parent.appendChild(document.importNode(include, true));
            } catch (IOException) {
                context.addWarning(CompileErrorId.IncludeFileNotFound, node, filename);
                parent.appendChild(document.importNode(include, true));
            }
        }
Beispiel #4
0
        private void copyTopLevelElement(Element e, Element parent)
        {
            if (e.getNamespaceURI() == null)
            {
                switch (e.getLocalName())
                {
                case "summary":
                case "remarks":
                case "value":
                case "returns":
                case "example":
                    parent.appendChild(copyContainer(e));
                    break;

                case "include":
                    include(e, parent, false);
                    break;

                case "exception":
                    parent.appendChild(copyException(e));
                    break;

                case "param":
                    parent.appendChild(copyParam(e));
                    break;

                case "typeparam":
                    parent.appendChild(copyTypeparam(e));
                    break;

                case "seealso":
                    parent.appendChild(copySeealso(e));
                    break;

                case "code":
                default:
                    parent.appendChild((Element)document.importNode(e, true));
                    break;
                }
            }
            else
            {
                parent.appendChild((Element)document.importNode(e, true));
            }
        }
Beispiel #5
0
        private void copyNestedElement(Element nested, Element parent)
        {
            if (nested.getNamespaceURI() == null)
            {
                switch (nested.getLocalName())
                {
                case "c":
                case "para":
                case "list":
                case "listheader":
                case "item":
                case "term":
                case "description":
                    parent.appendChild(copyContainer(nested));
                    break;

                case "include":
                    include(nested, parent, true);
                    break;

                case "see":
                    parent.appendChild(copySee(nested));
                    break;

                case "paramref":
                    parent.appendChild(copyParamref(nested));
                    break;

                case "typeparamref":
                    parent.appendChild(copyTypeparamref(nested));
                    break;

                default:
                    parent.appendChild((Element)document.importNode(nested, true));
                    break;
                }
            }
            else
            {
                parent.appendChild((Element)document.importNode(nested, true));
            }
        }
 private void copyNestedElement(Element nested, Element parent) {
     if (nested.getNamespaceURI() == null) {
         switch (nested.getLocalName()) {
         case "c":
         case "para":
         case "list":
         case "listheader":
         case "item":
         case "term":
         case "description":
             parent.appendChild(copyContainer(nested));
             break;
         case "include":
             include(nested, parent, true);
             break;
         case "see":
             parent.appendChild(copySee(nested));
             break;
         case "paramref":
             parent.appendChild(copyParamref(nested));
             break;
         case "typeparamref":
             parent.appendChild(copyTypeparamref(nested));
             break;
         default:
             parent.appendChild((Element)document.importNode(nested, true));
             break;
         }
     } else {
         parent.appendChild((Element)document.importNode(nested, true));
     }
 }
 private void copyNestedElementChildren(Element copy, Element nested) {
     for (var n = nested.getFirstChild(); n != null; n = n.getNextSibling()) {
         if (n.getNodeType() == Node.ELEMENT_NODE) {
             copyNestedElement((Element)n, copy);
         } else {
             copy.appendChild(document.importNode(n, true));
         }
     }
 }
 private void include(Element include, Element parent, bool nested) {
     var dir = PathHelper.getDirectoryName(node.Filename);
     var file = include.getAttribute("file");
     if (Helper.isNullOrEmpty(file)) {
         context.addWarning(CompileErrorId.MissingDocAttribute, node, "file", "include");
         parent.appendChild(document.importNode(include, true));
         return;
     }
     var path = include.getAttribute("path");
     if (Helper.isNullOrEmpty(file)) {
         context.addWarning(CompileErrorId.MissingDocAttribute, node, "path", "include");
         parent.appendChild(document.importNode(include, true));
         return;
     }
     var filename = PathHelper.combine(dir, include.getAttribute("file"));
     var includeFile = new File(filename);
     try {
         var doc = XmlHelper.load(new FileInputStream(includeFile));
         var nodeList = doc.getNodeList(path);
         for (int i = 0; i < nodeList.getLength(); i++) {
             var node = nodeList.item(i);
             if (node.getNodeType() == Node.ELEMENT_NODE) {
                 if (nested) {
                     copyNestedElement((Element)node, parent);
                 } else {
                     copyTopLevelElement((Element)node, parent);
                 }
             } else {
                 parent.appendChild(document.importNode(include, true));
             }
         }
     } catch (XPathExpressionException) {
         context.addWarning(CompileErrorId.IncludePathInvalid, node, path);
         parent.appendChild(document.importNode(include, true));
     } catch (org.xml.sax.SAXException) {
         context.addWarning(CompileErrorId.IncludeFileInvalid, node, filename);
         parent.appendChild(document.importNode(include, true));
     } catch (IOException) {
         context.addWarning(CompileErrorId.IncludeFileNotFound, node, filename);
         parent.appendChild(document.importNode(include, true));
     }
 }
 private void copyTopLevelElement(Element e, Element parent) {
     if (e.getNamespaceURI() == null) {
         switch (e.getLocalName()) {
         case "summary":
         case "remarks":
         case "value":
         case "returns":
         case "example":
             parent.appendChild(copyContainer(e));
             break;
         case "include":
             include(e, parent, false);
             break;
         case "exception":
             parent.appendChild(copyException(e));
             break;
         case "param":
             parent.appendChild(copyParam(e));
             break;
         case "typeparam":
             parent.appendChild(copyTypeparam(e));
             break;
         case "seealso":
             parent.appendChild(copySeealso(e));
             break;
         case "code":
         default:
             parent.appendChild((Element)document.importNode(e, true));
             break;
         }
     } else {
         parent.appendChild((Element)document.importNode(e, true));
     }
 }