Example #1
0
        /// <summary>
        /// This method is used to execute the plug-in during the build process
        /// </summary>
        /// <param name="executionContext">The current execution context</param>
        public void Execute(ExecutionContext executionContext)
        {
            _buildProcess.ReportProgress(Resources.PlugInBuildProgress);
            var messageReporter = new MessageReporter(_buildProcess);
            var configuration   = new Configuration
            {
                OutputFolderPath     = _buildProcess.WorkingFolder,
                DocumentRootSchemas  = _configuration.DocumentRootSchemas,
                DocumentRootElements = _configuration.DocumentRootElements,
                DocumentConstraints  = _configuration.DocumentConstraints,
                DocumentSchemas      = _configuration.DocumentSchemas,
                DocumentSyntax       = _configuration.DocumentSyntax,
                UseTypeDocumentationForUndocumentedAttributes = _configuration.UseTypeDocumentationForUndocumentedAttributes,
                UseTypeDocumentationForUndocumentedElements   = _configuration.UseTypeDocumentationForUndocumentedElements,
                SchemaSetContainer          = _configuration.SchemaSetContainer,
                SchemaSetTitle              = _configuration.SchemaSetTitle,
                NamespaceContainer          = _configuration.NamespaceContainer,
                IncludeLinkUriInKeywordK    = _configuration.IncludeLinkUriInKeywordK,
                AnnotationTransformFileName = _configuration.AnnotationTransformFilePath.ExpandedPath,
                SchemaFileNames             = ExpandFiles(_configuration.SchemaFilePaths),
                SchemaDependencyFileNames   = ExpandFiles(_configuration.SchemaDependencyFilePaths),
                DocFileNames = ExpandFiles(_configuration.DocFilePaths)
            };

            var contentGenerator = new ContentGenerator(messageReporter, configuration);

            contentGenerator.Generate();

            var contentFileProfider = new ContentFileProvider(_buildProcess.CurrentProject);

            var contentLayoutFile = contentFileProfider.Add(BuildAction.ContentLayout, contentGenerator.ContentFile);

            contentLayoutFile.SortOrder = _configuration.SortOrder;
            _buildProcess.ConceptualContent.ContentLayoutFiles.Add(contentLayoutFile);

            foreach (var topicFileName in contentGenerator.TopicFiles)
            {
                contentFileProfider.Add(BuildAction.None, topicFileName);
            }

            _buildProcess.ConceptualContent.Topics.Add(new TopicCollection(contentLayoutFile));

            foreach (var mediaItem in contentGenerator.MediaItems)
            {
                var imageFilePath  = new FilePath(mediaItem.FileName, _buildProcess.CurrentProject);
                var imageReference = new ImageReference(imageFilePath, mediaItem.ArtItem.Id)
                {
                    AlternateText = mediaItem.ArtItem.AlternateText
                };
                _buildProcess.ConceptualContent.ImageFiles.Add(imageReference);
            }

            var componentConfig = GetComponentConfiguration(contentGenerator.IndexFile);

            _buildProcess.CurrentProject.ComponentConfigurations.Add(GetComponentId(), true, componentConfig);
        }
Example #2
0
        /// <summary>
        /// This method is used to execute the plug-in during the build process
        /// </summary>
        /// <param name="executionContext">The current execution context</param>
        public void Execute(ExecutionContext executionContext)
        {
            _buildProcess.ReportProgress(Resources.PlugInBuildProgress);
            var messageReporter = new MessageReporter(_buildProcess);
            var configuration = new Configuration
                                {
                                    OutputFolderPath = _buildProcess.WorkingFolder,
                                    DocumentRootSchemas = _configuration.DocumentRootSchemas,
                                    DocumentRootElements = _configuration.DocumentRootElements,
                                    DocumentConstraints = _configuration.DocumentConstraints,
                                    DocumentSchemas = _configuration.DocumentSchemas,
                                    DocumentSyntax = _configuration.DocumentSyntax,
                                    UseTypeDocumentationForUndocumentedAttributes = _configuration.UseTypeDocumentationForUndocumentedAttributes,
                                    UseTypeDocumentationForUndocumentedElements = _configuration.UseTypeDocumentationForUndocumentedElements,
                                    SchemaSetContainer = _configuration.SchemaSetContainer,
                                    SchemaSetTitle = _configuration.SchemaSetTitle,
                                    NamespaceContainer = _configuration.NamespaceContainer,
                                    IncludeLinkUriInKeywordK = _configuration.IncludeLinkUriInKeywordK,
                                    AnnotationTransformFileName = _configuration.AnnotationTransformFilePath.ExpandedPath,
                                    SchemaFileNames = ExpandFiles(_configuration.SchemaFilePaths),
                                    SchemaDependencyFileNames = ExpandFiles(_configuration.SchemaDependencyFilePaths),
                                    DocFileNames = ExpandFiles(_configuration.DocFilePaths)
                                };

            var contentGenerator = new ContentGenerator(messageReporter, configuration);
            contentGenerator.Generate();

            var contentLayoutItem = AddLinkedItem(BuildAction.ContentLayout, contentGenerator.ContentFile);
            contentLayoutItem.SetMetadataValue("SortOrder", Convert.ToString(_configuration.SortOrder, CultureInfo.InvariantCulture));

            foreach (var topicFileName in contentGenerator.TopicFiles)
                AddLinkedItem(BuildAction.None, topicFileName);

            foreach (var mediaItem in contentGenerator.MediaItems)
            {
                var mediaFileItem = AddLinkedItem(BuildAction.Image, mediaItem.FileName);
                mediaFileItem.SetMetadataValue("ImageId", mediaItem.ArtItem.Id);
                mediaFileItem.SetMetadataValue("AlternateText", mediaItem.ArtItem.AlternateText);
            }

            var componentConfig = GetComponentConfiguration(contentGenerator.IndexFile);

            _buildProcess.CurrentProject.ComponentConfigurations.Add(GetComponentId(), true, componentConfig);

            // Needed so that all links are properly evaluated before processed by SHFB.
            _tempProject.MSBuildProject.ReevaluateIfNecessary();

            // Add the items to the conceptual content settings
            _buildProcess.ConceptualContent.MergeContentFrom(_tempProject);
        }