Пример #1
0
        public static void Create(BuildDocumenter documenter,
                                  TestOptions options)
        {
            CustomTocType tocType = options.TocType;

            if (tocType == CustomTocType.None)
            {
                return;
            }

            BuildSettings           settings       = documenter.Settings;
            ReferenceEngineSettings engineSettings = settings.EngineSettings[
                BuildEngineType.Reference] as ReferenceEngineSettings;

            IList <BuildGroup> listGroups = documenter.Groups;

            // Create a custom TOC layout for the CHM format only...
            if (tocType != CustomTocType.Default)
            {
                FormatChm chmFormat =
                    settings.Formats[BuildFormatType.HtmlHelp1] as FormatChm;
                if (chmFormat != null && chmFormat.Enabled)
                {
                    TocContent chmTocContent = new TocContent();
                    for (int i = 0; i < listGroups.Count; i++)
                    {
                        TocItem tocItem = new TocItem();
                        tocItem.SourceType      = TocItemSourceType.Group;
                        tocItem.SourceRecursive = true;
                        tocItem.SourceId        = listGroups[i].Id;
                        chmTocContent.Add(tocItem);
                    }

                    chmFormat.TocContent = chmTocContent;
                }
            }

            BuildToc   buildToc   = settings.Toc;
            TocContent tocContent = buildToc.Content;

            switch (tocType)
            {
            case CustomTocType.None:
                break;

            case CustomTocType.Default:
                for (int i = 0; i < listGroups.Count; i++)
                {
                    TocItem tocItem = new TocItem();
                    tocItem.SourceType      = TocItemSourceType.Group;
                    tocItem.SourceRecursive = true;
                    tocItem.SourceId        = listGroups[i].Id;
                    tocContent.Add(tocItem);
                }
                break;

            case CustomTocType.ReferenceRoot:
                // Assumes there are three groups and the third is reference group,
                // and root namespaces container is enabled...
                if (listGroups.Count == 3 &&
                    (engineSettings != null && engineSettings.RootNamespaceContainer))
                {
                    TocItem rootItem = new TocItem();
                    rootItem.SourceType      = TocItemSourceType.NamespaceRoot;
                    rootItem.SourceRecursive = false;
                    rootItem.SourceId        = listGroups[2].Id;
                    tocContent.Add(rootItem);

                    for (int i = 0; i < listGroups.Count - 1; i++)
                    {
                        TocItem tocItem = new TocItem();
                        tocItem.SourceType      = TocItemSourceType.Group;
                        tocItem.SourceRecursive = true;
                        tocItem.SourceId        = listGroups[i].Id;
                        rootItem.Add(tocItem);
                    }

                    TocItem namespaceItem1 = new TocItem();
                    namespaceItem1.SourceType      = TocItemSourceType.Namespace;
                    namespaceItem1.SourceRecursive = true;
                    namespaceItem1.SourceId        = "N:ANamespace";
                    rootItem.Add(namespaceItem1);

                    TocItem namespaceItem2 = new TocItem();
                    namespaceItem2.SourceType      = TocItemSourceType.Namespace;
                    namespaceItem2.SourceRecursive = true;
                    namespaceItem2.SourceId        = "N:TestLibrary";
                    rootItem.Add(namespaceItem2);
                }
                break;

            case CustomTocType.TopicRoot:
                if (settings.BuildConceptual && settings.BuildReferences)
                {
                    TocItem rootTocItem = new TocItem();
                    rootTocItem.SourceType      = TocItemSourceType.Topic;
                    rootTocItem.SourceRecursive = true;
                    rootTocItem.SourceId        = "d36e744f-c053-4e94-9ac9-b1ee054d8de2";
                    tocContent.Add(rootTocItem);
                    for (int i = 0; i < listGroups.Count; i++)
                    {
                        TocItem tocItem = new TocItem();
                        tocItem.SourceType      = TocItemSourceType.Group;
                        tocItem.SourceRecursive = true;
                        tocItem.SourceId        = listGroups[i].Id;
                        rootTocItem.Add(tocItem);
                    }
                }
                break;
            }
        }
Пример #2
0
        public void Create()
        {
            bool useCustomStyles = true;

            BuildStyleType styleType = BuildStyleType.ClassicWhite;

            _settings.WorkingDirectory  = new BuildDirectoryPath(_workingDir);
            _settings.CleanIntermediate = false;
            _settings.ShowPreliminary   = true;
            _settings.Style.StyleType   = styleType;
            //_settings.SyntaxType = BuildSyntaxType.None;

            _settings.HeaderText = "Header: This is the header text.";
            _settings.FooterText = "Footer: This is the footer text.";

            BuildFeedback feedBack = _settings.Feedback;

            feedBack.CompanyName   = "Sandcastle Assist";
            feedBack.ProductName   = "Sandcastle Helpers";
            feedBack.EmailAddress  = "*****@*****.**";
            feedBack.FeedbackType  = BuildFeedbackType.None;
            feedBack.CopyrightText =
                "Copyright &#169; 2007-2008 Sandcastle Assist. All Rights Reserved.";
            feedBack.CopyrightLink = "http://www.codeplex.com/SandAssist";

            // Configure the logo image information...
            feedBack.LogoEnabled   = true; // show it...
            feedBack.LogoImage     = new BuildFilePath(Path.Combine(_sandAssistDir, "AssistLogo.jpg"));
            feedBack.LogoWidth     = 64;
            feedBack.LogoHeight    = 64;
            feedBack.LogoPadding   = 3;
            feedBack.LogoText      = "Sandcastle Assist";
            feedBack.LogoLink      = "http://www.codeplex.com/SandAssist";
            feedBack.LogoAlignment = BuildLogoAlignment.Center;
            feedBack.LogoPlacement = BuildLogoPlacement.Right;

            // Configure the logging, we add some loggers by their names...
            BuildLogging logging = _settings.Logging;

            //logging.Verbosity = BuildLoggerVerbosity.Detailed;
            //logging.AddLogger(XmlLogger.LoggerName);
            //logging.AddLogger(HtmlLogger.LoggerName);
            ///logging.AddLogger(XamlLogger.LoggerName);
            logging.AddLogger(ConsoleLogger.LoggerName);

            BuildStyle style = _settings.Style;
            // Add direct code snippet root folder...
            SnippetContent snippets = style.Snippets;

            snippets.Add(new SnippetItem(
                             Path.Combine(_sampleDir, "SampleSnippets")));

            // Add some custom math packages and commands...
            MathPackageContent mathPackages = style.MathPackages;

            mathPackages.Add("picture", "calc");
            mathPackages.Add("xy", "all", "knot", "poly");

            MathCommandContent mathCommands = style.MathCommands;

            mathCommands.Add(@"\quot",
                             @"\dfrac{\varphi \cdot X_{n, #1}}{\varphi_{#2} \times \varepsilon_{#1}}", 2);
            mathCommands.Add(@"\exn", @"(x+\varepsilon_{#1})^{#1}", 1);

            if (useCustomStyles)
            {
                string stylesDir = @"Presentations";
                stylesDir = Path.GetFullPath(stylesDir);
                if (Directory.Exists(stylesDir))
                {
                    _settings.Style.Directory = new BuildDirectoryPath(stylesDir);
                }
            }

            FormatChm chmFormat =
                _settings.Formats[BuildFormatType.HtmlHelp1] as FormatChm;

            if (chmFormat != null)
            {
                chmFormat.Enabled      = true;
                chmFormat.UseBinaryToc = false;
                chmFormat.Indent       = true;
            }

            //FormatHxs hxsFormat =
            //  _settings.Formats[BuildFormatType.HtmlHelp2] as FormatHxs;
            //if (hxsFormat != null)
            //{
            //    //hxsFormat.SeparateIndexFile = true;
            //    hxsFormat.Enabled = true;
            //    hxsFormat.Indent = true;
            //}

            //FormatMhv mhvFormat =
            //    _settings.Formats[BuildFormatType.HtmlHelp3] as FormatMhv;
            //if (mhvFormat != null)
            //{
            //    mhvFormat.Enabled = true;
            //    mhvFormat.Indent = true;
            //}

            //FormatWeb webFormat =
            //    _settings.Formats[BuildFormatType.WebHelp] as FormatWeb;
            //if (webFormat != null)
            //{
            //    webFormat.Enabled = true;
            //    webFormat.Indent = true;
            //}

            //_settings.HelpName = "HelpRegister";
            //_settings.HelpTitle = "Sandcastle HelpRegister";
            _settings.HelpName  = "SandcastleHelpers";
            _settings.HelpTitle = "Sandcastle Helpers Test Sample";
        }