Beispiel #1
0
 public IEnumerable <DocumentationType> GetTypes()
 {
     return(DocumentationGenerator
            .FindTypes(IsTypeIncluded)
            .Select(type => new DocumentationType(type, this))
            .OrderBy(type => type.Name));
 }
        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 #3
0
 private void UnloadGenerator()
 {
     if (_generator != null)
     {
         DestroyImmediate(_generator);
         _generator = null;
     }
 }
Beispiel #4
0
        private void SetGenerator(DocumentationGenerator generator, string path)
        {
            UnloadGenerator();

            _settingsFilePreference.Value = path;
            _generator = generator;

            CreateElements();
        }
        private string GenerateConstructor(ConstructorInfo constructor, DocumentationCategory category)
        {
            var name       = DocumentationGenerator.GetCleanName(constructor.DeclaringType);
            var parameters = GenerateParameters(constructor.GetParameters(), category);

            return(category.Templates.Constructor
                   .Replace(_memberNameTag, name)
                   .Replace(_memberParametersTag, parameters));
        }
        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 #7
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);
 }
        public void Generate(string outputFolder)
        {
            var types = DocumentationGenerator.FindTypes(type => !type.IsEnum && DocumentationGenerator.IsTypeIncluded(type, IncludedTypes, IncludedNamespaces, ExcludedNamespaces));

            var warnings = GenerateLogDescriptions(types, _warningFieldSuffix, MessageTemplate);
            var errors   = GenerateLogDescriptions(types, _errorFieldSuffix, MessageTemplate);

            var content = DocumentTemplate
                          .Replace(_logWarningsTag, warnings)
                          .Replace(_logErrorsTag, errors);

            DocumentationGenerator.WriteFile(outputFolder, OutputFile, content);
        }
Beispiel #9
0
        private bool SaveGenerator(DocumentationGenerator generator, string path)
        {
            try
            {
                var content    = JsonUtility.ToJson(generator, true);
                var outputFile = new FileInfo(path);

                Directory.CreateDirectory(outputFile.Directory.FullName);
                File.WriteAllText(outputFile.FullName, content);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #10
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 #11
0
        private string GetTypeLink(Type type)
        {
            if (DocumentationGenerator.IsTypeIncluded(type, IncludedNamespaces, ExcludedNamespaces))
            {
                return(GetTypeLink(type, this, Templates.InternalLink));
            }

            foreach (var external in ExternalNamespaces)
            {
                if (DocumentationGenerator.IsTypeIncluded(type, new List <string> {
                    external.Namespace
                }, ExcludedNamespaces))
                {
                    return(GetTypeLink(type, this, external.LinkTemplate));
                }
            }

            return(GetTypeLink(type, null, Templates.UnknownLink));
        }
        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)
                                : "");
        }
        public void Validate()
        {
            var types = DocumentationGenerator.FindTypes(type => DocumentationGenerator.IsTypeIncluded(type, DocumentationTypeCategory.Asset | DocumentationTypeCategory.Behaviour, IncludedNamespaces, ExcludedNamespaces));

            foreach (var type in types)
            {
                var id        = DocumentationGenerator.GetTypeId(type);
                var url       = UrlRoot + id;
                var attribute = type.GetAttribute <HelpURLAttribute>();

                if (attribute == null)
                {
                    Debug.LogWarningFormat(_missingHelpUrlWarning, type.Name);
                }
                else if (attribute.URL != url)
                {
                    Debug.LogWarningFormat(_invalidHelpUrlWarning, type.Name, attribute.URL, url);
                }
            }
        }
Beispiel #14
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);
        }
Beispiel #15
0
 private bool IsTypeIncluded(Type type)
 {
     return(DocumentationGenerator.IsTypeIncluded(type, IncludedTypes, IncludedNamespaces, ExcludedNamespaces));
 }