コード例 #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);
            }
        }
コード例 #2
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)
                                : "");
        }
コード例 #3
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);
        }