A documentation visitor.
Inheritance: NuDoq.Visitor
Ejemplo n.º 1
0
        public static string MemberAnchor(object obj)
        {
            string anchor = String.Empty;

            if (obj is Type)
            {
                anchor = ((Type)obj).FullName;
            }
            else if (obj is MethodInfo)
            {
                anchor = (IsNonconversionOperator(((MethodInfo)obj).Name)) ?
                         ((MethodInfo)obj).Name :
                         DocVisitor.FormatMethod((MethodInfo)obj, true);
            }
            else
            {
                anchor = (obj is PropertyInfo) ?
                         DocVisitor.FormatProperty((PropertyInfo)obj, true) :
                         ((obj is FieldInfo) ?
                          ((FieldInfo)obj).Name : obj.ToString());
            }
            anchor = anchor.Trim();
            anchor = Regex.Replace(anchor, "\\(\\)", String.Empty);
            anchor = Regex.Replace(anchor, "\\W+", "_");
            anchor = Regex.Replace(anchor, "_+$", String.Empty);
            return(anchor);
        }
Ejemplo n.º 2
0
 public static string FormatMember(object obj)
 {
     if (obj is Type)
     {
         string m = ((Type)obj).FullName;
         m = Regex.Replace(m, "\\+", ".");
         m = Regex.Replace(m, "\\s+", " ");
         m = m.Trim();
         return(m);
     }
     if (obj is MethodInfo)
     {
         string m = DocVisitor.FormatMethod((MethodInfo)obj, true);
         m = Regex.Replace(m, "\\s+", " ");
         m = m.Trim();
         return(m);
     }
     if (obj is PropertyInfo)
     {
         string m = DocVisitor.FormatProperty((PropertyInfo)obj, true);
         m = Regex.Replace(m, "\\s+", " ");
         m = m.Trim();
         return(m);
     }
     if (obj is FieldInfo)
     {
         string m = DocVisitor.FormatField((FieldInfo)obj);
         m = Regex.Replace(m, "\\s+", " ");
         m = m.Trim();
         return(m);
     }
     return(obj.ToString());
 }
Ejemplo n.º 3
0
        public override void VisitMember(Member member)
        {
            Type currentType;

            if (member.Info is Type)
            {
                currentType = (Type)member.Info;
            }
            else
            {
                if (member.Info == null)
                {
                    return;
                }
                currentType = member.Info.ReflectedType;
            }
            if (currentType == null || !currentType.IsPublic)
            {
                return;
            }
            if (!this.docs.ContainsKey(currentType))
            {
                var docVisitor = new DocVisitor();
                this.docs[currentType] = docVisitor;
            }
            this.docs[currentType].VisitMember(member);
            base.VisitMember(member);
        }
Ejemplo n.º 4
0
        public void HandleMember(MemberInfo info, XmlDoc xmldoc)
        {
            Type currentType;

            if (info is Type)
            {
                currentType = (Type)info;
            }
            else
            {
                if (info == null)
                {
                    return;
                }
                currentType = info.ReflectedType;
            }
            if (currentType == null ||
                !(currentType.IsNested ? currentType.IsNestedPublic :
                  currentType.IsPublic))
            {
                return;
            }
            var typeFullName = currentType.FullName;

            if (!this.docs.ContainsKey(typeFullName))
            {
                var docVisitor = new DocVisitor();
                this.docs[typeFullName]         = docVisitor;
                this.typeIDs[typeFullName]      = DocVisitor.GetTypeID(currentType);
                this.memSummaries[typeFullName] = new MemberSummaryVisitor();
            }
            this.docs[typeFullName].HandleMember(info, xmldoc);
            this.memSummaries[typeFullName].HandleMember(info, xmldoc);
        }
Ejemplo n.º 5
0
        public static string MemberAnchor(object obj)
        {
            string anchor = String.Empty;

            if (obj is Type)
            {
                anchor = ((Type)obj).FullName;
            }
            else if (obj is MethodInfo)
            {
                anchor = (((MethodInfo)obj).Name.IndexOf(
                              "op_",
                              StringComparison.Ordinal) == 0) ? ((MethodInfo)obj).Name :
                         DocVisitor.FormatMethod((MethodInfo)obj, true);
            }
            else
            {
                anchor = (obj is PropertyInfo) ?
                         DocVisitor.FormatProperty((PropertyInfo)obj, true) :
                         ((obj is FieldInfo) ?
                          ((FieldInfo)obj).Name : obj.ToString());
            }
            anchor = anchor.Trim();
            anchor = Regex.Replace(anchor, "\\(\\)", String.Empty);
            anchor = Regex.Replace(anchor, "\\W+", "_");
            anchor = Regex.Replace(anchor, "_+$", String.Empty);
            return(anchor);
        }
Ejemplo n.º 6
0
            public TypeLinkAndBuilder(Type type)
            {
                var typeName = DocVisitor.FormatType(type);

                typeName = "[" + DocGenUtil.HtmlEscape(typeName) + "](" +
                           DocVisitor.GetTypeID(type) + ".md)";
                this.TypeLink = typeName;
                this.Builder  = new StringBuilder();
            }
Ejemplo n.º 7
0
            public TypeLinkAndBuilder(Type type)
            {
                var typeName = DocVisitor.FormatType(type);

                typeName      = typeName.Replace("&", "&");
                typeName      = typeName.Replace("<", "&lt;");
                typeName      = typeName.Replace(">", "&gt;");
                typeName      = "[" + typeName + "](" + DocVisitor.GetTypeID(type) + ".md)";
                this.TypeLink = typeName;
                this.Builder  = new StringBuilder();
            }
Ejemplo n.º 8
0
 public void Finish()
 {
     foreach (var key in this.docs.Keys)
     {
         var finalString = this.docs[key].ToString();
         var filename    = Path.Combine(
             this.directory,
             DocVisitor.GetTypeID(key) + ".md");
         using (var writer = new StreamWriter(filename, false, Encoding.UTF8)) {
             finalString = Regex.Replace(
                 finalString,
                 @"\r?\n(\r?\n)+",
                 "\r\n\r\n");
             writer.WriteLine(finalString);
         }
     }
 }
Ejemplo n.º 9
0
 public void Finish()
 {
     this.writer.Write("## API Documentation\r\n\r\n");
     foreach (var key in this.docs.Keys)
     {
         var finalString = this.docs[key].ToString();
         var typeName    = DocVisitor.FormatType(key);
         typeName = typeName.Replace("&", "&amp;");
         typeName = typeName.Replace("<", "&lt;");
         typeName = typeName.Replace(">", "&gt;");
         typeName = "[" + typeName + "](" + DocVisitor.GetTypeID(key) + ".md)";
         if (finalString.IndexOf(".", StringComparison.Ordinal) >= 0)
         {
             finalString = finalString.Substring(
                 0,
                 finalString.IndexOf(".", StringComparison.Ordinal) + 1);
         }
         finalString = Regex.Replace(finalString, @"\r?\n(\r?\n)+", "\r\n\r\n");
         this.writer.Write(" * " + typeName + " - ");
         this.writer.WriteLine(finalString);
     }
 }
Ejemplo n.º 10
0
 public BufferChanger(DocVisitor vis, StringBuilder buffer)
 {
     this.vis          = vis;
     this.oldBuffer    = vis.currentBuffer;
     vis.currentBuffer = buffer;
 }
Ejemplo n.º 11
0
 public BufferChanger(DocVisitor vis, StringBuilder buffer)
 {
     this.vis = vis;
     this.oldBuffer = vis.currentBuffer;
     vis.currentBuffer = buffer;
 }