Beispiel #1
0
        //alphabetize all code objects (so all lists are in alphabetical order)
        //NOTE, ONLY ALPHABETIZING CHILDREN OF ROOT.
        private void alphabetizeDoc()
        {
            EngineGovernor.log("Alphabetizing document objects...");

            //get current list of code objects
            List <CodeObject> docObjects = m_cRoot.Children;
            int objectCount = docObjects.Count;

            //foreach list (continually decreasing) starting at 1 to avoid root (0)
            for (int startIndex = 1; startIndex < objectCount - 1; startIndex++)
            {
                int indexOfLowest = startIndex;                 //by default, say the first one in list is lowest
                for (int i = startIndex + 1; i < objectCount; i++)
                {
                    //change if 1
                    int result = compareAlpha(docObjects[indexOfLowest].Name, docObjects[i].Name);
                    if (result == 1)
                    {
                        indexOfLowest = i;                                    /*EngineGovernor.log("DEBUG - : : : " + docObjects[i].Name + " was lower, replacing index of lowest.", 1);*/
                    }
                }

                //checked all of them, now swap
                docObjects = swapIndicies(indexOfLowest, startIndex, docObjects);
            }

            m_cRoot.Children = docObjects;
            EngineGovernor.log("Finished alphabetizing");
        }
Beispiel #2
0
        //will insert <a> tags for any links it finds in the source string
        private string convertLinkTags(string source)
        {
            //EngineGovernor.log("DEBUG - : Checking '" + source + "' for links...", 1);
            if (source.Contains("@l:") || source.Contains("@link:"))
            {
                string[] words  = source.Split(' ');
                string   result = "";
                for (int i = 0; i < words.Length; i++)
                {
                    if (words[i].Contains("@l:") || words[i].Contains("@link:"))
                    {
                        string linkText = "";
                        if (words[i].IndexOf("@l:") != -1 && words[i].Length > words[i].IndexOf("@l:") + 3)
                        {
                            linkText = words[i].Substring(words[i].IndexOf("@l:") + 3);
                        }
                        else if (words[i].IndexOf("@link:") != -1 && words[i].Length > words[i].IndexOf("@link:") + 6)
                        {
                            linkText = words[i].Substring(words[i].IndexOf("@link:") + 6);
                        }
                        else
                        {
                            EngineGovernor.log("WARNING - Found an empty link tag: '" + source + "'", -1);
                        }

                        //string endpunctuation = "";

                        words[i] = "<a href='" + DocGenerator.makeSafeLink(linkText) + ".html'>" + linkText + "</a>";
                    }

                    //recombine into the result string
                    if (i == 0)
                    {
                        result = words[i];
                    }
                    else
                    {
                        result += " " + words[i];
                    }
                }
                return(result);
            }
            else
            {
                return(source);
            }
        }
Beispiel #3
0
        //eventually allow custom stylesheet file to be input into this function, as well as other options
        public List <string> createHTMLDocument(string destFolder)
        {
            //first assign root object
            m_cRoot = m_cDocument.CodeObjects[0];

            if (m_cRoot.CodeType != "class" && m_cRoot.CodeType != "interface")
            {
                EngineGovernor.log("ERROR - Could not find a root code object of type class or interface. Generator currently has no implementation for this type of file.", -1); return(null);
            }

            string fileName    = "";
            string rootName    = "";
            string description = "";

            alphabetizeDoc();

            List <string> nameDescrip = new List <string>();

            EngineGovernor.log("Generating HTML...");
            htmlHead();
            nameDescrip = topInfo();
            tableOfContents();
            constructorIndex();
            functionIndex();
            constantList();
            propertyList();
            constructorList();
            functionList();
            footerStuff();

            EngineGovernor.log("HTML Generation complete.");

            fileName = writeHTML(destFolder);
            checkCSS(destFolder);
            checkJS(destFolder);

            rootName    = nameDescrip[0];
            description = nameDescrip[1];

            List <string> info = new List <string>();

            info.Add(fileName);
            info.Add(rootName);
            info.Add(description);
            return(info);
        }
Beispiel #4
0
        //gets the stuff within the parenethesis for parameters for input of the given object (either constructor or function)
        private string getFunctionParameters(CodeObject obj)
        {
            //EngineGovernor.log("DEBUG - Searching code object for input parameters...", 1);
            if (obj.CodeType != "function" && obj.CodeType != "constructor")
            {
                EngineGovernor.log("ERROR - Tried to get the function parameters of an object that wasn't a class or function", -1); return("");
            }
            if (obj.Inputs.Count > 0)
            {
                //EngineGovernor.log("DEBUG - : Found an input!", 1);

                string     returnString = "";
                CodeObject input        = obj.Inputs[0];
                for (int i = 0; i < input.Variables.Count; i++)
                {
                    if (input.Variables[i].Type == "")
                    {
                        returnString += input.Variables[i].Name;
                    }                                                                                                   //added in so that if in language without strong types (javascript) it doesn't put random space before variable)
                    else
                    {
                        returnString += "<span class='keyword'>" + convertLinkTags(input.Variables[i].Type) + "</span> " + input.Variables[i].Name;
                    }
                    if (i != input.Variables.Count - 1)
                    {
                        returnString += ", ";
                    }
                }
                EngineGovernor.log("DEUBG - : Returning '" + returnString + "'", 1);
                return(returnString);
            }
            else
            {
                //EngineGovernor.log("DEBUG - Found no inputs in the object, returning an empty string.", 1);
                return("");
            }
        }
Beispiel #5
0
 public DocGenerator(CodeDocument doc, int sectionNumber)
 {
     EngineGovernor.log("DocGenerator initialized.");
     m_cDocument      = doc;
     m_iSectionNumber = sectionNumber;
 }