Beispiel #1
0
        protected void InterfaceWiki(string area, API_supported_interface shared_interface, bool track_commands = false)
        {
            LogFormater.Info("[WIKI] Starting area " + area + "");
            // create index
            InterfaceIndex(area, shared_interface);

            // create workspaces
            InterfaceWorkspaces(area, shared_interface);

            // create commands
            InterfaceCommands(area, shared_interface, track_commands);
            LogFormater.Info("[WIKI] Done with area");
        }
Beispiel #2
0
 protected void InterfaceWorkspaces(string area, API_supported_interface shared_interface)
 {
     string[] cmds = shared_interface.GetCommandsList();
     foreach (string workspace in shared_interface.GetAllWorkspaces())
     {
         StringBuilder sb = new StringBuilder();
         sb.Append(html_header);
         sb.Append("<h3>Interface: <a href='[[AREA]].html'>[[AREA]]</a>");
         if (workspace != "")
         {
             sb.Append(" / [[WORKSPACE]]");
         }
         sb.Append("</h3><br/>");
         sb.Append("<h4>Build: ");
         sb.Append(buildVersion);
         sb.Append("</h4><br/>");
         sb.Append("<table class='datatable table table-striped table-bordered'><thead><tr><th>Command</th><th>Min args</th></tr></thead><tbody>");
         foreach (string c in cmds)
         {
             if (shared_interface.GetCommandWorkspace(c) == workspace)
             {
                 int args = shared_interface.GetCommandArgs(c);
                 sb.Append("<tr><td><a href='[[AREA]]");
                 sb.Append(workspace);
                 sb.Append(c);
                 sb.Append(".html'>");
                 sb.Append(c);
                 sb.Append("</a></td><td>");
                 sb.Append(args.ToString());
                 sb.Append("</td></tr>");
             }
         }
         sb.Append("</tbody></table>");
         sb.Replace("[[SUBFOLDER]]", "");
         sb.Replace("[[RETURNROOT]]", "../");
         sb.Replace("[[WORKSPACE]]", workspace);
         sb.Replace("[[AREA]]", area);
         sb.Append(html_footer);
         sb = DebugModeCreateWiki.MenuActive(sb, area);
         string target_file = "" + area + "" + workspace + ".html";
         io.WriteFile(target_file, sb.ToString());
     }
 }
Beispiel #3
0
        protected void InterfaceIndex(string area, API_supported_interface shared_interface)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(html_header);
            sb.Append("<h3>Interface:");
            sb.Append(area);
            sb.Append("</h3><br/>");
            sb.Append("<h4>Build: ");
            sb.Append(buildVersion);
            sb.Append("</h4><br/>");
            string[] cmds = shared_interface.GetCommandsList();
            sb.Append("<table class='datatable table table-striped table-bordered'><thead><tr><th>Workspace</th><th>Commands</th></tr></thead><tbody>");
            foreach (string workspace in shared_interface.GetAllWorkspaces())
            {
                int commands_count = 0;
                foreach (string c in cmds)
                {
                    if (shared_interface.GetCommandWorkspace(c) == workspace)
                    {
                        commands_count++;
                    }
                }

                string workspace_link = "<a href='[[AREA]]" + workspace + ".html'>" + workspace + "</a>";
                sb.Append("<tr><td>");
                sb.Append(workspace_link);
                sb.Append("</td><td>");
                sb.Append(commands_count.ToString());
                sb.Append("</td></tr>");
            }
            sb.Append("</tbody></table>");
            sb.Replace("[[SUBFOLDER]]", "");
            sb.Replace("[[RETURNROOT]]", "../");
            sb.Replace("[[AREA]]", area);
            sb.Append(html_footer);
            sb = DebugModeCreateWiki.MenuActive(sb, area);
            io.WriteFile("" + area + ".html", sb.ToString());
        }
Beispiel #4
0
        protected void InterfaceCommands(string area, API_supported_interface shared_interface, bool track_commands = false)
        {
            string[] cmds           = shared_interface.GetCommandsList();
            string   interface_name = shared_interface.GetType().Name;

            foreach (string c in cmds)
            {
                if (track_commands == true)
                {
                    if (seen_command_names.ContainsKey(c) == false)
                    {
                        seen_command_names.Add(c, interface_name);
                    }
                    else
                    {
                        LogFormater.Debug("command " + c + " from " + interface_name + " overlaps an ready loaded command from " + seen_command_names[c] + "");
                    }
                }
                string workspace = shared_interface.GetCommandWorkspace(c);


                StringBuilder sb = new StringBuilder();
                sb.Append(html_header);
                sb.Append("<h3>Build: ");
                sb.Append(buildVersion);
                sb.Append("</h3><br/>");
                sb.Append("<h4>Interface: <a href='[[AREA]].html'>[[AREA]]</a>");
                if (workspace != "")
                {
                    sb.Append(" / <a href='[[AREA]][[WORKSPACE]].html'>[[WORKSPACE]]</a>");
                }
                sb.Append("</h4><hr/><h3>[[COMMAND]]</h3>");
                int      loop      = 0;
                int      minargs   = shared_interface.GetCommandArgs(c);
                string[] arg_types = shared_interface.GetCommandArgTypes(c);
                string[] arg_hints = shared_interface.GetCommandArgHints(c);
                if (area == "Core")
                {
                    StringBuilder ExampleCall = new StringBuilder();
                    ExampleCall.Append("Example: [[COMMAND]]");
                    ExampleCall.Append("|||");
                    string addon = "";
                    while (loop < minargs)
                    {
                        ExampleCall.Append(addon);
                        addon = "~#~";
                        string hint_value = "";
                        if (arg_hints.Length > loop)
                        {
                            if (arg_hints[loop] != null)
                            {
                                string[] bits = arg_hints[loop].Split("<br/>", StringSplitOptions.RemoveEmptyEntries);
                                if (bits.Length >= 1)
                                {
                                    hint_value = bits[0];
                                }
                            }
                        }
                        if (hint_value != "")
                        {
                            ExampleCall.Append(hint_value);
                        }
                        else
                        {
                            ExampleCall.Append("?");
                            LogFormater.Debug("[WikiMake] " + area + " Command " + c + " missing some required hint values");
                        }
                        loop++;
                    }
                    sb.Append(ExampleCall.ToString());
                    sb.Append("<hr style='border-top: 1px dashed #dcdcdc;'>");
                }



                sb.Append("[[HELP]]");
                if (arg_types.Length > 0)
                {
                    sb.Append("<hr/><h4>Args helper</h4>");
                    loop = 0;

                    sb.Append("<table class='table table-striped table-bordered'><thead><tr><td>Num</td><th>Type</th><th>Required</th><th>Hint</th></tr></thead><tbody>");
                    while (loop < arg_types.Length)
                    {
                        string hint = "";
                        if (arg_hints.Length > loop)
                        {
                            hint = arg_hints[loop];
                        }
                        string Required = "X";
                        if ((loop + 1) > minargs)
                        {
                            Required = "";
                        }
                        sb.Append("<tr><td>" + (loop + 1).ToString() + "</td><td>" + arg_types[loop] + "</td><td>" + Required + "</td><td>" + hint + "</td></tr>");

                        loop++;
                    }
                    sb.Append("</tbody></table>");
                }
                sb.Append(html_footer);
                sb.Replace("[[COMMAND]]", c);
                sb.Replace("[[HELP]]", shared_interface.GetCommandHelp(c));
                sb.Replace("[[MINARGS]]", minargs.ToString());
                sb.Replace("[[WORKSPACE]]", workspace);
                sb.Replace("[[AREA]]", area);
                sb.Replace("[[SUBFOLDER]]", "");
                sb.Replace("[[RETURNROOT]]", "../");
                sb = DebugModeCreateWiki.MenuActive(sb, area);
                string target_file = "" + area + "" + workspace + "" + c + ".html";
                io.WriteFile(target_file, sb.ToString());
            }
        }