Beispiel #1
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: Class
         *
         * Creates a new class topic page.  Which features are available depend on which parameters you pass.
         *
         * - If you pass a <ClassString> AND a class ID, all features are available immediately.
         * - If you only pass a <ClassString>, then only the <path properties> are available.
         * - If you only pass a class ID, then only the <database functions> are available.
         *		- The <path properties> will be available after one of the <database functions> is called as they will look up the
         *			<ClassString>.
         *		- It is safe to call <HTMLTopicPage.Build()> when you only passed a class ID.
         */
        public Class(Builders.HTML htmlBuilder, int classID = 0, ClassString classString = default(ClassString)) : base(htmlBuilder)
        {
            // DEPENDENCY: This class assumes HTMLTopicPage.Build() will call a database function before using any path properties.

            this.classID     = classID;
            this.classString = classString;
        }
Beispiel #2
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: JSSearchData
         */
        public JSSearchData(Builders.HTML htmlBuilder)
        {
            this.htmlBuilder = htmlBuilder;

            output           = null;
            usedCommentTypes = null;
        }
Beispiel #3
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: Context
         * Creates a context with the passed parameters.
         */
        public Context(Builders.HTML builder, Output.Components.HTMLTopicPage topicPage = null, Topic topic = null)
        {
                        #if DEBUG
            if (topicPage != null)
            {
                if ((object)topicPage.HTMLBuilder != (object)builder)
                {
                    throw new Exception("Tried to create a Context with a topic page that doesn't match the builder.");
                }
            }
                        #endif

            this.builder   = builder;
            this.topicPage = topicPage;
            this.topic     = topic;
        }
Beispiel #4
0
            /* Function: GenerateJSON
             */
            public void GenerateJSON(Builders.HTML htmlBuilder, JSMenuData menu)
            {
                StringBuilder output = new StringBuilder();

                output.Append("[1,\"");

                string htmlTitle = menuEntry.Title.ToHTML();

                output.StringEscapeAndAppend(htmlTitle);

                output.Append('"');

                string hashPath = null;

                if (menuEntry is MenuEntries.Files.File)
                {
                    MenuEntries.Files.File fileMenuEntry = (MenuEntries.Files.File)menuEntry;
                    HTMLTopicPages.File    fileTopicPage = new HTMLTopicPages.File(htmlBuilder, fileMenuEntry.WrappedFile.ID);
                    hashPath = fileTopicPage.OutputFileNameOnlyHashPath;
                }
                else if (menuEntry is MenuEntries.Classes.Class)
                {
                    MenuEntries.Classes.Class classMenuEntry = (MenuEntries.Classes.Class)menuEntry;
                    HTMLTopicPages.Class      classTopicPage = new HTMLTopicPages.Class(htmlBuilder, classString: classMenuEntry.WrappedClassString);
                    hashPath = classTopicPage.OutputFileNameOnlyHashPath;
                }
                                #if DEBUG
                else
                {
                    throw new Exception("Don't know how to generate JSON for target \"" + menuEntry.Title + "\".");
                }
                                #endif

                if (hashPath != htmlTitle)
                {
                    output.Append(",\"");
                    output.StringEscapeAndAppend(hashPath);
                    output.Append('"');
                }

                output.Append(']');

                json = output.ToString();
            }
Beispiel #5
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: HTMLTopicPage
         * Creates a new HTMLTopicPage object.
         */
        public HTMLTopicPage(Builders.HTML htmlBuilder)
        {
            this.htmlBuilder = htmlBuilder;
        }
Beispiel #6
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: File
         */
        public File(Builders.HTML htmlBuilder, int fileID) : base(htmlBuilder)
        {
            this.fileID = fileID;
        }
Beispiel #7
0
            /* Function: GenerateJSON
             */
            public void GenerateJSON(Builders.HTML htmlBuilder, JSMenuData menu)
            {
                StringBuilder output = new StringBuilder();

                output.Append("[2,");


                // Title

                if (menuEntry.CondensedTitles == null)
                {
                    if (menuEntry.Title != null)
                    {
                        output.Append('"');
                        output.StringEscapeAndAppend(menuEntry.Title.ToHTML());
                        output.Append('"');
                    }
                    // Otherwise leave an empty space before the comma.  We don't have to write out "undefined".
                }
                else
                {
                    output.Append("[\"");
                    output.StringEscapeAndAppend(menuEntry.Title.ToHTML());
                    output.Append('"');

                    foreach (string condensedTitle in menuEntry.CondensedTitles)
                    {
                        output.Append(",\"");
                        output.StringEscapeAndAppend(condensedTitle.ToHTML());
                        output.Append('"');
                    }

                    output.Append(']');
                }


                // Hash path

                output.Append(',');

                if (menuEntry is MenuEntries.Files.FileSource)
                {
                    MenuEntries.Files.FileSource fileSourceEntry = (MenuEntries.Files.FileSource)menuEntry;
                    hashPath = htmlBuilder.Source_OutputFolderHashPath(fileSourceEntry.WrappedFileSource.Number,
                                                                       fileSourceEntry.CondensedPathFromFileSource);
                }
                else if (menuEntry is MenuEntries.Files.Folder)
                {
                    MenuEntries.Base.Container container = menuEntry.Parent;

                                        #if DEBUG
                    if (container == null)
                    {
                        throw new Exception("Parent must be defined when generating JSON for menu folder \"" + menuEntry.Title + "\".");
                    }
                                        #endif

                    while ((container is MenuEntries.Files.FileSource) == false)
                    {
                        container = container.Parent;

                                                #if DEBUG
                        if (container == null)
                        {
                            throw new Exception("Couldn't find a file source among the folder \"" + menuEntry.Title + "\"'s parents when generating JSON.");
                        }
                                                #endif
                    }

                    MenuEntries.Files.Folder     folderEntry     = (MenuEntries.Files.Folder)menuEntry;
                    MenuEntries.Files.FileSource fileSourceEntry = (MenuEntries.Files.FileSource)container;

                    hashPath = htmlBuilder.Source_OutputFolderHashPath(fileSourceEntry.WrappedFileSource.Number,
                                                                       folderEntry.PathFromFileSource);
                }
                else if (menuEntry is MenuEntries.Classes.Language)
                {
                    MenuEntries.Classes.Language languageEntry = (MenuEntries.Classes.Language)menuEntry;

                    hashPath = htmlBuilder.Class_OutputFolderHashPath(languageEntry.WrappedLanguage,
                                                                      languageEntry.CondensedScopeString);
                }
                else if (menuEntry is MenuEntries.Classes.Scope)
                {
                    MenuEntries.Base.Container container = menuEntry;

                                        #if DEBUG
                    if (container == null)
                    {
                        throw new Exception("Parent must be defined when generating JSON for menu scope \"" + menuEntry.Title + "\".");
                    }
                                        #endif

                    while ((container is MenuEntries.Classes.Language) == false && container != menu.RootDatabaseMenu)
                    {
                        container = container.Parent;

                                                #if DEBUG
                        if (container == null)
                        {
                            throw new Exception("Couldn't find a language among the scope \"" + menuEntry.Title + "\"'s parents when generating JSON.");
                        }
                                                #endif
                    }

                    MenuEntries.Classes.Scope scopeEntry = (MenuEntries.Classes.Scope)menuEntry;

                    if (container == menu.RootDatabaseMenu)
                    {
                        hashPath = htmlBuilder.Database_OutputFolderHashPath(scopeEntry.WrappedScopeString);
                    }
                    else
                    {
                        MenuEntries.Classes.Language languageEntry = (MenuEntries.Classes.Language)container;
                        hashPath = htmlBuilder.Class_OutputFolderHashPath(languageEntry.WrappedLanguage, scopeEntry.WrappedScopeString);
                    }
                }
                else if (menuEntry == menu.RootFileMenu || menuEntry == menu.RootClassMenu)
                {
                    // If we're at the root file or class menu and the entry is not also a language or file source, it means there are multiple languages and/or
                    // file sources beneath it and thus there is no shared hash path.  "CSharpClass:" and "PerlClass:", "Files:" and "Files2:", etc.
                    hashPath = null;
                }
                else if (menuEntry == menu.RootDatabaseMenu)
                {
                    // If we're at the root database menu and the entry is not also a scope, it means there are multiple scopes beneath it.  However, unlike
                    // files and classes, there is still the shared "Database:" hash path.
                    hashPath = htmlBuilder.Database_OutputFolderHashPath();
                }
                                #if DEBUG
                else
                {
                    throw new Exception("Don't know how to generate JSON for container \"" + menuEntry.Title + "\".");
                }
                                #endif

                if (hashPath != null)
                {
                    output.Append('"');
                    output.StringEscapeAndAppend(hashPath);
                    output.Append('"');
                }
                // Otherwise leave an empty space before the comma.  We don't have to write out "undefined".

                output.Append(',');

                jsonBeforeMembers = output.ToString();
                jsonAfterMembers  = "]";
            }
Beispiel #8
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: JSMenuData
         */
        public JSMenuData(Builders.HTML htmlBuilder) : base(htmlBuilder)
        {
        }