Ejemplo n.º 1
0
        /// <summary>
        ///     Gets markdown string of given type.
        ///     It includes type reference.
        /// </summary>
        internal static string GetTypeMarkdown(Type t, bool quote = true, string fixedName = null)
        {
            var name     = string.Empty;
            var typeName = DocSyntax.FixVarName(t.Name); // fix type name

            if (t.IsByRef)
            {
                typeName = typeName.Remove(typeName.Length - 1, 1);
                typeName = $"ref {typeName}";
            }

            if (!string.IsNullOrEmpty(fixedName))
            {
                typeName += $" {fixedName}";
            }

            if (!CanDefineTypeReference(t))
            {
                if (quote)
                {
                    name += "`";
                }
                name += typeName;
                if (quote)
                {
                    name += "`";
                }
                name += " ";
            }
            else
            {
                name += "[";
                if (quote)
                {
                    name += "`";
                }
                name += typeName;
                if (quote)
                {
                    name += "`";
                }
                name += $"]({DocSyntax.CollectMarkDownReference(t)})";
            }

            return(name);
        }
Ejemplo n.º 2
0
        private void BuildExample(Type t, StringBuilder str)
        {
            var exampleFile = FindExampleFile(t);

            if (string.IsNullOrEmpty(exampleFile))
            {
                return;
            }

            str.AppendLine();
            str.AppendLine("## Examples");
            str.AppendLine();
            var exampleStr = File.ReadAllText(exampleFile);
            var allTypes   = t.Assembly.GetTypes();

            foreach (var a in allTypes)
            {
                var s = a.Name;
                exampleStr = exampleStr.Replace($"(#{s})", $"({DocSyntax.CollectMarkDownReference(a)})");
            }

            str.AppendLine(exampleStr);
        }