Пример #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);
            }
        }
        private void SetGenerator(DocumentationGenerator generator, string path)
        {
            UnloadGenerator();

            _settingsFile = path;
            _generator    = generator;
            _editor       = generator != null?Editor.CreateEditor(_generator) : null;
        }
 private void UnloadGenerator()
 {
     if (_generator != null)
     {
         DestroyImmediate(_generator);
         _generator = null;
         _editor    = null;
     }
 }
Пример #4
0
        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));
        }
Пример #5
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);
 }
Пример #6
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));
        }
Пример #7
0
        public void Generate(string outputFolder)
        {
            var types = TypeHelper.FindTypes(type => !type.IsEnum && DocumentationGenerator.IsTypeIncluded(type, IncludedTypes, IncludedNamespaces));

            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);
        }
        void OnEnable()
        {
            DocumentationGenerator.Initialize();
            _applicationPath = Application.dataPath;

            if (!string.IsNullOrEmpty(_settingsFile))
            {
                LoadGenerator(_settingsFile);
            }

            _state = GenerationState.Waiting;
            LoadTemplates();
        }
Пример #9
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
        }
        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 (Exception exception)
            {
                Debug.LogException(exception);
                return(false);
            }
        }
Пример #11
0
        private string GetTypeLink(Type type)
        {
            if (DocumentationGenerator.IsTypeIncluded(type, IncludedNamespaces))
            {
                return(GetTypeLink(type, this, Templates.InternalLink));
            }

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

            return(GetTypeLink(type, null, Templates.UnknownLink));
        }
Пример #12
0
        public void Validate()
        {
            var types = TypeHelper.FindTypes(type => DocumentationGenerator.IsTypeIncluded(type, DocumentationTypeCategory.Asset | DocumentationTypeCategory.Behaviour, IncludedNamespaces));

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

                if (attribute == null)
                {
                    Debug.LogWarningFormat(_missingHelpUrlWarning, type.Name);
                }
                else if (attribute.URL != url)
                {
                    Debug.LogWarningFormat(_invalidHelpUrlWarning, type.Name, attribute.URL, url);
                }
            }
        }
Пример #13
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)
                                : "");
        }
Пример #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);
        }
Пример #15
0
 private bool IsTypeIncluded(Type type)
 {
     return(DocumentationGenerator.IsTypeIncluded(type, IncludedTypes, IncludedNamespaces));
 }