Ejemplo n.º 1
0
        private void CreateReflectionSteps(BuildMultiStep listSteps,
                                           ReferenceGroup group, string sandcastleDir, string helpStyle)
        {
            Debug.Assert(_engineSettings != null);
            if (_engineSettings == null)
            {
                return;
            }

            BuildContext  context  = this.Context;
            BuildSettings settings = this.Settings;

            ReferenceGroupContext groupContext =
                context.GroupContexts[group.Id] as ReferenceGroupContext;

            if (groupContext == null)
            {
                throw new BuildException(
                          "The group context is not provided, and it is required by the build system.");
            }

            string workingDir = context.WorkingDirectory;

            ReferenceContent content       = group.Content;
            string           assemblyDir   = Path.Combine(workingDir, groupContext.AssemblyFolder);
            string           dependencyDir = Path.Combine(workingDir, groupContext.DependencyFolder);

            DependencyContent dependencies = content.Dependencies;

            string reflectionFile = groupContext["$ReflectionFile"];
            string manifestFile   = groupContext["$ManifestFile"];
            string refBuilderFile = groupContext["$ReflectionBuilderFile"];
            string tocFile        = groupContext["$TocFile"];

            BuildStyleType outputStyle = settings.Style.StyleType;

            string tempText = null;

            string arguments   = null;
            string application = null;

            bool ripOldApis = true;

            string assemblyFiles     = null;
            string dependencyFiles   = null;
            string outputFile        = null;
            string configurationFile = null;

            ReferenceVisibilityConfiguration visibility =
                _engineSettings.Visibility;

            Debug.Assert(visibility != null);
            // 1. Create the reflection and the manifest
            StringBuilder textBuilder = new StringBuilder();

            if (group.IsSingleVersion)
            {
                // Call MRefBuilder to generate the reflection...
                // MRefBuilder Assembly.dll
                // /out:reflection.org /config:MRefBuilder.config
                //   /internal-
                application = Path.Combine(context.SandcastleToolsDirectory,
                                           "MRefBuilder.exe");

                assemblyFiles     = String.Format(@"{0}\*.*", assemblyDir);
                dependencyFiles   = String.Format(@"{0}\*.*", dependencyDir);
                outputFile        = Path.ChangeExtension(reflectionFile, ".ver");
                configurationFile = Path.Combine(workingDir, refBuilderFile);

                textBuilder.Append(assemblyFiles);
                textBuilder.Append(" /dep:" + dependencyFiles);

                textBuilder.AppendFormat(" /out:{0} /config:{1}",
                                         outputFile, refBuilderFile);
                if (visibility != null && visibility.IncludeInternalsMembers)
                {
                    textBuilder.Append(" /internal+");
                }
                else
                {
                    textBuilder.Append(" /internal-");
                }

                arguments = textBuilder.ToString();

                outputFile = Path.Combine(workingDir, outputFile);
            }
            else
            {
                // Call the VersionBuilder to create the combined reflection file...
                application = Path.Combine(context.SandcastleToolsDirectory,
                                           "VersionBuilder.exe");

                textBuilder.AppendFormat(" /config:{0} /out:{1}",
                                         groupContext["$ApiVersionsBuilderFile"],
                                         Path.ChangeExtension(reflectionFile, ".org"));

                configurationFile = Path.Combine(workingDir,
                                                 groupContext["$ApiVersionsBuilderFile"]);

                ReferenceVersionInfo versionInfo = group.VersionInfo;
                ripOldApis = versionInfo.RipOldApis;
                if (ripOldApis)
                {
                    textBuilder.Append(" /rip+");
                }
                else
                {
                    textBuilder.Append(" /rip-");
                }

                arguments = textBuilder.ToString();
            }
            StepReflectionBuilder refBuilder = new StepReflectionBuilder(workingDir,
                                                                         application, arguments);

            refBuilder.Group           = group;
            refBuilder.LogTitle        = String.Empty;
            refBuilder.Message         = "Creating XML-formatted reflection information.";
            refBuilder.CopyrightNotice = 2;

            // For the direct use of the Sandcastle library, we need the
            // following parameters...
            refBuilder.RipOldApis        = ripOldApis;
            refBuilder.DocumentInternals =
                (visibility != null && visibility.IncludeInternalsMembers);
            refBuilder.ConfigurationFile = configurationFile;
            refBuilder.ReflectionFile    = outputFile;
            refBuilder.AssemblyFiles.Add(assemblyFiles);
            refBuilder.DependencyFiles.Add(dependencyFiles);

            listSteps.Add(refBuilder);

            textBuilder.Length = 0;

            // 2. Create the reflection and comment refining step...
            StepReferenceRefine referenceRefine =
                new StepReferenceRefine(workingDir);

            referenceRefine.LogTitle = String.Empty;
            referenceRefine.Message  = "Refining the reflection files - filtering and cleaning";
            referenceRefine.Group    = group;

            listSteps.Add(referenceRefine);

            textBuilder.Length = 0;

            // 3. Apply Transforms
            // XslTransform.exe
            // /xsl:"%DXROOT%\ProductionTransforms\ApplyVSDocModel.xsl"
            //    reflection.org
            //    /xsl:"%DXROOT%\ProductionTransforms\AddFriendlyFilenames.xsl"
            //    /out:reflection.xml /arg:IncludeAllMembersTopic=true
            //    /arg:IncludeInheritedOverloadTopics=true /arg:project=Project
            application = Path.Combine(context.SandcastleToolsDirectory,
                                       "XslTransform.exe");
            string prodPath = Path.Combine(sandcastleDir, "ProductionTransforms");
            string textTemp = String.Empty;

            if (group.EnableXmlnsForXaml)
            {
                textTemp = Path.Combine(prodPath, "AddXamlSyntaxData.xsl");
                if (!String.IsNullOrEmpty(textTemp))
                {
                    textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp);
                    textTemp = String.Empty;
                }
            }

            if (outputStyle == BuildStyleType.ClassicWhite ||
                outputStyle == BuildStyleType.ClassicBlue)
            {
                textTemp = Path.Combine(prodPath, "ApplyVSDocModel.xsl");
            }
            else if (outputStyle == BuildStyleType.Lightweight)
            {
            }
            else if (outputStyle == BuildStyleType.ScriptFree)
            {
            }
            if (!String.IsNullOrEmpty(textTemp))
            {
                textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp);
                textTemp = String.Empty;
            }

            ReferenceNamingMethod namingMethod = _engineSettings.Naming;

            if (namingMethod == ReferenceNamingMethod.Guid)
            {
                textTemp = Path.Combine(prodPath, "AddGuidFilenames.xsl");
            }
            else if (namingMethod == ReferenceNamingMethod.MemberName)
            {
                textTemp = Path.Combine(prodPath, "AddFriendlyFilenames.xsl");
            }
            else
            {
                textTemp = Path.Combine(prodPath, "AddGuidFilenames.xsl");
            }
            if (!String.IsNullOrEmpty(textTemp))
            {
                textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp);
                textTemp = String.Empty;
            }

            textBuilder.Append(" " + Path.ChangeExtension(reflectionFile, ".org"));
            textBuilder.AppendFormat(" /out:{0}", reflectionFile);
            textBuilder.AppendFormat(" /arg:IncludeAllMembersTopic={0}",
                                     _engineSettings.IncludeAllMembersTopic ? "true" : "false");
            textBuilder.AppendFormat(" /arg:IncludeInheritedOverloadTopics={0}",
                                     _engineSettings.IncludeInheritedOverloadTopics ? "true" : "false");

            bool   rootContainer = _engineSettings.RootNamespaceContainer;
            string rootTitle     = group.RootNamespaceTitle;

            if (rootContainer && !String.IsNullOrEmpty(rootTitle))
            {
                textBuilder.Append(" /arg:project=Project");
                // Indicate that this reference group is rooted...
                groupContext["$IsRooted"] = Boolean.TrueString;
            }
            arguments = textBuilder.ToString();
            StepReferenceModel applyDocProcess = new StepReferenceModel(
                workingDir, application, arguments);

            applyDocProcess.Group           = group;
            applyDocProcess.LogTitle        = String.Empty;
            applyDocProcess.Message         = "Xsl Transformation - Applying model and adding filenames";
            applyDocProcess.CopyrightNotice = 2;

            listSteps.Add(applyDocProcess);

            textBuilder.Length = 0;

            // 4. and finally the manifest...
            // XslTransform.exe
            // /xsl:"%DXROOT%\ProductionTransforms\ReflectionToManifest.xsl"
            //   reflection.xml /out:manifest.xml
            application = Path.Combine(context.SandcastleToolsDirectory,
                                       "XslTransform.exe");
            textTemp = Path.Combine(prodPath, "ReflectionToManifest.xsl");
            textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp);
            textBuilder.AppendFormat(" {0} /out:{1}", reflectionFile, manifestFile);
            arguments = textBuilder.ToString();
            StepReferenceManifest manifestProcess = new StepReferenceManifest(
                workingDir, application, arguments);

            manifestProcess.Group           = group;
            manifestProcess.LogTitle        = String.Empty;
            manifestProcess.Message         = "Xsl Transformation - Reflection to Manifest";
            manifestProcess.CopyrightNotice = 2;

            listSteps.Add(manifestProcess);

            // 5. Create the reflection table of contents
            // XslTransform.exe
            // /xsl:"%DXROOT%\ProductionTransforms\createvstoc.xsl"
            //    reflection.xml /out:ApiToc.xml
            application = Path.Combine(context.SandcastleToolsDirectory,
                                       "XslTransform.exe");
            if (outputStyle == BuildStyleType.ClassicWhite ||
                outputStyle == BuildStyleType.ClassicBlue)
            {
                tempText = Path.Combine(sandcastleDir,
                                        @"ProductionTransforms\CreateVSToc.xsl");
            }
            else if (outputStyle == BuildStyleType.Lightweight)
            {
            }
            else if (outputStyle == BuildStyleType.ScriptFree)
            {
            }
            arguments = String.Format("/xsl:\"{0}\" {1} /out:{2}",
                                      tempText, reflectionFile, tocFile);
            StepReferenceToc tocProcess = new StepReferenceToc(workingDir,
                                                               application, arguments);

            tocProcess.LogTitle        = String.Empty;
            tocProcess.Message         = "Xsl Transformation - Creating References TOC";
            tocProcess.Group           = group;
            tocProcess.CopyrightNotice = 2;

            listSteps.Add(tocProcess);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public override BuildStep CreateStep(BuildContext context,
                                             BuildStage stage, string workingDir)
        {
            if (context == null || context.Settings == null)
            {
                return(null);
            }

            // Accessing the property will force a lookup for the compiler...
            BuildFilePath helpCompiler = this.CompilerFile;

            if (helpCompiler == null || !helpCompiler.Exists)
            {
                throw new BuildException(
                          "The CHM format compiler cannot be found. If installed, manually set its path.");
            }

            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}\{1}.chm", helpFolder, helpName));

            // Case 1: Closing the HtmlHelp 1.x viewer...
            if (stage == BuildStage.CloseViewer)
            {
                StepChmViewerClose chmClose = new StepChmViewerClose(
                    helpDirectory, helpPath, helpTitle);

                return(chmClose);
            }

            // Case 2: Starting the HtmlHelp 1.x viewer...
            if (stage == BuildStage.StartViewer)
            {
                StepChmViewerStart chmStart = new StepChmViewerStart(
                    helpDirectory, helpPath);

                return(chmStart);
            }

            // Case 3: Compiling the HtmlHelp 1.x help file...
            if (stage == BuildStage.Compilation)
            {
                string      sandassistDir = settings.SandAssistDirectory;
                CultureInfo culture       = settings.CultureInfo;
                int         lcid          = 1033;
                if (culture != null)
                {
                    lcid = culture.LCID;
                }
                string appLocale = null;
                if (lcid != 1033)
                {
                    string toolsDir = Path.Combine(sandassistDir, "Tools");
                    if (Directory.Exists(toolsDir))
                    {
                        appLocale = Path.Combine(toolsDir, "SBAppLocale.exe");
                    }
                }

                // If there is a customized or format specific TOC use it,
                // otherwise, use the default...
                string tocFile = context["$HelpTocFile"];

                FormatChmOptions options = new FormatChmOptions();
                options.ConfigFile       = Path.Combine(workingDir, "ChmBuilder.config");
                options.HtmlDirectory    = Path.Combine(workingDir, @"Output\html");
                options.LangID           = lcid;
                options.Metadata         = false;
                options.WorkingDirectory = workingDir;
                options.OutputDirectory  = Path.Combine(workingDir, helpFolder);
                options.ProjectName      = helpName;
                options.TocFile          = Path.Combine(workingDir, tocFile);

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

                // 1. Prepare the help html files, and create the html project
                // ChmBuilder.exe
                // /project:Manual /html:Output\html
                //   /lcid:1041 /toc:Toc.xml /out:Help
                string application = Path.Combine(context.SandcastleToolsDirectory,
                                                  "ChmBuilder.exe");
                string arguments = String.Format(
                    "/project:{0} /html:Output\\html /lcid:{1} /toc:{2} /out:{3} /config:ChmBuilder.config",
                    helpName, lcid, tocFile, helpFolder);
                StepChmBuilder chmProcess = new StepChmBuilder(workingDir,
                                                               application, arguments);
                chmProcess.LogTitle        = String.Empty;
                chmProcess.Message         = "Creating project and HTML files for the compiler";
                chmProcess.CopyrightNotice = 2;
                chmProcess.HelpName        = helpName;
                chmProcess.HelpFolder      = helpFolder;
                chmProcess.HelpDirectory   = helpDirectory;
                chmProcess.Options         = options;
                chmProcess.OptimizeStyle   = this.OptimizeStyle;
                chmProcess.Format          = this;

                listSteps.Add(chmProcess);

                // 2. Fix the file encoding: DBCSFix.exe /d:Help /l:1033
                application = Path.Combine(context.SandcastleToolsDirectory,
                                           "DBCSFix.exe");
                arguments = String.Format("/d:{0} /l:{1}", helpFolder + @"\html", lcid);
                StepChmDbcsFix dbcsFixProcess = new StepChmDbcsFix(workingDir,
                                                                   application, arguments);
                dbcsFixProcess.LogTitle        = String.Empty;
                dbcsFixProcess.Message         = "Fixing the DBCS for the non-Unicode compiler";
                dbcsFixProcess.CopyrightNotice = 2;
                dbcsFixProcess.Options         = options;

                listSteps.Add(dbcsFixProcess);

                // 3. Compile the Html help files: hhc Help\Manual.hhp
                application = helpCompiler.Path;
                arguments   = String.Format(@"{0}\{1}.hhp", helpFolder, helpName);
                if (String.IsNullOrEmpty(appLocale) == false &&
                    File.Exists(appLocale))
                {
                    arguments = String.Format("$({0}) \"{1}\" {2}", lcid, application,
                                              arguments);
                    application = appLocale;
                }
                StepChmCompiler hhcProcess = new StepChmCompiler(workingDir,
                                                                 application, arguments);
                hhcProcess.LogTitle        = String.Empty;
                hhcProcess.Message         = "Compiling HtmlHelp 1.x help file";
                hhcProcess.CopyrightNotice = 2;
                hhcProcess.KeepSources     = _keepSources;
                hhcProcess.HelpName        = helpName;
                hhcProcess.HelpFolder      = helpFolder;
                hhcProcess.HelpDirectory   = helpDirectory;

                listSteps.Add(hhcProcess);

                return(listSteps);
            }

            return(null);
        }
Ejemplo n.º 4
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}\{1}.mshc", helpFolder, helpName));
            string helpSetup = Path.Combine(helpDirectory,
                                            String.Format(@"{0}\{1}", helpFolder,
                                                          StepMhvBuilder.HelpContentSetup));

            // Case 1: Closing the HtmlHelp 3.x viewer...
            if (stage == BuildStage.CloseViewer)
            {
                StepMhvViewerClose mhvClose = new StepMhvViewerClose(workingDir);

                return(mhvClose);
            }

            // Case 2: Starting the HtmlHelp 3.x viewer...
            if (stage == BuildStage.StartViewer)
            {
                StepMhvViewerStart mhvStart = new StepMhvViewerStart(
                    helpDirectory, helpPath, helpSetup);

                return(mhvStart);
            }

            // Case 3: Compiling the HtmlHelp 3.x help file...
            if (stage == BuildStage.Compilation)
            {
                CultureInfo culture = settings.CultureInfo;
                int         lcid    = 1033;
                if (culture != null)
                {
                    lcid = culture.LCID;
                }

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

                // 1. Move the output html files to the help folder for compilation...
                StepDirectoryMove dirMove = new StepDirectoryMove(workingDir);
                dirMove.LogTitle = String.Empty;
                dirMove.Message  = "Moving the output html files to the help folder for compilation";
                dirMove.Add(@"Output\" + this.FormatFolder, helpFolder + @"\html");

                listSteps.Add(dirMove);

                // 2. Compile or build the HtmlHelp 3.x format...
                StepMhvBuilder mhvBuilder = new StepMhvBuilder(workingDir);

                mhvBuilder.Message       = "Compiling the help file.";
                mhvBuilder.LogTitle      = String.Empty;
                mhvBuilder.HelpName      = helpName;
                mhvBuilder.HelpFolder    = helpFolder;
                mhvBuilder.HelpDirectory = helpDirectory;
                mhvBuilder.OptimizeStyle = this.OptimizeStyle;

                listSteps.Add(mhvBuilder);

                return(listSteps);
            }

            return(null);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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}\{1}.hxs", helpFolder, helpName));

            if (String.IsNullOrEmpty(_helpTitleId))
            {
                _helpTitleId = helpName.Trim();
            }

            // Case 1: Closing the HtmlHelp 2.x viewer...
            if (stage == BuildStage.CloseViewer)
            {
                StepHxsViewerClose hxsClose = new StepHxsViewerClose(
                    workingDir, helpPath, helpTitle);

                return(hxsClose);
            }
            // Case 2: Starting the HtmlHelp 2.x viewer...
            if (stage == BuildStage.StartViewer)
            {
                string collPrefix = this["CollectionPrefix"];
                if (String.IsNullOrEmpty(collPrefix))
                {
                    collPrefix = "Coll";
                    this.AddProperty("CollectionPrefix", collPrefix);
                }
                string helpColl = Path.Combine(helpDirectory,
                                               String.Format(@"{0}\{1}{2}.hxC", helpFolder, collPrefix, helpName));
                string             registrar = Path.Combine(this.CompilerDirectory, "HxReg.exe");
                StepHxsViewerStart hxsStart  = new StepHxsViewerStart(
                    Path.GetDirectoryName(helpPath), helpPath, helpColl);
                hxsStart.Registrar         = registrar;
                hxsStart.HelpTitleId       = _helpTitleId;
                hxsStart.SeparateIndexFile = _separateIndex;

                return(hxsStart);
            }

            // Case 3: Compiling the HtmlHelp 2.x help file...
            if (stage == BuildStage.Compilation)
            {
                CultureInfo culture = settings.CultureInfo;
                int         lcid    = 1033;
                if (culture != null)
                {
                    lcid = culture.LCID;
                }

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

                // Prepare the help html files, and create the html project
                // 1. Move the output html files to the help folder for compilation...
                StepDirectoryMove dirMove = new StepDirectoryMove(workingDir);
                dirMove.LogTitle = String.Empty;
                dirMove.Message  = "Moving the output html files to the help folder for compilation";
                dirMove.Add(@"Output\" + this.FormatFolder, helpFolder + @"\html");

                listSteps.Add(dirMove);

                // 2. Creating the project file...
                string tocFile = context["$HelpTocFile"];

                StepHxsBuilder hxsBuilder = new StepHxsBuilder(workingDir);
                hxsBuilder.LogTitle        = String.Empty;
                hxsBuilder.Message         = "Creating project, content and configuration files.";
                hxsBuilder.HelpFolder      = helpFolder;
                hxsBuilder.HelpToc         = tocFile;
                hxsBuilder.HelpName        = helpName;
                hxsBuilder.HelpTitleId     = _helpTitleId;
                hxsBuilder.HelpCultureInfo = culture;

                listSteps.Add(hxsBuilder);

                // 3. Compile the Html help files hxcomp.exe -p Help\Manual.hxc
                string application = this.CompilerFile;
                string arguments   = String.Format(
                    @"-p {0}\{1}.HxC -n Output\{1}.log", helpFolder, helpName);
                StepHxsCompiler hxsCompiler = new StepHxsCompiler(workingDir,
                                                                  application, arguments);
                hxsCompiler.Message  = "Compiling the help file (HxComp Tool)";
                hxsCompiler.LogTitle = String.Empty;
                hxsCompiler.LogFile  = Path.Combine(workingDir,
                                                    String.Format(@"Output\{0}.log", helpName));
                hxsCompiler.ProjectFile = Path.Combine(workingDir,
                                                       String.Format(@"{0}\{1}.HxC", helpFolder, helpName));
                //hxsCompiler.CopyrightNotice = 2;
                hxsCompiler.HelpFolder      = helpFolder;
                hxsCompiler.HelpToc         = tocFile;
                hxsCompiler.HelpName        = helpName;
                hxsCompiler.HelpTitleId     = _helpTitleId;
                hxsCompiler.HelpDirectory   = helpDirectory;
                hxsCompiler.HelpCultureInfo = culture;

                listSteps.Add(hxsCompiler);

                return(listSteps);
            }

            return(null);
        }