Beispiel #1
0
        protected static void ExportCommandInfo(string path)
        {
            // Dump command info
            List <System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList();
            List <KeyValuePair <System.Type, CommandInfoAttribute> > filteredAttributes = GetFilteredCommandInfoAttribute(menuTypes);

            filteredAttributes.Sort(CompareCommandAttributes);

            // Build list of command categories
            List <string> commandCategories = new List <string>();

            foreach (var keyPair in filteredAttributes)
            {
                CommandInfoAttribute info = keyPair.Value;
                if (info.Category != "" &&
                    !commandCategories.Contains(info.Category))
                {
                    commandCategories.Add(info.Category);
                }
            }
            commandCategories.Sort();

            // Output the commands in each category
            foreach (string category in commandCategories)
            {
                string markdown = "# " + category + " commands # {#" + category.ToLower() + "_commands}\n\n";
                markdown += "[TOC]\n";

                foreach (var keyPair in filteredAttributes)
                {
                    CommandInfoAttribute info = keyPair.Value;

                    if (info.Category == category ||
                        info.Category == "" && category == "Scripting")
                    {
                        markdown += "# " + info.CommandName + " # {#" + info.CommandName.Replace(" ", "") + "}\n";
                        markdown += info.HelpText + "\n\n";
                        markdown += "Defined in " + keyPair.Key.FullName + "\n";
                        markdown += GetPropertyInfo(keyPair.Key);
                    }
                }

                string filePath = path + "/command_ref/" + category.ToLower() + "_commands.md";

                Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                File.WriteAllText(filePath, markdown);
            }
        }
Beispiel #2
0
        protected static void ExportEventHandlerInfo(string path)
        {
            List <System.Type> eventHandlerTypes      = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList();
            List <string>      eventHandlerCategories = new List <string>();

            eventHandlerCategories.Add("Core");
            foreach (System.Type type in eventHandlerTypes)
            {
                EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
                if (info != null &&
                    info.Category != "" &&
                    !eventHandlerCategories.Contains(info.Category))
                {
                    eventHandlerCategories.Add(info.Category);
                }
            }
            eventHandlerCategories.Sort();

            // Output the commands in each category
            foreach (string category in eventHandlerCategories)
            {
                string markdown = "# " + category + " event handlers # {#" + category.ToLower() + "_events}\n\n";
                markdown += "[TOC]\n";

                foreach (System.Type type in eventHandlerTypes)
                {
                    EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);

                    if (info != null &&
                        (info.Category == category ||
                         (info.Category == "" && category == "Core")))
                    {
                        markdown += "# " + info.EventHandlerName + " # {#" + info.EventHandlerName.Replace(" ", "") + "}\n";
                        markdown += info.HelpText + "\n\n";
                        markdown += "Defined in " + type.FullName + "\n";
                        markdown += GetPropertyInfo(type);
                    }
                }

                string filePath = path + "/command_ref/" + category.ToLower() + "_events.md";

                Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                File.WriteAllText(filePath, markdown);
            }
        }
Beispiel #3
0
 static void CacheEventHandlerTypes()
 {
     eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList();
     commandTypes      = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList();
 }