コード例 #1
0
        /// <summary>
        /// e.g. Classes
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private string CheckNamespaceMembers(MetadataItem member)
        {
            StringBuilder message = new StringBuilder();

            // Skip if it is already invalid
            if (member.Items == null || member.IsInvalid)
            {
                return string.Empty;
            }

            foreach (var i in member.Items)
            {
                Debug.Assert(!i.Type.IsPageLevel());
                if (i.Type.IsPageLevel())
                {
                    Logger.Log(LogLevel.Error, $"Invalid item inside yaml metadata: {i.Type.ToString()} is not allowed inside {member.Type.ToString()}. Will be ignored.");
                    message.AppendFormat("{0} is not allowed inside {1}.", i.Type.ToString(), member.Type.ToString());
                    i.IsInvalid = true;
                }
                else
                {
                    var result = CheckNamespaceMembersMembers(i);
                    if (!string.IsNullOrEmpty(result))
                    {
                        message.AppendLine(result);
                    }
                }
            }

            return message.ToString();
        }
コード例 #2
0
        /// <summary>
        /// Only when Namespace is not empty, return it
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static MetadataItem ShrinkToSimpleTocWithNamespaceNotEmpty(this MetadataItem item)
        {
            MetadataItem shrinkedItem = new MetadataItem();
            shrinkedItem.Name = item.Name;
            shrinkedItem.DisplayNames = item.DisplayNames;
            shrinkedItem.Type = item.Type;
            shrinkedItem.Items = null;

            if (item.Type == MemberType.Toc || item.Type == MemberType.Namespace)
            {
                if (item.Items != null)
                {
                    foreach (var i in item.Items)
                    {
                        if (shrinkedItem.Items == null)
                        {
                            shrinkedItem.Items = new List<MetadataItem>();
                        }

                        if (i.IsInvalid) continue;
                        var shrinkedI = i.ShrinkToSimpleTocWithNamespaceNotEmpty();
                        if (shrinkedI != null) shrinkedItem.Items.Add(shrinkedI);
                    }
                }
            }

            if (item.Type == MemberType.Namespace)
            {
                if (shrinkedItem.Items == null || shrinkedItem.Items.Count == 0) return null;
            }

            return shrinkedItem;
        }
コード例 #3
0
        public static MetadataItem ShrinkToSimpleToc(this MetadataItem item)
        {
            MetadataItem shrinkedItem = new MetadataItem();
            shrinkedItem.Name = item.Name;
            shrinkedItem.DisplayNames = item.DisplayNames;

            shrinkedItem.Href = item.Href;
            shrinkedItem.Items = null;

            if (item.Items == null)
            {
                return shrinkedItem;
            }

            if (item.Type == MemberType.Toc || item.Type == MemberType.Namespace)
            {
                foreach (var i in item.Items)
                {
                    if (shrinkedItem.Items == null)
                    {
                        shrinkedItem.Items = new List<MetadataItem>();
                    }

                    if (i.IsInvalid) continue;
                    var shrinkedI = i.ShrinkToSimpleToc();
                    shrinkedItem.Items.Add(shrinkedI);
                }

            }

            return shrinkedItem;
        }
コード例 #4
0
 public override void DefaultVisit(ISymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
 {
     foreach (var generator in _generators)
     {
         generator.DefaultVisit(symbol, item, adapter);
     }
 }
コード例 #5
0
ファイル: ResolveReference.cs プロジェクト: yonglehou/docfx
 private void AddIndirectReference(ResolverContext context, MetadataItem page, List<ReferenceItem> addedReferences)
 {
     while (addedReferences.Count > 0)
     {
         var addingReferences = new List<ReferenceItem>();
         foreach (var r in addedReferences)
         {
             foreach (var key in GetReferenceKeys(r))
             {
                 TryAddReference(context, page, addingReferences, key);
             }
         }
         addedReferences = addingReferences;
     }
 }
コード例 #6
0
ファイル: ResolveReference.cs プロジェクト: yonglehou/docfx
 private static void TryAddReference(ResolverContext context, MetadataItem page, List<ReferenceItem> addingReferences, string key)
 {
     if (!page.References.ContainsKey(key))
     {
         ReferenceItem item;
         if (context.References.TryGetValue(key, out item))
         {
             var reference = context.References[key].Clone();
             page.References.Add(key, reference);
             addingReferences.Add(reference);
         }
         else
         {
             Debug.Fail(string.Format("Reference not found: {0}", key));
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// e.g. Classes
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private ParseResult CheckNamespaceMembers(MetadataItem member)
        {
            ParseResult overall = new ParseResult(ResultLevel.Success);
            StringBuilder message = new StringBuilder();

            // Skip if it is already invalid
            if (member.Items == null || member.IsInvalid)
            {
                return overall;
            }


            foreach (var i in member.Items)
            {
                Debug.Assert(!i.Type.IsPageLevel());
                if (i.Type.IsPageLevel())
                {
                    Logger.Log(LogLevel.Error, $"Invalid item inside yaml metadata: {i.Type.ToString()} is not allowed inside {member.Type.ToString()}. Will be ignored.");
                    message.AppendFormat("{0} is not allowed inside {1}.", i.Type.ToString(), member.Type.ToString());
                    i.IsInvalid = true;
                }
                else
                {
                    ParseResult result = CheckNamespaceMembersMembers(i);
                    if (!string.IsNullOrEmpty(result.Message))
                    {
                        message.AppendLine(result.Message);
                    }
                }
            }

            if (message.Length > 0)
            {
                overall.ResultLevel = ResultLevel.Warning;
                overall.Message = message.ToString();
            }

            return overall;
        }
コード例 #8
0
        /// <summary>
        /// e.g. Methods
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private string CheckNamespaceMembersMembers(MetadataItem member)
        {
            StringBuilder message = new StringBuilder();
            if (member.IsInvalid)
            {
                return string.Empty;
            }

            // does method has members?
            Debug.Assert(member.Items == null);
            if (member.Items != null)
            {
                foreach (var i in member.Items)
                {
                    i.IsInvalid = true;
                }

                Logger.Log(LogLevel.Error, $"Invalid item inside yaml metadata: {member.Type.ToString()} should not contain items. Will be ignored.");
                message.AppendFormat("{0} should not contain items.", member.Type.ToString());
            }

            return message.ToString();
        }
コード例 #9
0
ファイル: YamlModelGenerator.cs プロジェクト: yonglehou/docfx
 public virtual void GenerateProperty(IPropertySymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
 {
 }
コード例 #10
0
ファイル: YamlModelGenerator.cs プロジェクト: yonglehou/docfx
 public virtual void GenerateEvent(IEventSymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
 {
 }
コード例 #11
0
ファイル: YamlModelGenerator.cs プロジェクト: yonglehou/docfx
 public virtual void GenerateField(IFieldSymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
 {
 }
コード例 #12
0
ファイル: YamlModelGenerator.cs プロジェクト: yonglehou/docfx
 public virtual void GenerateMethod(IMethodSymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
 {
 }
コード例 #13
0
ファイル: YamlModelGenerator.cs プロジェクト: yonglehou/docfx
 public virtual void GenerateNamedType(INamedTypeSymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
 {
 }
コード例 #14
0
ファイル: YamlModelGenerator.cs プロジェクト: yonglehou/docfx
 public virtual void DefaultVisit(ISymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
 {
 }
コード例 #15
0
ファイル: VisitorHelper.cs プロジェクト: yonglehou/docfx
 public static void FeedComments(MetadataItem item, ITripleSlashCommentParserContext context)
 {
     if (!string.IsNullOrEmpty(item.RawComment))
     {
         var commentModel = TripleSlashCommentModel.CreateModel(item.RawComment, context);
         if (commentModel == null) return;
         item.Summary = commentModel.Summary;
         item.Remarks = commentModel.Remarks;
         item.Exceptions = commentModel.Exceptions;
         item.Sees = commentModel.Sees;
         item.SeeAlsos = commentModel.SeeAlsos;
         item.Examples = commentModel.Examples;
         item.CommentModel = commentModel;
     }
 }
コード例 #16
0
 public override void DefaultVisit(ISymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
 {
     item.DisplayNames[SyntaxLanguage.VB] = NameVisitorCreator.GetVB(NameOptions.WithGenericParameter | NameOptions.WithParameter).GetName(symbol);
     item.DisplayQualifiedNames[SyntaxLanguage.VB] = NameVisitorCreator.GetVB(NameOptions.Qualified | NameOptions.WithGenericParameter | NameOptions.WithParameter).GetName(symbol);
 }
コード例 #17
0
ファイル: VisitorHelper.cs プロジェクト: yonglehou/docfx
 public static ApiParameter GetParameterDescription(ISymbol symbol, MetadataItem item, string id, bool isReturn, ITripleSlashCommentParserContext context)
 {
     string comment = isReturn ? item.CommentModel?.Returns : item.CommentModel?.GetParameter(symbol.Name);
     return new ApiParameter
     {
         Name = isReturn ? null : symbol.Name,
         Type = id,
         Description = comment,
     };
 }
コード例 #18
0
ファイル: VisitorHelper.cs プロジェクト: yonglehou/docfx
 public static ApiParameter GetTypeParameterDescription(ITypeParameterSymbol symbol, MetadataItem item, ITripleSlashCommentParserContext context)
 {
     string comment = item.CommentModel?.GetTypeParameter(symbol.Name);
     return new ApiParameter
     {
         Name = symbol.Name,
         Description = comment,
     };
 }
コード例 #19
0
ファイル: ResolveReference.cs プロジェクト: yonglehou/docfx
        private IEnumerable<string> GetReferenceKeys(MetadataItem current)
        {
            if (current.NamespaceName != null)
            {
                yield return current.NamespaceName;
            }

            if (current.Overridden != null)
            {
                yield return current.Overridden;
            }

            if (current.Inheritance != null && current.Inheritance.Count > 0)
            {
                foreach (var item in current.Inheritance)
                {
                    yield return item;
                }
            }

            if (current.InheritedMembers != null && current.InheritedMembers.Count > 0)
            {
                foreach (var item in current.InheritedMembers)
                {
                    yield return item;
                }
            }

            if (current.Exceptions != null && current.Exceptions.Count > 0)
            {
                foreach (var item in current.Exceptions)
                {
                    yield return item.Type;
                }
            }

            if (current.Sees != null && current.Sees.Count > 0)
            {
                foreach (var item in current.Sees)
                {
                    yield return item.Type;
                }
            }

            if (current.SeeAlsos != null && current.SeeAlsos.Count > 0)
            {
                foreach (var item in current.SeeAlsos)
                {
                    yield return item.Type;
                }
            }

            if (current.Syntax != null)
            {
                if (current.Syntax.Parameters != null)
                {
                    foreach (var item in current.Syntax.Parameters)
                    {
                        yield return item.Type;
                    }
                }

                if (current.Syntax.Return != null)
                {
                    yield return current.Syntax.Return.Type;
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// e.g. Methods
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private ParseResult CheckNamespaceMembersMembers(MetadataItem member)
        {
            ParseResult overall = new ParseResult(ResultLevel.Success);
            StringBuilder message = new StringBuilder();
            if (member.IsInvalid)
            {
                return overall;
            }

            // does method has members?
            Debug.Assert(member.Items == null);
            if (member.Items != null)
            {
                foreach (var i in member.Items)
                {
                    i.IsInvalid = true;
                }

                Logger.Log(LogLevel.Error, $"Invalid item inside yaml metadata: {member.Type.ToString()} should not contain items. Will be ignored.");
                message.AppendFormat("{0} should not contain items.", member.Type.ToString());
            }

            if (message.Length > 0)
            {
                overall.ResultLevel = ResultLevel.Warning;
                overall.Message = message.ToString();
            }

            return overall;
        }