Пример #1
0
        private string RenderTocType(Model.Type type)
        {
            var id     = GetUsableId(type.Id);
            var name   = GetPresentableTypeName(type);
            var result = "- Type " + string.Format(MarkdownTemplates.Link, name, "#" + id);

            if (type.Methods.Any() || type.Properties.Any())
            {
                result += " (";
                if (type.Properties.Any())
                {
                    result += string.Format(MarkdownTemplates.Link, "Properties", "#" + id + "_Properties");
                    if (type.Methods.Any())
                    {
                        result += ", ";
                    }
                }
                if (type.Methods.Any())
                {
                    result += string.Format(MarkdownTemplates.Link, "Methods", "#" + id + "_Methods");
                }
                result += ")\r\n";
            }
            return(result);
        }
Пример #2
0
 private string RenderType(Model.Type type)
 {
     return(string.Format(MarkdownTemplates.TypeFormat,
                          GetUsableId(type.Id),
                          GetPresentableTypeName(type),
                          RenderDocumentation(type.Documentation),
                          RenderTypeParameters(type.TypeParameters),
                          RenderProperties(type.Properties),
                          RenderMethods(type.Methods)
                          ));
 }
Пример #3
0
        private string GetPresentableTypeName(Model.Type type)
        {
            var match = Regex.Match(type.Name, "`+(?<genericParams>\\d)");

            if (!match.Success)
            {
                return(type.Name);
            }
            var paramTypes         = new List <string>();
            var genericParamsCount = int.Parse(match.Groups["genericParams"].Value);

            for (int i = 0; i < genericParamsCount; i++)
            {
                if (i < type.TypeParameters.Count)
                {
                    paramTypes.Add(type.TypeParameters[i].Name);
                }
                else
                {
                    paramTypes.Add("T" + (i + 1));
                }
            }
            return(type.Name.Replace(match.Value, $"<{string.Join(",", paramTypes)}>"));
        }
Пример #4
0
 //private string RelativeCodeFileFor(Type type)
 //{
 //    return $"{RelativeFolderFor(type)}/{Regex.Replace(type.Name, "`\\d+", "")}.cs";
 //}
 private string RelativeLocationFor(Model.Type type)
 {
     return($"{RelativeFileFor(type)}#{GetUsableId(type.Id)}");
 }
Пример #5
0
 private string RelativeFileFor(Model.Type type)
 {
     return($"{RelativeFolderFor(type)}{Path.DirectorySeparatorChar}Classes.md");
 }
Пример #6
0
 private string RelativeFolderFor(Model.Type type)
 {
     return(string.Join(Path.DirectorySeparatorChar.ToString(), type.NamespaceStrings));
 }