Example #1
0
        public override BuildStep CreateInitialSteps(BuildGroup group)
        {
            ReferenceGroup refGroup = group as ReferenceGroup;

            if (refGroup == null)
            {
                throw new BuildException("The build engine requires reference group.");
            }
            if (_listFormats == null || _listFormats.Count == 0)
            {
                return(null);
            }

            BuildMultiStep listSteps = new BuildMultiStep();

            listSteps.Message     = "References topics for the group: " + group.Name;
            listSteps.LogTitle    = String.Empty;
            listSteps.LogTimeSpan = true;

            BuildSettings settings      = this.Settings;
            string        sandcastleDir = this.Context.StylesDirectory;
            BuildStyle    outputStyle   = settings.Style;

            if (String.IsNullOrEmpty(sandcastleDir))
            {
                return(null);
            }

            // 1. Initialize the conceptual topics...
            StepReferenceInit stepInit = new StepReferenceInit(refGroup);

            stepInit.Message  = "Initializing and copying reference contents";
            stepInit.LogTitle = String.Empty;

            listSteps.Add(stepInit);

            string helpStyle = BuildStyle.StyleFolder(
                outputStyle.StyleType);
            string workingDir = this.Context.WorkingDirectory;

            // 2. Ensure that we have a valid list of folders...
            IList <string>             listFolders = new List <string>();
            IDictionary <string, bool> dicFolders  = this.GetOutputFolders(listFolders);

            // 3. Handle the resources...
            StepDirectoryCopy copyResources = new StepDirectoryCopy(
                workingDir);

            copyResources.LogTitle = String.Empty;
            copyResources.Message  = "Copying user-defined resources.";
            IList <ResourceContent> resourceContents = group.ResourceContents;

            if (resourceContents != null && resourceContents.Count != 0)
            {
                int contentCount = resourceContents.Count;
                for (int j = 0; j < contentCount; j++)
                {
                    ResourceContent resourceContent = resourceContents[j];
                    if (resourceContent == null || resourceContent.Count == 0)
                    {
                        continue;
                    }

                    int itemCount = resourceContent.Count;

                    for (int i = 0; i < itemCount; i++)
                    {
                        ResourceItem resource = resourceContent[i];
                        if (resource != null && !resource.IsEmpty)
                        {
                            string destFolder = resource.Destination;
                            copyResources.Add(resource.Source, destFolder);

                            // Add this to the output folders so that it is copied
                            // to the final output/build directories...
                            if (destFolder.StartsWith("Output",
                                                      StringComparison.OrdinalIgnoreCase))
                            {
                                DirectoryInfo info = new DirectoryInfo(destFolder);
                                destFolder = info.Name;
                                if (!String.IsNullOrEmpty(destFolder) &&
                                    !dicFolders.ContainsKey(destFolder))
                                {
                                    dicFolders.Add(destFolder, true);
                                    listFolders.Add(destFolder);
                                }
                            }
                        }
                    }
                }
            }

            if (copyResources.IsValid)
            {
                listSteps.Add(copyResources);
            }
            else
            {
                StepNone placeHolder = new StepNone();
                placeHolder.LogTitle = String.Empty;
                placeHolder.Message  = "Copying user-defined resources.";
                listSteps.Add(placeHolder);
            }

            _listFolders = listFolders;

            this.CreateReflectionSteps(listSteps, refGroup,
                                       sandcastleDir, helpStyle);

            if (listSteps.Count != 0)
            {
                return(listSteps);
            }

            return(null);
        }
Example #2
0
        public override BuildStep CreateStep(BuildContext context,
                                             BuildStage stage, string workingDir)
        {
            if (context == null || context.Settings == null)
            {
                return(null);
            }

            BuildSettings settings = context.Settings;

            string helpDirectory = context.OutputDirectory;

            if (String.IsNullOrEmpty(workingDir))
            {
                workingDir = context.WorkingDirectory;
            }

            string helpName = settings.HelpName;

            if (String.IsNullOrEmpty(helpName))
            {
                helpName = "Documentation";
            }
            string helpTitle = settings.HelpTitle;

            if (String.IsNullOrEmpty(helpTitle))
            {
                helpTitle = helpName;
            }
            string helpFolder = this.OutputFolder;
            string helpPath   = Path.Combine(helpDirectory,
                                             String.Format(@"{0}\index.htm", helpFolder));

            // Case 2: Starting the default browser viewer...
            if (stage == BuildStage.StartViewer)
            {
                StepWebViewerStart viewerStart = new StepWebViewerStart(
                    helpDirectory, helpPath);

                return(viewerStart);
            }

            // Case 3: Compiling the WebHelp help file...
            if (stage == BuildStage.Compilation)
            {
                string sandassistDir = settings.SandAssistDirectory;

                string webStyle = Path.Combine(sandassistDir,
                                               String.Format(@"Web\{0}\Themes\{1}", _framework, _theme));

                if (!Directory.Exists(webStyle))
                {
                    return(null);
                }

                string tempOutputDir = Path.Combine(workingDir, helpFolder);
                string webHelpDir    = Path.Combine(helpDirectory, helpFolder);

                BuildMultiStep listSteps = new BuildMultiStep();
                listSteps.LogTitle    = "Building document output format - " + this.Name;
                listSteps.LogTimeSpan = true;

                StepDirectoryCopy dirCopy = new StepDirectoryCopy();

                dirCopy.LogTitle  = String.Empty;
                dirCopy.Message   = "Copying the format files to the help folder.";
                dirCopy.Recursive = true;
                dirCopy.Add(webStyle, Path.Combine(tempOutputDir, "webtheme"));

                listSteps.Add(dirCopy);

                string tocFile = context["$HelpTocFile"];

                FormatWebOptions options = new FormatWebOptions();
                options.HelpTitle        = helpTitle;
                options.HelpTocFile      = tocFile;
                options.ProjectName      = helpName;
                options.WorkingDirectory = workingDir;
                options.HtmlDirectory    = Path.Combine(workingDir,
                                                        @"Output\" + this.FormatFolder);
                options.OutputDirectory = tempOutputDir;

                StepWebBuilder webBuilder = new StepWebBuilder(options, workingDir);
                webBuilder.Format        = this;
                webBuilder.LogTitle      = String.Empty;
                webBuilder.Message       = "Creating the WebHelp files.";
                webBuilder.HelpDirectory = webHelpDir;

                listSteps.Add(webBuilder);

                // 3. Move the output html files to the help folder...
                StepDirectoryMove dirMove = new StepDirectoryMove(workingDir);
                dirMove.LogTitle = String.Empty;
                dirMove.Message  = "Moving the output html files to the help folder.";
                dirMove.Add(options.OutputDirectory, webHelpDir);

                listSteps.Add(dirMove);

                return(listSteps);
            }

            return(null);
        }