Beispiel #1
0
        public void Generate(string applicationPath, IEnumerable <DocumentationCategory> categories, string outputFolder)
        {
            if (!string.IsNullOrEmpty(CodePath))
            {
                var root  = Path.Combine(applicationPath, CodePath);
                var files = Directory.EnumerateFiles(root, "*.cs", SearchOption.AllDirectories);
                var file  = new StringBuilder();

                var roots = categories.Where(category => category.IncludeInTableOfContents).Select(category => new Category
                {
                    Name          = category.Name,
                    NiceName      = DocumentationGenerator.GetNiceName(category.Name),
                    Id            = DocumentationGenerator.GetId(category.Name),
                    Documentation = category,
                    Sections      = Sections
                                    .Select(sectionName => new Section
                    {
                        Name     = sectionName,
                        NiceName = DocumentationGenerator.GetNiceName(sectionName),
                        Id       = DocumentationGenerator.GetId(sectionName),
                        Types    = GetTypes(category, sectionName, files)
                    })
                                    .ToList()
                });

                foreach (var category in roots)
                {
                    var contents = GenerateCategory(category);
                    file.Append(contents);
                }

                var tableOfContents = Templates.File.Replace(_categoriesTag, file.ToString());
                DocumentationGenerator.WriteFile(outputFolder, OutputFile, tableOfContents);
            }
        }
Beispiel #2
0
 public DocumentationType(Type type, DocumentationCategory category)
 {
     Type     = type;
     Name     = DocumentationGenerator.GetCleanName(type);
     RawName  = type.Name;
     NiceName = DocumentationGenerator.GetNiceName(Name);
     Id       = DocumentationGenerator.GetTypeId(type);
     Filename = GetFilename(category);
     Link     = category.GetLink(type);
 }
Beispiel #3
0
        private string GenerateField(FieldInfo field, DocumentationCategory category)
        {
            var type     = category.GetLink(field.FieldType);
            var niceName = DocumentationGenerator.GetNiceName(field.Name);

            return(category.Templates.Field
                   .Replace(_memberTypeTag, type)
                   .Replace(_memberNameTag, field.Name)
                   .Replace(_memberNiceNameTag, niceName));
        }
Beispiel #4
0
        private string GetTypeLink(Type type, DocumentationCategory category, string template)
        {
            var cleanName = DocumentationGenerator.GetCleanName(type);
            var niceName  = DocumentationGenerator.GetNiceName(cleanName);
            var id        = DocumentationGenerator.GetTypeId(type);

            return(template
                   .Replace(DocumentationGenerator.CategoryNameTag, category?.Name)
                   .Replace(DocumentationGenerator.CategoryNiceNameTag, category?.NiceName)
                   .Replace(DocumentationGenerator.CategoryIdTag, category?.Id)
                   .Replace(DocumentationGenerator.TypeIdTag, id)
                   .Replace(DocumentationGenerator.TypeNameTag, cleanName)
                   .Replace(DocumentationGenerator.TypeRawNameTag, type.Name)
                   .Replace(DocumentationGenerator.TypeNiceNameTag, niceName)
                   .Replace(DocumentationGenerator.TypeNamespaceTag, type.Namespace)
                   .Replace('`', '-'));             // this is specific to msdn but potentially makes sense for other scenarios as well
        }
Beispiel #5
0
        public string Generate(DocumentationType type, DocumentationCategory category)
        {
            var niceName = DocumentationGenerator.GetNiceName(Name);
            var id       = DocumentationGenerator.GetId(Name);

            var members = type.Type.IsEnum
                                ? GenerateValues(type, category)
                                : GenerateMembers(type, category);

            return(!string.IsNullOrEmpty(members)
                                ? category.Templates.Section
                   .Replace(DocumentationGenerator.SectionNameTag, Name)
                   .Replace(DocumentationGenerator.SectionNiceNameTag, niceName)
                   .Replace(DocumentationGenerator.SectionIdTag, id)
                   .Replace(DocumentationGenerator.TypeIdTag, type.Id)
                   .Replace(DocumentationGenerator.TypeIdTag, type.Name)
                   .Replace(DocumentationGenerator.TypeIdTag, type.NiceName)
                   .Replace(_membersTag, members)
                                : "");
        }
Beispiel #6
0
        public void Generate(IEnumerable <DocumentationCategory> allCategories, string outputFolder)
        {
            Id            = DocumentationGenerator.GetId(Name);
            NiceName      = DocumentationGenerator.GetNiceName(Name);
            AllCategories = allCategories;

            var types = GetTypes();
            var index = new StringBuilder();
            var files = new List <string>();
            var first = true;

            foreach (var type in types)
            {
                var typeIndex = type.GenerateIndex(this);
                var typeFile  = type.GenerateFile(this);

                if (!first)
                {
                    index.Append(Templates.TypeSeparator);
                }

                index.Append(typeIndex);
                first = false;

                DocumentationGenerator.WriteFile(outputFolder, type.Filename, typeFile);
            }

            var contents = Templates.CategoryFile
                           .Replace(DocumentationGenerator.CategoryNameTag, Name)
                           .Replace(DocumentationGenerator.CategoryNiceNameTag, NiceName)
                           .Replace(DocumentationGenerator.CategoryIdTag, Id)
                           .Replace(_typesTag, index.ToString());

            var filename = CategoryFilename
                           .Replace(DocumentationGenerator.CategoryNameTag, Name)
                           .Replace(DocumentationGenerator.CategoryNiceNameTag, NiceName)
                           .Replace(DocumentationGenerator.CategoryIdTag, Id);

            DocumentationGenerator.WriteFile(outputFolder, filename, contents);
        }