/// <summary>
        /// This specifies the conceptual topic keywords metadata.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnMetadataKeywordsItem(string keyword, XPathNavigator navigator)
        {
            BuildContext context = this.Context;

            BuildGroupContext groupContext = context.GroupContexts[_group.Id];

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

            //<copy base=".\XmlComp" file="concat($key,'.cmp.xml')"
            //      source="/metadata/topic[@id=$key]/*" target="/document/metadata" />
            XmlWriter xmlWriter = navigator.InsertAfter();

            // For now, lets simply write the default...
            xmlWriter.WriteStartElement("copy");
            xmlWriter.WriteAttributeString("base", String.Format(
                                               @".\{0}", groupContext["$DdueXmlCompDir"]));
            xmlWriter.WriteAttributeString("file", @"concat($key,'.cmp.xml')");
            xmlWriter.WriteAttributeString("source", @"/metadata/topic[@id=$key]/*");
            xmlWriter.WriteAttributeString("target", @"/document/metadata");
            xmlWriter.WriteEndElement();

            xmlWriter.Close();
            navigator.DeleteSelf();
        }
        /// <summary>
        /// The creates the configuration information or settings required by the
        /// target component for the build process.
        /// </summary>
        /// <param name="group">
        /// A build group, <see cref="BuildGroup"/>, representing the documentation
        /// target for configuration.
        /// </param>
        /// <param name="writer">
        /// An <see cref="XmlWriter"/> object used to create one or more new
        /// child nodes at the end of the list of child nodes of the current node.
        /// </param>
        /// <returns>
        /// Returns <see langword="true"/> for a successful configuration;
        /// otherwise, it returns <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// The <see cref="XmlWriter"/> writer passed to this configuration object
        /// may be passed on to other configuration objects, so do not close or
        /// dispose it.
        /// </remarks>
        public override bool Configure(BuildGroup group, XmlWriter writer)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.NotNull(writer, "writer");

            if (!this.Enabled || !this.IsInitialized)
            {
                return(false);
            }

            BuildGroupContext groupContext = _context.GroupContexts[group.Id];

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

            // <autoDocument enabled="true" warn="true" constructors="true"
            //   disposeMethods="true"/>
            // Or
            //<autoDocument enabled="true" warn="true">
            //    <constructors enabled="true">
            //        <normalSummary comment=""/>
            //        <staticSummary comment=""/>
            //    </constructors>
            //    <disposeMethods enabled="true">
            //        <withoutParamSummary comment=""/>
            //        <withParamSummary comment=""/>
            //        <boolParam comment=""/>
            //    </disposeMethods>
            //</autoDocument>

            bool   notApplicable = false;
            string embeddedText  = groupContext["$IsEmbeddedGroup"];

            if (!String.IsNullOrEmpty(embeddedText) &&
                embeddedText.Equals(Boolean.TrueString, StringComparison.OrdinalIgnoreCase))
            {
                notApplicable = true;
            }

            writer.WriteComment(" Start: Automatic documentation options ");
            writer.WriteStartElement("autoDocument");   //start: autoDocument
            if (notApplicable)
            {
                writer.WriteAttributeString("enabled", "false");
            }
            else
            {
                writer.WriteAttributeString("enabled", this.Enabled.ToString());
            }
            writer.WriteAttributeString("warn", _warn.ToString());
            writer.WriteAttributeString("constructors", _constructors.ToString());
            writer.WriteAttributeString("disposeMethods", _disposeMethods.ToString());
            writer.WriteEndElement();                   //end: autoDocument
            writer.WriteComment(" End: Automatic documentation options ");

            return(true);
        }
Esempio n. 3
0
        public override ReferenceContent Create(BuildGroupContext groupContext)
        {
            BuildExceptions.NotNull(groupContext, "groupContext");

            BuildContext context = groupContext.Context;
            BuildLogger  logger  = null;

            if (context != null)
            {
                logger = context.Logger;
            }

            if (!this.IsInitialized)
            {
                throw new BuildException(String.Format(
                                             "The content source '{0}' is not yet initialized.", this.Title));
            }
            if (!this.IsValid)
            {
                if (logger != null)
                {
                    logger.WriteLine(String.Format(
                                         "The content group source '{0}' is invalid.", this.Title),
                                     BuildLoggerLevel.Warn);
                }

                return(null);
            }

            return(_content);
        }
        public override void Initialize(BuildContext context, ReferenceGroup group)
        {
            base.Initialize(context, group);

            _notApplicable = false;

            BuildGroupContext groupContext = context.GroupContexts[group.Id];
            if (groupContext != null)
            {
                // We do not have to spell check embedded documents...
                string embeddedText = groupContext["$IsEmbeddedGroup"];
                if (!String.IsNullOrEmpty(embeddedText) && 
                    embeddedText.Equals(Boolean.TrueString, StringComparison.OrdinalIgnoreCase))
                {
                    _notApplicable = true;
                    return;
                }
            }

            if (this.IsInitialized)
            {
                if (_spellChecking == null)
                {
                    ReferenceEngineSettings engineSettings = this.EngineSettings;

                    Debug.Assert(engineSettings != null);
                    if (engineSettings == null)
                    {
                        this.IsInitialized = false;
                        return;
                    }

                    _spellChecking = engineSettings.SpellChecking;
                    Debug.Assert(_spellChecking != null);
                    if (_spellChecking == null)
                    {
                        this.IsInitialized = false;
                        return;
                    }
                }

                _spellChecker = BuildSpellChecker.Default;
                if (_spellChecker != null)
                {
                    _spellChecker.Initialize(context);
                    if (!_spellChecker.IsInitialized)
                    {
                        this.IsInitialized = false;
                        return;
                    }
                }

                ICollection<string> configSkips = _spellChecking.SkipTags;
                if (configSkips != null && configSkips.Count != 0)
                {
                    _skipTags.UnionWith(configSkips);
                }
            }
        }
        public override void Initialize(BuildContext context, ReferenceGroup group)
        {
            base.Initialize(context, group);

            _notApplicable = false;

            BuildGroupContext groupContext = context.GroupContexts[group.Id];

            if (groupContext != null)
            {
                // We do not have to spell check embedded documents...
                string embeddedText = groupContext["$IsEmbeddedGroup"];
                if (!String.IsNullOrEmpty(embeddedText) &&
                    embeddedText.Equals(Boolean.TrueString, StringComparison.OrdinalIgnoreCase))
                {
                    _notApplicable = true;
                    return;
                }
            }

            if (this.IsInitialized)
            {
                if (_tocLayout == null)
                {
                    ReferenceEngineSettings engineSettings = this.EngineSettings;

                    Debug.Assert(engineSettings != null);
                    if (engineSettings == null)
                    {
                        this.IsInitialized = false;
                        return;
                    }

                    _tocLayout = engineSettings.TocLayout;
                    Debug.Assert(_tocLayout != null);

                    if (_tocLayout == null)
                    {
                        this.IsInitialized = false;
                        return;
                    }
                }

                _contentsAfter = _tocLayout.ContentsAfter;

                ReferenceTocLayoutType layoutType = _tocLayout.LayoutType;
                if (layoutType != ReferenceTocLayoutType.Hierarchical &&
                    layoutType != ReferenceTocLayoutType.Custom)
                {
                    this.IsInitialized = false;
                    return;
                }
            }
        }
Esempio n. 6
0
        public override void BeginSources(BuildContext context)
        {
            base.BeginSources(context);

            string workingDir = context.WorkingDirectory;

            if (!Directory.Exists(workingDir))
            {
                // If the base directory does not exists for some reason, we
                // create that first...
                string baseDir = context.BaseDirectory;
                if (!Directory.Exists(baseDir))
                {
                    Directory.CreateDirectory(baseDir);
                }
                Directory.CreateDirectory(workingDir);
            }

            if (_topicSource != null && _topicSource.IsValid)
            {
                BuildGroupContext groupContext = context.GroupContexts[this.Id];
                if (groupContext == null)
                {
                    throw new BuildException(
                              "The group context is not provided, and it is required by the build system.");
                }

                string ddueMediaDir = Path.Combine(workingDir, groupContext["$DdueMedia"]);

                BuildSourceContext sourceContext = new BuildSourceContext();
                sourceContext.AssembliesDir = Path.Combine(workingDir,
                                                           groupContext["$AssembliesFolder"]);
                sourceContext.CommentsDir = Path.Combine(workingDir,
                                                         groupContext["$CommentsFolder"]);
                sourceContext.DependenciesDir = Path.Combine(workingDir,
                                                             groupContext["$DependenciesFolder"]);
                sourceContext.MediaDir  = ddueMediaDir;
                sourceContext.MediaFile = Path.Combine(workingDir,
                                                       groupContext["$MediaFile"]);

                sourceContext.Initialize(this.Name, workingDir, false);

                _topicSource.Initialize(sourceContext);
                _topicContent = _topicSource.Create(groupContext);
                _topicSource.Uninitialize();

                if (_topicContent == null)
                {
                    throw new BuildException(String.Format(
                                                 "The creation of the content for '{0}' failed.", this.Name));
                }
            }
        }
        private void WriteNodes()
        {
            BuildGroupContext groupContext = this.Context.GroupContexts[this.Group.Id];

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

            // Determine if we have a root namespace container...
            bool includesRoot = !String.IsNullOrEmpty(_projectName);

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent             = true;
            settings.OmitXmlDeclaration = false;
            settings.Encoding           = Encoding.UTF8;

            string outputFile = Path.Combine(Path.GetDirectoryName(_tocFilePath),
                                             groupContext["$HierarchicalTocFile"]);

            using (XmlWriter writer = XmlWriter.Create(outputFile, settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("topics");  // start: topics
                if (includesRoot)
                {
                    writer.WriteStartElement("topic");  // start: topic(Project)
                    writer.WriteAttributeString("id", _projectName);
                    writer.WriteAttributeString("project", "");
                    writer.WriteAttributeString("file", _projectFile);
                }

                IList <HierarchicalTocNode> nodes = _rootNode.Children;
                if (nodes != null && nodes.Count != 0)
                {
                    for (int i = 0; i < nodes.Count; i++)
                    {
                        this.WriteNode(writer, nodes[i]);
                    }
                }

                if (includesRoot)
                {
                    writer.WriteEndElement();        // end: topic(Project)
                }
                writer.WriteEndElement();            // end: topics
                writer.WriteEndDocument();
            }
        }
Esempio n. 8
0
        protected override bool OnExecute(BuildContext context)
        {
            Debug.Assert(_group != null);
            if (_group == null)
            {
                throw new BuildException(
                          "A build group is required, but none is attached to this task.");
            }

            BuildGroupContext groupContext = context.GroupContexts[_group.Id];

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

            bool buildResult = base.OnExecute(context);

            if (!buildResult)
            {
                return(false);
            }

            buildResult = this.ProcessTocVisitors(context, groupContext);

            if (buildResult)
            {
                string tempText = context["$HelpHierarchicalToc"];

                string tocFilePath = String.Empty;
                if (!String.IsNullOrEmpty(tempText) && String.Equals(tempText,
                                                                     Boolean.TrueString, StringComparison.OrdinalIgnoreCase))
                {
                    tocFilePath = Path.Combine(this.WorkingDirectory,
                                               groupContext["$HierarchicalTocFile"]);
                }
                else
                {
                    tocFilePath = Path.Combine(this.WorkingDirectory,
                                               groupContext["$TocFile"]);
                }

                if (!String.IsNullOrEmpty(tocFilePath) && File.Exists(tocFilePath))
                {
                    buildResult = ProcessRootToc(context, groupContext, tocFilePath);
                }
            }

            return(buildResult);
        }
Esempio n. 9
0
        public override BuildStep CreateFinalSteps(BuildGroup group)
        {
            if (group.GroupType != BuildGroupType.Reference)
            {
                throw new BuildException("The build engine requires reference group.");
            }

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

            BuildGroupContext groupContext = context.GroupContexts[group.Id];

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

            string reflectionFile = groupContext["$ReflectionFile"];
            string manifestFile   = groupContext["$ManifestFile"];
            string configFile     = groupContext["$ConfigurationFile"];
            string tocFile        = groupContext["$TocFile"];

            string sandcastleDir = context.StylesDirectory;

            BuildStyleType outputStyle = settings.Style.StyleType;
            string         workingDir  = context.WorkingDirectory;

            // Assemble the help files using the BuildAssembler
            // BuildAssembler.exe /config:Project.config manifest.xml
            string application = Path.Combine(context.SandcastleToolsDirectory,
                                              "BuildAssembler.exe");
            string arguments = String.Format(" /config:{0} {1}",
                                             configFile, manifestFile);
            StepAssembler buildAssProcess = new StepAssembler(workingDir,
                                                              application, arguments);

            buildAssProcess.Group           = group;
            buildAssProcess.LogTitle        = String.Empty;
            buildAssProcess.Message         = "For the group: " + group.Name;
            buildAssProcess.CopyrightNotice = 2;

            return(buildAssProcess);
        }
Esempio n. 10
0
        public override void Initialize(BuildContext context, ReferenceGroup group)
        {
            base.Initialize(context, group);

            _notApplicable = false;

            BuildGroupContext groupContext = context.GroupContexts[group.Id];

            if (groupContext != null)
            {
                // We do not have to spell check embedded documents...
                string embeddedText = groupContext["$IsEmbeddedGroup"];
                if (!String.IsNullOrEmpty(embeddedText) &&
                    embeddedText.Equals(Boolean.TrueString, StringComparison.OrdinalIgnoreCase))
                {
                    _notApplicable = true;
                    return;
                }
            }

            if (this.IsInitialized)
            {
                if (_visibility == null)
                {
                    ReferenceEngineSettings engineSettings = this.EngineSettings;

                    Debug.Assert(engineSettings != null);
                    if (engineSettings == null)
                    {
                        this.IsInitialized = false;
                        return;
                    }

                    _visibility = engineSettings.Visibility;
                    Debug.Assert(_visibility != null);
                    if (_visibility == null)
                    {
                        this.IsInitialized = false;
                        return;
                    }
                }
            }
        }
Esempio n. 11
0
            public override void Initialize(ConceptualGroup group,
                                            BuildContext context)
            {
                string workingDir = context.WorkingDirectory;

                BuildGroupContext groupContext = context.GroupContexts[group.Id];

                string tocFile = Path.Combine(workingDir,
                                              groupContext["$TocFile"]);

                XmlWriterSettings settings = new XmlWriterSettings();

                settings.Indent   = true;
                settings.Encoding = Encoding.UTF8;

                _tocWriter = XmlWriter.Create(tocFile, settings);
                _tocWriter.WriteStartDocument();
                _tocWriter.WriteStartElement("topics"); // start - topics
            }
        /// <summary>
        /// This specifies the conceptual version metadata.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnMetadataVersionItem(string keyword, XPathNavigator navigator)
        {
            BuildContext context = this.Context;

            BuildGroupContext groupContext = context.GroupContexts[_group.Id];

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

            // Create an empty version metadata file...
            string workingDir  = context.WorkingDirectory;
            string versionPath = Path.Combine(workingDir, groupContext["$VersionFile"]);

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent             = true;
            settings.OmitXmlDeclaration = false;
            settings.Encoding           = Encoding.UTF8;
            using (XmlWriter tokenWriter = XmlWriter.Create(versionPath, settings))
            {
                tokenWriter.WriteStartElement("metadata");

                tokenWriter.WriteComment(" There is no version metadata. ");

                tokenWriter.WriteEndElement();
            }


            // <data files="Version.xml" />
            XmlWriter xmlWriter = navigator.InsertAfter();

            // For now, lets simply write the default...
            xmlWriter.WriteStartElement("data");
            xmlWriter.WriteAttributeString("files", versionPath);
            xmlWriter.WriteEndElement();

            xmlWriter.Close();
            navigator.DeleteSelf();
        }
Esempio n. 13
0
            public override void Initialize(ConceptualGroup group,
                                            BuildContext context)
            {
                string workingDir = context.WorkingDirectory;

                BuildGroupContext groupContext = context.GroupContexts[group.Id];

                string metadataFile = Path.Combine(workingDir,
                                                   groupContext["$MetadataFile"]);

                XmlWriterSettings settings = new XmlWriterSettings();

                settings.Indent   = true;
                settings.Encoding = Encoding.UTF8;

                _metadataWriter = XmlWriter.Create(metadataFile, settings);
                _metadataWriter.WriteStartDocument();
                _metadataWriter.WriteStartElement("metadata"); // start - metadata
                _metadataWriter.WriteAttributeString("fileAssetGuid",
                                                     Guid.NewGuid().ToString());
                _metadataWriter.WriteAttributeString("assetTypeId", "ContentMetadata");
            }
Esempio n. 14
0
        private void ProcessMarkers(BuildContext context)
        {
            BuildTocContext tocContext = context.TocContext;

            tocContext.LoadAll();

            IBuildNamedList <BuildGroupContext> groupContexts = context.GroupContexts;

            for (int i = 0; i < groupContexts.Count; i++)
            {
                BuildGroupContext groupContext = groupContexts[i];
                if (groupContext.GroupType == BuildGroupType.Conceptual)
                {
                    ConceptualGroupContext conceptualContext =
                        (ConceptualGroupContext)groupContext;

                    if (conceptualContext.HasMarkers)
                    {
                        this.ProcessMarker(conceptualContext, context);
                    }
                }
            }

            if (_pendindDelete != null && _pendindDelete.Count != 0)
            {
                for (int i = 0; i < _pendindDelete.Count; i++)
                {
                    _pendindDelete[i].RemoveTopic();
                }
            }

            _pendindDelete = null;

            tocContext.SaveAll();

            // Reset the markers state, since it is handled...
            context["$HelpTocMarkers"] = Boolean.FalseString;
        }
        /// <summary>
        /// This specifies the conceptual topic settings metadata.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnMetadataSettingsItem(string keyword, XPathNavigator navigator)
        {
            BuildContext context = this.Context;

            BuildGroupContext groupContext = context.GroupContexts[_group.Id];

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

            // <data files=".\Projectsettings.xml" />
            XmlWriter xmlWriter = navigator.InsertAfter();

            // For now, lets simply write the default...
            xmlWriter.WriteStartElement("data");
            xmlWriter.WriteAttributeString("files", String.Format(
                                               @".\{0}", groupContext["$ProjSettings"]));
            xmlWriter.WriteEndElement();

            xmlWriter.Close();
            navigator.DeleteSelf();
        }
Esempio n. 16
0
            public override void Initialize(ConceptualGroup group,
                                            BuildContext context)
            {
                _group   = group;
                _context = context;

                string workingDir = context.WorkingDirectory;

                BuildSettings settings = context.Settings;

                BuildGroupContext groupContext = context.GroupContexts[group.Id];

                string manifestFile = Path.Combine(workingDir,
                                                   groupContext["$ManifestFile"]);

                XmlWriterSettings xmlSettings = new XmlWriterSettings();

                xmlSettings.Indent   = true;
                xmlSettings.Encoding = Encoding.UTF8;

                _manifestWriter = XmlWriter.Create(manifestFile, xmlSettings);
                _manifestWriter.WriteStartDocument();
                _manifestWriter.WriteStartElement("topics"); // start - topics
            }
Esempio n. 17
0
        private bool ProcessRootToc(BuildContext context,
                                    BuildGroupContext groupContext, string tocFilePath)
        {
            bool buildResult = true;

            string rootTopicId = _group.RootTopicId;

            if (String.IsNullOrEmpty(rootTopicId) ||
                !ConceptualUtils.IsValidId(rootTopicId))
            {
                return(buildResult);
            }

            BuildLogger logger = context.Logger;

            BuildTocContext tocContext = context.TocContext;
            IBuildNamedList <BuildTopicTocInfo> relatedTopics =
                tocContext.RelatedTopics;

            if (relatedTopics == null || relatedTopics.Count == 0 ||
                relatedTopics[rootTopicId] == null)
            {
                if (logger != null)
                {
                    logger.WriteLine(String.Format(
                                         "The related topic '{0}' for the reference group '{1}' is not defined.",
                                         rootTopicId, _group.Name), BuildLoggerLevel.Warn);
                }

                return(buildResult);
            }

            bool isRooted = Convert.ToBoolean(groupContext["$IsRooted"]);

            string tocFileBackup = Path.ChangeExtension(tocFilePath, ".tocbak");

            File.SetAttributes(tocFilePath, FileAttributes.Normal);
            File.Move(tocFilePath, tocFileBackup);

            XmlWriter writer = null;

            try
            {
                XmlWriterSettings writerSettings = new XmlWriterSettings();
                writerSettings.Indent             = true;
                writerSettings.OmitXmlDeclaration = false;
                writer = XmlWriter.Create(tocFilePath, writerSettings);

                writer.WriteStartElement("topics"); // start: topics
                writer.WriteStartElement("topic");  // start: topic
                writer.WriteAttributeString("id", rootTopicId);
                writer.WriteAttributeString("file", rootTopicId);

                using (XmlReader reader = XmlReader.Create(tocFileBackup))
                {
                    if (reader.IsStartElement("topics"))
                    {
                        while (!reader.EOF)
                        {
                            if (reader.Read())
                            {
                                if (reader.NodeType == XmlNodeType.Element &&
                                    String.Equals(reader.Name, "topic",
                                                  StringComparison.OrdinalIgnoreCase))
                                {
                                    if (isRooted)
                                    {
                                        isRooted = false;
                                        continue;
                                    }

                                    writer.WriteNode(reader, true);
                                }
                            }
                        }
                    }
                }

                writer.WriteEndElement();           // end: topic
                writer.WriteEndElement();           // end: topics

                writer.Close();
                writer = null;

                return(true);
            }
            catch (Exception ex)
            {
                File.Move(tocFileBackup, tocFilePath);

                if (logger != null)
                {
                    logger.WriteLine(ex);
                }

                buildResult = false;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                    writer = null;
                }
            }

            return(buildResult);
        }
        /// <summary>
        /// The creates the configuration information or settings required by the
        /// target component for the build process.
        /// </summary>
        /// <param name="group">
        /// A build group, <see cref="BuildGroup"/>, representing the documentation
        /// target for configuration.
        /// </param>
        /// <param name="writer">
        /// An <see cref="XmlWriter"/> object used to create one or more new
        /// child nodes at the end of the list of child nodes of the current node.
        /// </param>
        /// <returns>
        /// Returns <see langword="true"/> for a successful configuration;
        /// otherwise, it returns <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// The <see cref="XmlWriter"/> writer passed to this configuration object
        /// is created as a new child specifically for this object, and will not
        /// be passed onto other configuration objects.
        /// </remarks>
        public override bool Configure(BuildGroup group, XmlWriter writer)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.NotNull(writer, "writer");

            if (!this.Enabled || !this.IsInitialized)
            {
                return(false);
            }

            Debug.Assert(_settings != null, "The settings object is required.");
            if (_settings == null || _context == null)
            {
                return(false);
            }

            //<component type="Sandcastle.Components.ConceptualPreTransComponent" assembly="$(SandAssistComponent)">
            //    <!-- Replaces <token>autoOutline</token> with an <autoOutline xmlns=""/> node. -->
            //    <autoOutline enabled="true" depth="3" />
            //</component>

            writer.WriteComment(" Resolve tokens, <ddue:token>...</ddue:token>, removing any an used token. ");
            writer.WriteStartElement("resolveTokens");  //start: resolveTokens
            writer.WriteAttributeString("enabled", _resolveTokens.ToString());

            writer.WriteComment(" Replaces <token>autoOutline</token> with an <autoOutline xmlns=\"\"/> node. ");
            writer.WriteStartElement("autoOutline");  //start: autoOutline
            writer.WriteAttributeString("enabled", _outlineTokens.ToString());
            if (_outlineDepth > 0)
            {
                writer.WriteAttributeString("depth", _outlineDepth.ToString());
            }
            writer.WriteEndElement();                 //end: autoOutline

            writer.WriteStartElement("lineBreak");    //start: lineBreak
            writer.WriteAttributeString("enabled", _lineBreakTokens.ToString());
            writer.WriteEndElement();                 //end: lineBreak

            writer.WriteStartElement("iconColumn");   //start: iconColumn
            writer.WriteAttributeString("enabled", _tableIconColumnTokens.ToString());
            writer.WriteEndElement();                 //end: iconColumn

            writer.WriteEndElement();                 //end: resolveTokens

            BuildGroupContext groupContext = _context.GroupContexts[group.Id];

            if (groupContext == null)
            {
                return(true);
            }

            string workingDir = _context.WorkingDirectory;
            string indexFile  = Path.Combine(workingDir, groupContext["$IndexFile"]);

            if (String.IsNullOrEmpty(indexFile) || !File.Exists(indexFile))
            {
                return(true);
            }

            string linkResolverPrefix = groupContext["$LinkResolverPrefix"];
            string linkResolverName   = groupContext["$LinkResolverName"];
            string linkResolverValue  = groupContext["$LinkResolverValue"];

            if (!String.IsNullOrEmpty(linkResolverPrefix) &&
                !String.IsNullOrEmpty(linkResolverName) &&
                !String.IsNullOrEmpty(linkResolverValue))
            {
                writer.WriteStartElement("linkResolver");
                writer.WriteAttributeString("indexFile", indexFile);
                writer.WriteAttributeString("topicType",
                                            groupContext["$LinkResolverTopicType"]);

                writer.WriteStartElement("xpath");
                writer.WriteAttributeString("value", linkResolverValue);
                writer.WriteAttributeString("name", linkResolverName);
                writer.WriteAttributeString("prefix", linkResolverPrefix);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }

            return(true);
        }
        /// <summary>
        /// The creates the configuration information or settings required by the
        /// target component for the build process.
        /// </summary>
        /// <param name="group">
        /// A build group, <see cref="BuildGroup"/>, representing the documentation
        /// target for configuration.
        /// </param>
        /// <param name="writer">
        /// An <see cref="XmlWriter"/> object used to create one or more new
        /// child nodes at the end of the list of child nodes of the current node.
        /// </param>
        /// <returns>
        /// Returns <see langword="true"/> for a successful configuration;
        /// otherwise, it returns <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// The <see cref="XmlWriter"/> writer passed to this configuration object
        /// may be passed on to other configuration objects, so do not close or
        /// dispose it.
        /// </remarks>
        public override bool Configure(BuildGroup group, XmlWriter writer)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.NotNull(writer, "writer");

            IBuildNamedList <BuildGroupContext> groupContexts = _context.GroupContexts;

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

            ReferenceGroupContext groupContext = 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.");
            }

            if (!this.Enabled || !this.IsInitialized)
            {
                return(false);
            }

            BuildFramework     framework = groupContext.Framework;
            BuildFrameworkKind kind      = framework.FrameworkType.Kind;

            ReferenceEngineSettings referenceSettings = _settings.EngineSettings[
                BuildEngineType.Reference] as ReferenceEngineSettings;
            BuildSpecialSdkType webSdkType = referenceSettings.WebMvcSdkType;

            writer.WriteStartElement("options");   // start - options
            writer.WriteAttributeString("locale",
                                        _settings.CultureInfo.Name.ToLower());
            if (kind == BuildFrameworkKind.Silverlight)
            {
                writer.WriteAttributeString("version", "VS.95");
            }
            else if (kind == BuildFrameworkKind.Compact)
            {
                // The framework 3.5 is the last version of Windows CE...
                writer.WriteAttributeString("version", "VS.90");
            }
            if (webSdkType != BuildSpecialSdkType.Null &&
                webSdkType != BuildSpecialSdkType.None)
            {
                switch (webSdkType.Value)
                {
                case 10:        // ASP.NET MVC 1.0: Supported in .NET 3.5
                    writer.WriteAttributeString("mvcVersion", "VS.90");
                    break;

                case 20:        // ASP.NET MVC 2.0: Supported in .NET 3.5 SP1
                    // This is currently the default documentation for
                    // the ASP.NET MVC Framework...
                    writer.WriteAttributeString("mvcVersion", "");
                    break;

                case 30:        // ASP.NET MVC 3.0: Supported in .NET 4.0
                    writer.WriteAttributeString("mvcVersion", "VS.98");
                    break;

                case 40:        // ASP.NET MVC 4.0: Supported in .NET 4.5
                    writer.WriteAttributeString("mvcVersion", "VS.108");
                    break;
                }
            }
            writer.WriteAttributeString("linkTarget",
                                        "_" + _format.ExternalLinkTarget.ToString().ToLower());
            writer.WriteEndElement();              // end - options

            bool   isEmbeddedGroup    = false;
            bool   frameworkAvailable = false;
            bool   isEmbeddedScript   = groupContext.IsEmbeddedGroup;
            string tempText           = _context["$EmbeddedScriptSharp"];

            if (!String.IsNullOrEmpty(tempText))
            {
                isEmbeddedScript = Convert.ToBoolean(tempText);
            }

            List <DataSource> dataSources = new List <DataSource>();

            if (kind == BuildFrameworkKind.Silverlight)
            {
                string silverlightDir = groupContext["$SilverlightDataDir"];

                if (!String.IsNullOrEmpty(silverlightDir) &&
                    Directory.Exists(silverlightDir))
                {
                    frameworkAvailable = true;

                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", silverlightDir);
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                _format.ExternalLinkType.ToString().ToLower());

                    // Write the data source...
                    Version latestVersion = BuildFrameworks.LatestSilverlightVersion;
                    if (latestVersion == null)
                    {
                        latestVersion = framework.Version;
                    }
                    this.WriteDataSource(writer, DataSourceType.Silverlight,
                                         silverlightDir, latestVersion, true, true, dataSources);

                    writer.WriteEndElement();
                }
            }
            else if (kind == BuildFrameworkKind.Portable)
            {
                string portableDir = groupContext["$PortableDataDir"];

                if (!String.IsNullOrEmpty(portableDir) && Directory.Exists(portableDir))
                {
                    frameworkAvailable = true;

                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", portableDir);
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                _format.ExternalLinkType.ToString().ToLower());

                    // Write the data source...
                    Version latestVersion = BuildFrameworks.LatestPortableVersion;
                    if (latestVersion == null)
                    {
                        latestVersion = framework.Version;
                    }
                    this.WriteDataSource(writer, DataSourceType.Portable,
                                         portableDir, latestVersion, true, false, dataSources);

                    writer.WriteEndElement();
                }
            }
            else if (kind == BuildFrameworkKind.ScriptSharp)
            {
                string scriptSharpDir = groupContext["$ScriptSharpDataDir"];

                if (!String.IsNullOrEmpty(scriptSharpDir) && Directory.Exists(scriptSharpDir))
                {
                    frameworkAvailable = true;

                    if (!isEmbeddedGroup)
                    {
                        writer.WriteStartElement("targets");
                        writer.WriteAttributeString("base", scriptSharpDir);
                        writer.WriteAttributeString("recurse", "false");
                        writer.WriteAttributeString("system", "true");
                        writer.WriteAttributeString("files", "*.xml");

                        if (isEmbeddedScript)
                        {
                            writer.WriteAttributeString("type",
                                                        BuildLinkType.Local.ToString().ToLower());
                        }
                        else
                        {
                            writer.WriteAttributeString("type",
                                                        BuildLinkType.None.ToString().ToLower());
                        }

                        // Write the data source...
                        Version latestVersion = BuildFrameworks.LatestScriptSharpVersion;
                        if (latestVersion == null)
                        {
                            latestVersion = framework.Version;
                        }
                        this.WriteDataSource(writer, DataSourceType.ScriptSharp,
                                             scriptSharpDir, latestVersion, true, false, dataSources);

                        writer.WriteEndElement();
                    }
                }
            }

            // If not specialized framework, then write the default...
            if (!frameworkAvailable || kind == BuildFrameworkKind.None ||
                kind == BuildFrameworkKind.DotNet || kind == BuildFrameworkKind.Compact)
            {
                string dotNetDataDir = Path.GetFullPath(
                    Environment.ExpandEnvironmentVariables(ReferenceEngine.ReflectionDirectory));

                writer.WriteStartElement("targets");
                writer.WriteAttributeString("base", dotNetDataDir);
                writer.WriteAttributeString("recurse", "true");
                writer.WriteAttributeString("system", "true");
                writer.WriteAttributeString("files", "*.xml");
                writer.WriteAttributeString("type",
                                            _format.ExternalLinkType.ToString().ToLower());

                // Write the data source...
                this.WriteDataSource(writer, DataSourceType.Framework,
                                     dotNetDataDir, ReferenceEngine.ReflectionVersion, true,
                                     false, dataSources);

                writer.WriteEndElement();
            }

            // The Portable and ScriptSharp do not support Blend...
            if (kind != BuildFrameworkKind.Portable &&
                kind != BuildFrameworkKind.Compact &&
                kind != BuildFrameworkKind.ScriptSharp)
            {
                string blendDir = groupContext["$BlendDataDir"];

                if (!String.IsNullOrEmpty(blendDir) && Directory.Exists(blendDir))
                {
                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", blendDir);
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                _format.ExternalLinkType.ToString().ToLower());

                    // Write the data source...
                    BuildSpecialSdk latestBlendSdk = null;
                    if (kind == BuildFrameworkKind.Silverlight)
                    {
                        latestBlendSdk = BuildSpecialSdks.LatestBlendSilverlightSdk;
                    }
                    else
                    {
                        latestBlendSdk = BuildSpecialSdks.LatestBlendWpfSdk;
                    }
                    Version latestVersion = (latestBlendSdk == null) ?
                                            null : latestBlendSdk.Version;
                    if (latestVersion == null)
                    {
                        latestVersion = framework.Version;
                    }
                    this.WriteDataSource(writer, DataSourceType.Blend, blendDir,
                                         latestVersion, true, kind == BuildFrameworkKind.Silverlight,
                                         dataSources);

                    writer.WriteEndElement();
                }
            }

            IList <string> linkDirs = _context.GetValue(
                "$ReferenceLinkDirectories") as IList <string>;
            IList <ReferenceLinkSource> linkSources = _context.GetValue(
                "$ReferenceLinkSources") as IList <ReferenceLinkSource>;

            if ((linkDirs != null && linkDirs.Count != 0) &&
                (linkSources != null && linkSources.Count == linkDirs.Count))
            {
                for (int i = 0; i < linkDirs.Count; i++)
                {
                    ReferenceLinkSource linkSource     = linkSources[i];
                    BuildLinkType       sourceLinkType = linkSource.LinkType;

                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", linkDirs[i]);
                    writer.WriteAttributeString("recurse", "true");
                    writer.WriteAttributeString("system", "false");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                sourceLinkType.ToString().ToLower());

                    writer.WriteEndElement();
                }
            }

            BuildLinkType linkType     = _format.LinkType;
            string        linkTypeText = linkType.ToString().ToLower();

            // For the embedded group, we will not link to the other groups...
            if (!isEmbeddedGroup)
            {
                for (int i = 0; i < groupContexts.Count; i++)
                {
                    ReferenceGroupContext aContext = groupContexts[i]
                                                     as ReferenceGroupContext;

                    if (aContext == null || aContext.IsLinkGroup)
                    {
                        continue;
                    }

                    if (aContext.GroupType != BuildGroupType.Reference ||
                        aContext == groupContext)
                    {
                        continue;
                    }

                    string linkFile = aContext["$ReflectionFile"];
                    if (!String.IsNullOrEmpty(linkFile))
                    {
                        writer.WriteStartElement("targets");

                        writer.WriteAttributeString("base", @".\");
                        writer.WriteAttributeString("recurse", "false");
                        writer.WriteAttributeString("system", "false");
                        writer.WriteAttributeString("files", @".\" + linkFile);
                        writer.WriteAttributeString("type", linkTypeText);
                        writer.WriteEndElement();
                    }
                }
            }

            //<targets base=".\" recurse="false"
            //   files=".\reflection.xml" type="local" />
            writer.WriteStartElement("targets");
            writer.WriteAttributeString("base", @".\");
            writer.WriteAttributeString("recurse", "false");
            writer.WriteAttributeString("system", "false");
            writer.WriteAttributeString("files", @".\" + groupContext["$ReflectionFile"]);

            if (isEmbeddedGroup)
            {
                writer.WriteAttributeString("type",
                                            BuildLinkType.Local.ToString().ToLower());
            }
            else
            {
                writer.WriteAttributeString("type", linkTypeText);
            }

            writer.WriteEndElement();

            // Provide the information for the MSDN link resolvers...
            writer.WriteStartElement("linkResolver"); // start - linkResolver
            writer.WriteAttributeString("storage", _linkStorage.ToString().ToLower());
            writer.WriteAttributeString("cache", _cacheLinks ? "true" : "false");
            if (dataSources != null && dataSources.Count != 0)
            {
                for (int i = 0; i < dataSources.Count; i++)
                {
                    DataSource dataSource = dataSources[i];

                    this.WriteDataSource(writer, dataSource.SourceType,
                                         dataSource.InputDir, dataSource.Version,
                                         dataSource.IsDatabase, dataSource.IsSilverlight, true);
                }
            }
            writer.WriteEndElement();                 // end - linkResolver

            // Finally, provide the information for the conceptual links
            // in reference documents, if any...
            bool hasConceptualContext = _settings.BuildConceptual;

            if (hasConceptualContext)
            {
                hasConceptualContext = false;

                for (int i = 0; i < groupContexts.Count; i++)
                {
                    BuildGroupContext aContext = groupContexts[i];
                    if (aContext.GroupType == BuildGroupType.Conceptual)
                    {
                        hasConceptualContext = true;
                        break;
                    }
                }
            }

            if (hasConceptualContext)
            {
                ConceptualEngineSettings conceptualSettings = _settings.EngineSettings[
                    BuildEngineType.Conceptual] as ConceptualEngineSettings;
                Debug.Assert(conceptualSettings != null,
                             "The settings does not include the reference engine settings.");
                if (conceptualSettings == null)
                {
                    return(false);
                }
                ConceptualLinkConfiguration linkConfig =
                    conceptualSettings.ConceptualLinks;
                Debug.Assert(linkConfig != null,
                             "There is no conceptual link configuration available.");
                if (linkConfig == null)
                {
                    return(false);
                }

                writer.WriteStartElement("conceptualLinks");  //start: conceptualLinks
                writer.WriteAttributeString("enabled", "true");
                writer.WriteAttributeString("showText",
                                            linkConfig.ShowLinkText.ToString());
                writer.WriteAttributeString("showBrokenLinkText",
                                            linkConfig.ShowBrokenLinkText.ToString());
                writer.WriteAttributeString("type", linkTypeText);

                for (int i = 0; i < groupContexts.Count; i++)
                {
                    BuildGroupContext aContext = groupContexts[i];
                    if (aContext.GroupType == BuildGroupType.Conceptual)
                    {
                        writer.WriteStartElement("conceptualTargets");  // start - conceptualTargets
                        writer.WriteAttributeString("base", String.Format(
                                                        @".\{0}", aContext["$DdueXmlCompDir"]));
                        writer.WriteAttributeString("type", linkTypeText);
                        writer.WriteEndElement();                       // end - conceptualTargets
                    }
                }
                writer.WriteEndElement();                     //end: conceptualLinks
            }

            return(true);
        }
Esempio n. 20
0
        public override ReferenceContent Create(BuildGroupContext groupContext)
        {
            BuildExceptions.NotNull(groupContext, "groupContext");

            BuildContext context = groupContext.Context;
            BuildLogger  logger  = null;

            if (context != null)
            {
                logger = context.Logger;
            }

            if (!this.IsInitialized)
            {
                throw new BuildException(String.Format(
                                             "The content source '{0}' is not yet initialized.", this.Title));
            }
            if (!this.IsValid)
            {
                if (logger != null)
                {
                    logger.WriteLine(String.Format(
                                         "The content group source '{0}' is invalid.", this.Title),
                                     BuildLoggerLevel.Warn);
                }

                return(null);
            }

            ReferenceContent content = new ReferenceContent();

            // Set the framework version...
            if (_frameworkType == BuildFrameworkType.Null ||
                _frameworkType == BuildFrameworkType.None)
            {
                BuildFramework framework = BuildFrameworks.LatestFramework;

                if (framework == null)
                {
                    // If not successful, use the default...
                    framework = BuildFrameworks.DefaultFramework;
                }

                content.FrameworkType = framework.FrameworkType;
            }
            else
            {
                content.FrameworkType = _frameworkType;
            }

            for (int i = 0; i < _listItems.Count; i++)
            {
                ReferenceItem item = _listItems[i];
                if (item != null && !item.IsEmpty)
                {
                    content.Add(item);
                }
            }

            // Provide other user-supplied information to the content...
            content.Comments         = this.Comments;
            content.Dependencies     = this.Dependencies;
            content.HierarchicalToc  = this.HierarchicalToc;
            content.TypeFilters      = this.TypeFilters;
            content.AttributeFilters = this.AttributeFilters;

            return(content);
        }
Esempio n. 21
0
        /// <summary>
        /// The creates the configuration information or settings required by the
        /// target component for the build process.
        /// </summary>
        /// <param name="group">
        /// A build group, <see cref="BuildGroup"/>, representing the documentation
        /// target for configuration.
        /// </param>
        /// <param name="writer">
        /// An <see cref="XmlWriter"/> object used to create one or more new
        /// child nodes at the end of the list of child nodes of the current node.
        /// </param>
        /// <returns>
        /// Returns <see langword="true"/> for a successful configuration;
        /// otherwise, it returns <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// The <see cref="XmlWriter"/> writer passed to this configuration object
        /// may be passed on to other configuration objects, so do not close or
        /// dispose it.
        /// </remarks>
        public override bool Configure(BuildGroup group, XmlWriter writer)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.NotNull(writer, "writer");

            if (!this.Enabled || !this.IsInitialized)
            {
                return(false);
            }

            Debug.Assert(_settings != null, "The settings object is required.");
            if (_settings == null || _context == null)
            {
                return(false);
            }

            BuildGroupContext groupContext = _context.GroupContexts[group.Id];

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

            //<component type="Sandcastle.Components.ReferencePostTransComponent" assembly="$(SandAssistComponent)">
            //    <paths outputPath=".\Output\"/>
            //    <attributes>
            //        <attribute name="DocSet" value="NETFramework" />
            //        <attribute name="DocSet" value="NETCompactFramework"/>
            //    </attributes>
            //    <scripts>
            //        <IncludeItem item="assistScripts" />
            //    </scripts>
            //    <styles>
            //        <!-- Include the various styles used by the Sandcastle Assist -->
            //        <IncludeItem item="codeStyle" />
            //        <IncludeItem item="assistStyle" />
            //    </styles>
            //    <header>
            //        <!-- Include the logo image support -->
            //        <IncludeItem item="logoImage" />
            //        <!--<tables>
            //            <table name="" operation="" />
            //        </tables>-->
            //    </header>
            //</component>

            BuildFeedback feeback = _settings.Feedback;

            Debug.Assert(feeback != null, "Feedback object cannot be null (or Nothing).");
            if (feeback == null)
            {
                return(false);
            }
            BuildStyle buildStyle = _settings.Style;

            Debug.Assert(buildStyle != null, "The style object cannot be null (or Nothing).");
            if (buildStyle == null)
            {
                return(false);
            }

            writer.WriteStartElement("paths");  //start: paths
            writer.WriteAttributeString("outputPath", @".\Output\");
            writer.WriteEndElement();           //end: paths

            AttributeContent attributes = _settings.Attributes;

            if (attributes != null && attributes.Count != 0)
            {
                writer.WriteStartElement("attributes");  //start: attributes
                for (int i = 0; i < attributes.Count; i++)
                {
                    AttributeItem attribute = attributes[i];
                    if (attribute.IsEmpty)
                    {
                        continue;
                    }

                    writer.WriteStartElement("attribute");  //start: attribute
                    writer.WriteAttributeString("name", attribute.Name);
                    writer.WriteAttributeString("value", attribute.Value);
                    writer.WriteEndElement();            //end: attribute
                }
                writer.WriteEndElement();                //end: attributes
            }

            writer.WriteStartElement("scripts");  //start: scripts
            ScriptContent scriptContent = buildStyle.Scripts;

            if (scriptContent != null && !scriptContent.IsEmpty)
            {
                for (int i = 0; i < scriptContent.Count; i++)
                {
                    ScriptItem scriptItem = scriptContent[i];
                    // a. Empty item is no use.
                    // b. Overriding scripts are added to the documentation
                    //    by the transform.
                    if (scriptItem.IsEmpty || scriptItem.Overrides)
                    {
                        continue;
                    }

                    writer.WriteStartElement("script");  //start: script
                    writer.WriteAttributeString("file", scriptItem.ScriptFile);
                    writer.WriteAttributeString("condition", scriptItem.Condition);
                    writer.WriteEndElement();            //end: script
                }
            }
            writer.WriteEndElement();            //end: scripts

            writer.WriteStartElement("styles");  //start: styles
            StyleSheetContent styleContent = buildStyle.StyleSheets;

            if (styleContent != null && !styleContent.IsEmpty)
            {
                for (int i = 0; i < styleContent.Count; i++)
                {
                    StyleSheetItem styleItem = styleContent[i];
                    // a. Empty item is no use.
                    // b. Overriding styles are added to the documentation
                    //    by the transform.
                    if (styleItem.IsEmpty || styleItem.Overrides)
                    {
                        continue;
                    }

                    writer.WriteStartElement("style");  //start: style
                    writer.WriteAttributeString("file", styleItem.StyleFile);
                    writer.WriteAttributeString("condition", styleItem.Condition);
                    writer.WriteEndElement();           //end: style
                }
            }
            writer.WriteEndElement();            //end: styles

            // Let the Feedback option object configure itself...
            feeback.Configure(group, writer);

            // Write roots to namespaces conversion handler...
            writer.WriteStartElement("rootNamespaces"); // start: rootNamespaces
            writer.WriteAttributeString("id", group.Id);

            string rootNamespacesFile = Path.Combine(_context.WorkingDirectory,
                                                     groupContext["$RootNamespaces"]);

            if (File.Exists(rootNamespacesFile))
            {
                writer.WriteAttributeString("source", rootNamespacesFile);
            }
            writer.WriteEndElement();                   //end: rootNamespaces

            return(true);
        }
Esempio n. 22
0
        public override void Initialize(BuildContext context)
        {
            if (this.IsInitialized)
            {
                return;
            }

            base.Initialize(context);
            if (!this.IsInitialized)
            {
                return;
            }

            if (_listGroups == null || _listGroups.Count == 0)
            {
                this.IsInitialized = false;
                return;
            }

            BuildSettings settings = this.Settings;

            _engineSettings = (ReferenceEngineSettings)settings.EngineSettings[
                BuildEngineType.Reference];
            Debug.Assert(_engineSettings != null,
                         "The settings does not include the reference engine settings.");
            if (_engineSettings == null)
            {
                this.IsInitialized = false;
                return;
            }

            int itemCount = _listGroups.Count;

            for (int i = 0; i < itemCount; i++)
            {
                ReferenceGroup group = _listGroups[i];

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

                string indexText = String.Empty;
                if (itemCount > 1)
                {
                    indexText = (i + 1).ToString();
                }

                // Create the build dynamic properties...
                groupContext.CreateProperties(indexText);

                group.BeginSources(context);
            }

            // Turn the link sources to dynamic groups...
            this.CreateLinkGroups(context);

            // Cache the list of applicable formats...
            _listFormats = new BuildFormatList();

            BuildFormatList listFormats = this.Settings.Formats;

            if (listFormats == null || listFormats.Count == 0)
            {
                this.IsInitialized = false;
                return;
            }
            itemCount = listFormats.Count;
            for (int i = 0; i < itemCount; i++)
            {
                BuildFormat format = listFormats[i];
                if (format != null && format.Enabled)
                {
                    _listFormats.Add(format);
                }
            }
            if (_listFormats == null || _listFormats.Count == 0)
            {
                this.IsInitialized = false;
                return;
            }

            // Finally, initialize the build groups...
            itemCount = _listGroups.Count;
            for (int i = 0; i < itemCount; i++)
            {
                ReferenceGroup group = _listGroups[i];

                group.Initialize(context);
                if (!group.IsInitialized)
                {
                    this.IsInitialized = false;
                    break;
                }
            }
        }
Esempio n. 23
0
        public override ReferenceContent Create(BuildGroupContext groupContext)
        {
            BuildExceptions.NotNull(groupContext, "groupContext");

            BuildContext context = groupContext.Context;
            BuildLogger  logger  = null;

            if (context != null)
            {
                logger = context.Logger;
            }

            if (!this.IsInitialized)
            {
                throw new BuildException(String.Format(
                                             "The content source '{0}' is not yet initialized.", this.Title));
            }
            if (!this.IsValid)
            {
                if (logger != null)
                {
                    logger.WriteLine(String.Format(
                                         "The content group source '{0}' is invalid.", this.Title),
                                     BuildLoggerLevel.Warn);
                }

                return(null);
            }

            ReferenceContent content = new ReferenceContent(_sourcePath);

            content.Load();

            CommentContent sourceComments = this.Comments;

            if (_overrideComments == null)
            {
                // Provide other user-supplied information to the content...
                if (sourceComments != null && !sourceComments.IsEmpty)
                {
                    // Merge the comments, overriding any existing...
                    CommentContent importComments = content.Comments;
                    if (importComments == null || importComments.IsEmpty)
                    {
                        content.Comments = sourceComments;
                    }
                    else
                    {
                        for (int i = 0; i < sourceComments.Count; i++)
                        {
                            CommentItem sourceItem = sourceComments[i];
                            if (!sourceItem.IsEmpty)
                            {
                                importComments.Add(sourceItem);
                            }
                        }
                    }
                }
            }
            else if (_overrideComments.Value)
            {
                content.Comments = sourceComments;
            }

            HierarchicalTocContent hierarchicalToc = this.HierarchicalToc;

            if (_overrideHierarchicalToc == null)
            {
                if (hierarchicalToc != null && !hierarchicalToc.IsEmpty)
                {
                    content.HierarchicalToc = hierarchicalToc;
                }
            }
            else if (_overrideHierarchicalToc.Value)
            {
                content.HierarchicalToc = hierarchicalToc;
            }

            ReferenceRootFilter typeFilters      = this.TypeFilters;
            ReferenceRootFilter attributeFilters = this.AttributeFilters;

            if (_overrideFilters == null)
            {
                if (typeFilters != null && !typeFilters.IsEmpty)
                {
                    content.TypeFilters = typeFilters;
                }
                if (attributeFilters != null && !attributeFilters.IsEmpty)
                {
                    content.AttributeFilters = attributeFilters;
                }
            }
            else if (_overrideFilters.Value)
            {
                content.TypeFilters      = typeFilters;
                content.AttributeFilters = attributeFilters;
            }

            return(content);
        }
Esempio n. 24
0
        /// <summary>
        /// The creates the configuration information or settings required by the
        /// target component for the build process.
        /// </summary>
        /// <param name="group">
        /// A build group, <see cref="BuildGroup"/>, representing the documentation
        /// target for configuration.
        /// </param>
        /// <param name="writer">
        /// An <see cref="XmlWriter"/> object used to create one or more new
        /// child nodes at the end of the list of child nodes of the current node.
        /// </param>
        /// <returns>
        /// Returns <see langword="true"/> for a successful configuration;
        /// otherwise, it returns <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// The <see cref="XmlWriter"/> writer passed to this configuration object
        /// is created as a new child specifically for this object, and will not
        /// be passed onto other configuration objects.
        /// </remarks>
        public override bool Configure(BuildGroup group, XmlWriter writer)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.NotNull(writer, "writer");

            if (!this.Enabled || !this.IsInitialized)
            {
                return(false);
            }

            BuildSettings settings = _context.Settings;

            writer.WriteStartElement("options");   // start - options
            writer.WriteAttributeString("locale",
                                        settings.CultureInfo.Name.ToLower());
            writer.WriteAttributeString("linkTarget",
                                        "_" + _format.ExternalLinkTarget.ToString().ToLower());
            writer.WriteEndElement();              // end - options

            List <DataSource> dataSources = new List <DataSource>();

            // For now, lets simply write the default...
            //writer.WriteStartElement("targets");    // start - targets
            //writer.WriteAttributeString("base", @"%DXROOT%\Data\Reflection\");
            //writer.WriteAttributeString("recurse", "true");
            //writer.WriteAttributeString("files", "*.xml");
            //writer.WriteAttributeString("type",
            //    _format.ExternalLinkType.ToString().ToLower());
            //writer.WriteEndElement();               // end - targets
            string dotNetDataDir = Path.GetFullPath(
                Environment.ExpandEnvironmentVariables(ReferenceEngine.ReflectionDirectory));

            writer.WriteStartElement("targets");  // start - targets
            writer.WriteAttributeString("base", dotNetDataDir);
            writer.WriteAttributeString("recurse", "true");
            writer.WriteAttributeString("system", "true");
            writer.WriteAttributeString("files", "*.xml");
            writer.WriteAttributeString("type",
                                        _format.ExternalLinkType.ToString().ToLower());

            // Write the data source...
            this.WriteDataSource(writer, DataSourceType.Framework,
                                 dotNetDataDir, ReferenceEngine.ReflectionVersion, true,
                                 false, dataSources);

            writer.WriteEndElement();             // end - targets

            // Write Silverlight framework too...
            Version latestVersion = BuildFrameworks.LatestSilverlightVersion;
            string  reflectionDir = _context.ReflectionDataDirectory;

            if (latestVersion != null && (!String.IsNullOrEmpty(reflectionDir) &&
                                          Directory.Exists(reflectionDir)))
            {
                string silverlightDir = Path.Combine(reflectionDir,
                                                     @"Silverlight\v" + latestVersion.ToString(2));

                // If it exits and not empty, we assume the reflection data
                // is already created..
                if (Directory.Exists(silverlightDir) &&
                    !DirectoryUtils.IsDirectoryEmpty(silverlightDir))
                {
                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", silverlightDir);
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                _format.ExternalLinkType.ToString().ToLower());

                    // Write the data source...
                    this.WriteDataSource(writer, DataSourceType.Silverlight,
                                         silverlightDir, latestVersion, true, true, dataSources);

                    writer.WriteEndElement();
                }
            }
            latestVersion = null;
            bool isSilverlight = false;

            // Write Blend SDK...
            BuildSpecialSdk latestBlendSdk      = null;
            BuildSpecialSdk silverlightBlendSdk = BuildSpecialSdks.LatestBlendSilverlightSdk;
            BuildSpecialSdk wpfBlendSdk         = BuildSpecialSdks.LatestBlendWpfSdk;

            if (silverlightBlendSdk != null && wpfBlendSdk != null)
            {
                // In this case we use the latest version, most likely to
                // have improved API...
                latestBlendSdk = wpfBlendSdk;
                if (silverlightBlendSdk.Version > wpfBlendSdk.Version)
                {
                    isSilverlight  = true;
                    latestBlendSdk = silverlightBlendSdk;
                }
            }
            else if (silverlightBlendSdk != null)
            {
                isSilverlight  = true;
                latestBlendSdk = silverlightBlendSdk;
            }
            else if (wpfBlendSdk != null)
            {
                latestBlendSdk = wpfBlendSdk;
            }

            latestVersion = (latestBlendSdk == null) ?
                            null : latestBlendSdk.Version;

            if (latestVersion != null && (!String.IsNullOrEmpty(reflectionDir) &&
                                          Directory.Exists(reflectionDir)))
            {
                string blendDir = null;
                if (isSilverlight)
                {
                    blendDir = Path.Combine(reflectionDir,
                                            @"Blend\Silverlight\v" + latestVersion.ToString(2));
                }
                else
                {
                    blendDir = Path.Combine(reflectionDir,
                                            @"Blend\Wpf\v" + latestVersion.ToString(2));
                }

                // If it exits and not empty, we assume the reflection data
                // is already created..
                if (Directory.Exists(blendDir) &&
                    !DirectoryUtils.IsDirectoryEmpty(blendDir))
                {
                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", blendDir);
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                _format.ExternalLinkType.ToString().ToLower());

                    // Write the data source...
                    this.WriteDataSource(writer, DataSourceType.Blend,
                                         blendDir, latestVersion, true, isSilverlight, dataSources);

                    writer.WriteEndElement();
                }
            }

            // Provide the information for the MSDN link resolvers...
            writer.WriteStartElement("linkResolver"); // start - linkResolver
            writer.WriteAttributeString("storage", "database");
            writer.WriteAttributeString("cache", "false");
            if (dataSources != null && dataSources.Count != 0)
            {
                for (int i = 0; i < dataSources.Count; i++)
                {
                    DataSource dataSource = dataSources[i];

                    this.WriteDataSource(writer, dataSource.SourceType,
                                         dataSource.InputDir, dataSource.Version,
                                         dataSource.IsDatabase, dataSource.IsSilverlight, true);
                }
            }
            writer.WriteEndElement();                 // end - linkResolver

            BuildLinkType linkType     = _format.LinkType;
            string        linkTypeText = linkType.ToString().ToLower();

            IBuildNamedList <BuildGroupContext> groupContexts = _context.GroupContexts;

            if (groupContexts != null && groupContexts.Count != 0)
            {
                for (int i = 0; i < groupContexts.Count; i++)
                {
                    BuildGroupContext groupContext = groupContexts[i];

                    if (groupContext.GroupType != BuildGroupType.Reference)
                    {
                        continue;
                    }

                    string linkFile = groupContext["$ReflectionFile"];
                    if (!String.IsNullOrEmpty(linkFile))
                    {
                        writer.WriteStartElement("targets");

                        writer.WriteAttributeString("base", @".\");
                        writer.WriteAttributeString("recurse", "false");
                        writer.WriteAttributeString("files",
                                                    @".\" + groupContext["$ReflectionFile"]);
                        writer.WriteAttributeString("type", linkTypeText);

                        writer.WriteEndElement();
                    }
                }
            }

            return(true);
        }
        private void OnVisit(ReferenceDocument referenceDocument, BuildContext context)
        {
            BuildLogger logger = context.Logger;

            string fileName = Path.GetFileName(referenceDocument.DocumentFile);

            if (logger != null)
            {
                logger.WriteLine("Begin Fixing Comment: " + fileName,
                                 BuildLoggerLevel.Info);
            }

            XmlDocument    document          = referenceDocument.Document;
            XPathNavigator documentNavigator = document.CreateNavigator();

            // For the NamespaceDoc classes...
            if (_comments.UsesNamespaceDoc)
            {
                int itemCount = 0;

                XPathNodeIterator iterator = documentNavigator.Select(
                    _nsdocExpression);

                if (iterator != null && iterator.Count != 0)
                {
                    itemCount = iterator.Count;

                    foreach (XPathNavigator navigator in iterator)
                    {
                        string nameText = navigator.GetAttribute("name", String.Empty);

                        // Change from: T:Company.TestLibrary.NamespaceDoc
                        //        to:   N:Company.TestLibrary
                        if (navigator.MoveToAttribute("name", String.Empty))
                        {
                            // 15 := sizeof(.NamespaceDoc) + sizeof(T:)
                            navigator.SetValue(
                                "N:" + nameText.Substring(2, nameText.Length - 15));
                        }
                    }
                }

                if (logger != null)
                {
                    logger.WriteLine("Total number of 'NamespaceDoc' found: " +
                                     itemCount.ToString(), BuildLoggerLevel.Info);
                }
            }

            if (_comments.FixComments)
            {
                int itemFound = 0;
                int itemFixed = 0;

                bool conceptualTopics = false;

                if (context.Settings.BuildConceptual)
                {
                    IList <BuildGroupContext> groupContexts = context.GroupContexts;
                    for (int i = 0; i < groupContexts.Count; i++)
                    {
                        BuildGroupContext groupContext = groupContexts[i];
                        if (groupContext.GroupType == BuildGroupType.Conceptual)
                        {
                            conceptualTopics = true;
                            break;
                        }
                    }
                }

                KeyValuePair <int, int> errorSeeCount = this.OnFixErrorLinks(
                    documentNavigator, _errorSeeExpression, logger);
                itemFound += errorSeeCount.Key;
                itemFixed += errorSeeCount.Value;

                KeyValuePair <int, int> errorSeealsoCount = this.OnFixErrorLinks(
                    documentNavigator, _errorSeealsoExpression, logger);
                itemFound += errorSeealsoCount.Key;
                itemFixed += errorSeealsoCount.Value;

                // Counting this fixes is time wasting, we might have to
                // compare the input and output texts
                XPathNodeIterator it = documentNavigator.Select(_cppGenericExpression);
                while (it.MoveNext())
                {
                    string methodName = _cppGenericFixRegex.Replace(
                        it.Current.Value, "$1");

                    it.Current.SetValue(methodName);
                }

                if (conceptualTopics)
                {
                    KeyValuePair <int, int> seeCount = this.OnFixTopicLinks(
                        documentNavigator, _seeExpression, logger);
                    itemFound += seeCount.Key;
                    itemFixed += seeCount.Value;

                    KeyValuePair <int, int> seealsoCount = this.OnFixTopicLinks(
                        documentNavigator, _seealsoExpression, logger);
                    itemFound += seealsoCount.Key;
                    itemFixed += seealsoCount.Value;
                }

                if (logger != null)
                {
                    logger.WriteLine(String.Format(
                                         "Total number of link issues fixed: {0} out of {1}",
                                         itemFixed, itemFound), BuildLoggerLevel.Info);
                }
            }

            if (logger != null)
            {
                logger.WriteLine("Completed Fixing Comment: " + fileName,
                                 BuildLoggerLevel.Info);
            }
        }
Esempio n. 26
0
        private bool ProcessTocVisitors(BuildContext context, BuildGroupContext groupContext)
        {
            // We need the list of the available configurations from the
            // reference settings...
            BuildSettings settings = context.Settings;

            Debug.Assert(settings != null,
                         "The settings is not associated with the context.");
            if (settings == null)
            {
                return(false);
            }
            BuildEngineSettingsList listSettings = settings.EngineSettings;

            Debug.Assert(listSettings != null,
                         "The settings does not include the engine settings.");
            if (listSettings == null || listSettings.Count == 0)
            {
                return(false);
            }
            _engineSettings = listSettings[BuildEngineType.Reference] as ReferenceEngineSettings;

            Debug.Assert(_engineSettings != null,
                         "The settings does not include the reference engine settings.");
            if (_engineSettings == null)
            {
                return(false);
            }

            string tocFilePath = Path.Combine(this.WorkingDirectory,
                                              groupContext["$TocFile"]);

            if (File.Exists(tocFilePath))
            {
                _listDocuments = new List <ReferenceDocument>();

                ReferenceDocument document = new ReferenceDocument(
                    tocFilePath, ReferenceDocumentType.TableOfContents);

                _listDocuments.Add(document);
            }

            if (_listDocuments == null || _listDocuments.Count == 0)
            {
                return(false);
            }

            // 1. Create all the reference visitors...
            this.PrepareVisitors(context);
            if (_dictVisitors == null || _dictVisitors.Count == 0)
            {
                return(true);
            }

            // 2. Initialize all the reference visitors...
            ICollection <ReferenceTocVisitor> listVisitors = _dictVisitors.Values;

            foreach (ReferenceTocVisitor visitor in listVisitors)
            {
                visitor.Initialize(context, _group);
            }

            // 3. Process the configurations...
            this.ProcessDocuments(context);

            // 4. Un-initialize all the reference visitors...
            foreach (ReferenceTocVisitor visitor in listVisitors)
            {
                visitor.Uninitialize();
            }

            return(true);
        }
        private void WriteReflections()
        {
            BuildGroupContext groupContext = this.Context.GroupContexts[this.Group.Id];

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

            string reflectionFile = Path.Combine(
                Path.GetDirectoryName(_tocFilePath), groupContext["$ReflectionFile"]);

            if (!File.Exists(reflectionFile))
            {
                return;
            }

            XmlDocument document = new XmlDocument();

            document.Load(reflectionFile);
            XPathNavigator documentNavigator = document.CreateNavigator();

            XPathNavigator rootNavigator = documentNavigator.SelectSingleNode(
                "reflection/apis");

            if (rootNavigator == null)
            {
                return;
            }

            XmlWriter writer = rootNavigator.AppendChild();

            for (int i = 0; i < _undocumentedNodes.Count; i++)
            {
                KeyValuePair <string, HierarchicalTocNode> keyValue =
                    _undocumentedNodes[i];
                string fileName          = keyValue.Key;
                HierarchicalTocNode node = keyValue.Value;

                string nodeText = node.FullText;
                string topicId  = "N:" + nodeText;

                // This simulates a root namespace group or container, allowing
                // the transformations to create a list of namespaces with syntax
                // section added. The only issue is that the title include tag is
                // set to <include item="rootTopicTitle"/>, which we can change
                // to <include item="namespaceTopicTitle"/> using build components.
                writer.WriteStartElement("api");       // start: api
                writer.WriteAttributeString("id", topicId);
                writer.WriteStartElement("topicdata"); // start: topicdata
                writer.WriteAttributeString("name", nodeText);
                writer.WriteAttributeString("group", "root");
                writer.WriteEndElement();               // end: topicdata

                writer.WriteStartElement("apidata");    // start: apidata
                writer.WriteAttributeString("name", nodeText);
                writer.WriteAttributeString("group", "namespace");
                writer.WriteEndElement();              // end: apidata

                writer.WriteStartElement("elements");  // start: elements

                XPathNavigator tocExcludedNode = null;

                if (_dicTocExcludedNamespaces != null &&
                    _dicTocExcludedNamespaces.ContainsKey(topicId))
                {
                    tocExcludedNode = rootNavigator.SelectSingleNode(
                        "api[@id='" + topicId + "']");
                    if (tocExcludedNode != null)
                    {
                        string topicFile = _dicTocExcludedNamespaces[topicId];
                        if (!String.IsNullOrEmpty(topicFile))
                        {
                            XPathNavigator fileNode =
                                tocExcludedNode.SelectSingleNode("file");
                            if (fileNode != null && fileNode.MoveToAttribute(
                                    "name", String.Empty))
                            {
                                fileNode.SetValue(topicFile);

                                if (tocExcludedNode.MoveToAttribute("id", String.Empty))
                                {
                                    tocExcludedNode.SetValue(GetTocExcludedTopic(topicId));
                                }
                            }
                        }
                    }
                }

                if (node.HasChildren)
                {
                    IList <HierarchicalTocNode> children = node.Children;
                    for (int j = 0; j < children.Count; j++)
                    {
                        HierarchicalTocNode child = children[j];
                        writer.WriteStartElement("element");  // start: element
                        writer.WriteAttributeString("api", "N:" + child.FullText);
                        writer.WriteEndElement();             // end: element
                    }
                }

                writer.WriteEndElement();         // end: elements

                writer.WriteStartElement("file"); // start: file
                writer.WriteAttributeString("name", fileName);
                writer.WriteEndElement();         // end: file

                writer.WriteEndElement();         // end: api
            }

            writer.Close();

            if (!String.IsNullOrEmpty(_projectName))
            {
                XPathNavigator navigator = rootNavigator.SelectSingleNode(
                    "api[starts-with(@id, 'R:')]");
                if (navigator != null &&
                    navigator.MoveToChild("elements", String.Empty))
                {
                    writer = navigator.AppendChild();

                    for (int i = 0; i < _undocumentedNodes.Count; i++)
                    {
                        KeyValuePair <string, HierarchicalTocNode> keyValue =
                            _undocumentedNodes[i];
                        HierarchicalTocNode node = keyValue.Value;

                        string topicId = "N:" + node.FullText;

                        if (_dicTocExcludedNamespaces != null &&
                            _dicTocExcludedNamespaces.ContainsKey(topicId))
                        {
                            continue;
                        }

                        writer.WriteStartElement("element");  // start: element
                        writer.WriteAttributeString("api", topicId);
                        writer.WriteEndElement();             // end: element
                    }

                    writer.Close();
                }
            }

            document.Save(reflectionFile);
        }
        private void WriteManifest()
        {
            BuildContext   context = this.Context;
            ReferenceGroup group   = this.Group;

            Debug.Assert(context != null);
            Debug.Assert(group != null);
            if (group == null || context == null)
            {
                return;
            }
            BuildGroupContext groupContext = context.GroupContexts[group.Id];

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

            string manifestFile = Path.Combine(
                Path.GetDirectoryName(_tocFilePath), groupContext["$ManifestFile"]);

            if (!File.Exists(manifestFile))
            {
                return;
            }

            XmlDocument document = new XmlDocument();

            document.Load(manifestFile);
            XPathNavigator documentNavigator = document.CreateNavigator();
            XPathNavigator rootNavigator     =
                documentNavigator.SelectSingleNode("topics");

            if (rootNavigator == null)
            {
                return;
            }

            XmlWriter manifestWriter = rootNavigator.AppendChild();

            // We also save the additional namespaces introduced so that their
            // titles can be changed by changing the <include item="rootTopicTitle"/>,
            // to <include item="namespaceTopicTitle"/> using build components.
            XmlWriterSettings writerSettings = new XmlWriterSettings();

            writerSettings.Indent             = true;
            writerSettings.OmitXmlDeclaration = false;
            writerSettings.Encoding           = Encoding.UTF8;

            string rootNamespaceFile = Path.Combine(context.WorkingDirectory,
                                                    groupContext["$RootNamespaces"]);
            XmlWriter rootWriter = XmlWriter.Create(rootNamespaceFile,
                                                    writerSettings);

            try
            {
                rootWriter.WriteStartDocument();
                rootWriter.WriteStartElement("topics");
                rootWriter.WriteAttributeString("contentsAfter",
                                                _contentsAfter.ToString());

                for (int i = 0; i < _undocumentedNodes.Count; i++)
                {
                    KeyValuePair <string, HierarchicalTocNode> keyValue =
                        _undocumentedNodes[i];
                    HierarchicalTocNode node = keyValue.Value;

                    string topicId = "N:" + node.FullText;

                    manifestWriter.WriteStartElement("topic"); // start: topic
                    manifestWriter.WriteAttributeString("id", topicId);
                    manifestWriter.WriteEndElement();          // end: topic

                    rootWriter.WriteStartElement("topic");     // start: topic
                    rootWriter.WriteAttributeString("id", topicId);

                    if (_dicTocExcludedNamespaces != null &&
                        _dicTocExcludedNamespaces.ContainsKey(topicId))
                    {
                        rootWriter.WriteAttributeString("isTocExcluded",
                                                        "true");
                        string tocExcludedTopic = GetTocExcludedTopic(topicId);
                        string fileName         = String.Empty;
                        if (_namingMethod == ReferenceNamingMethod.Guid)
                        {
                            fileName = ReferenceDocument.GetGuildFileName(
                                tocExcludedTopic);
                        }
                        else if (_namingMethod == ReferenceNamingMethod.MemberName)
                        {
                            fileName = ReferenceDocument.GetFriendlyFileName(
                                tocExcludedTopic);
                        }
                        else
                        {
                            fileName = ReferenceDocument.GetGuildFileName(
                                tocExcludedTopic);
                        }
                        rootWriter.WriteAttributeString("tocExcludedTopic",
                                                        tocExcludedTopic);
                        rootWriter.WriteAttributeString("topicFile",
                                                        fileName);

                        XPathNavigator currNode = rootNavigator.SelectSingleNode(
                            "topic[@id='" + topicId + "']");

                        if (currNode != null && currNode.MoveToAttribute(
                                "id", String.Empty))
                        {
                            currNode.SetValue(tocExcludedTopic);
                            _dicTocExcludedNamespaces[topicId] = fileName;
                        }
                    }

                    rootWriter.WriteEndElement();           // end: topic
                }

                rootWriter.WriteEndElement();
                rootWriter.WriteEndDocument();

                manifestWriter.Close();
                manifestWriter = null;

                rootWriter.Close();
                rootWriter = null;

                document.Save(manifestFile);
            }
            finally
            {
                if (manifestWriter != null)
                {
                    manifestWriter.Close();
                    manifestWriter = null;

                    document.Save(manifestFile);
                }

                if (rootWriter != null)
                {
                    rootWriter.Close();
                    rootWriter = null;
                }
            }
        }
        public override ReferenceContent Create(BuildGroupContext groupContext)
        {
            BuildExceptions.NotNull(groupContext, "groupContext");

            BuildContext context = groupContext.Context;
            BuildLogger  logger  = null;

            if (context != null)
            {
                logger = context.Logger;
            }

            if (!this.IsInitialized)
            {
                throw new BuildException(String.Format(
                                             "The content source '{0}' is not yet initialized.", this.Title));
            }
            if (!this.IsValid)
            {
                if (logger != null)
                {
                    logger.WriteLine(String.Format(
                                         "The content group source '{0}' is invalid.", this.Title),
                                     BuildLoggerLevel.Warn);
                }

                return(null);
            }

            string searchPattern = _searchPattern;

            if (String.IsNullOrEmpty(searchPattern))
            {
                searchPattern = "*.dll";
            }
            string[] fullPaths = Directory.GetFiles(_sourcePath.Path,
                                                    searchPattern, _isRecursive ? SearchOption.AllDirectories :
                                                    SearchOption.TopDirectoryOnly);

            if (fullPaths == null || fullPaths.Length == 0)
            {
                return(null);
            }

            HashSet <string> dependencyDirs = new HashSet <string>(
                StringComparer.OrdinalIgnoreCase);
            Dictionary <string, string> assemblies =
                new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (string fullPath in fullPaths)
            {
                string fileName = Path.GetFileName(fullPath);
                if (assemblies.ContainsKey(fileName) ||
                    (_excludeSet.Count != 0 && _excludeSet.Contains(fileName)))
                {
                    continue;
                }

                // We will not use the assemblies without comments as
                // dependencies, since we cannot verify these are .NET DLLs.
                string commentFile = Path.ChangeExtension(fullPath, ".xml");
                if (!File.Exists(commentFile))
                {
                    continue;
                }

                string dependencyDir = Path.GetDirectoryName(fullPath);
                if (!dependencyDir.EndsWith("\\"))
                {
                    dependencyDir += "\\";
                }
                dependencyDirs.Add(dependencyDir);

                assemblies[fileName] = fullPath;
            }

            if (assemblies.Count == 0)
            {
                return(null);
            }

            ReferenceContent content = new ReferenceContent();

            // Set the framework version...
            if (_frameworkType == BuildFrameworkType.Null ||
                _frameworkType == BuildFrameworkType.None)
            {
                BuildFramework framework = BuildFrameworks.LatestFramework;

                if (framework == null)
                {
                    // If not successful, use the default...
                    framework = BuildFrameworks.DefaultFramework;
                }

                content.FrameworkType = framework.FrameworkType;
            }
            else
            {
                content.FrameworkType = _frameworkType;
            }

            foreach (KeyValuePair <string, string> pair in assemblies)
            {
                string assemblyFile = pair.Value;
                string commentFile  = Path.ChangeExtension(assemblyFile, ".xml");

                content.AddItem(commentFile, assemblyFile);
            }

            // Provide the dependency information for the content...
            DependencyContent depContents = content.Dependencies;

            foreach (string dependencyDir in dependencyDirs)
            {
                depContents.Paths.Add(new BuildDirectoryPath(dependencyDir));
            }

            // Provide other user-supplied information to the content...
            content.Comments         = this.Comments;
            content.HierarchicalToc  = this.HierarchicalToc;
            content.TypeFilters      = this.TypeFilters;
            content.AttributeFilters = this.AttributeFilters;

            return(content);
        }
        /// <summary>
        /// The creates the configuration information or settings required by the
        /// target component for the build process.
        /// </summary>
        /// <param name="group">
        /// A build group, <see cref="BuildGroup"/>, representing the documentation
        /// target for configuration.
        /// </param>
        /// <param name="writer">
        /// An <see cref="XmlWriter"/> object used to create one or more new
        /// child nodes at the end of the list of child nodes of the current node.
        /// </param>
        /// <returns>
        /// Returns <see langword="true"/> for a successful configuration;
        /// otherwise, it returns <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// The <see cref="XmlWriter"/> writer passed to this configuration object
        /// may be passed on to other configuration objects, so do not close or
        /// dispose it.
        /// </remarks>
        public override bool Configure(BuildGroup group, XmlWriter writer)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.NotNull(writer, "writer");

            BuildGroupContext groupContext = _context.GroupContexts[group.Id];

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

            if (!this.Enabled || !this.IsInitialized)
            {
                return(false);
            }

            string outputFile = null;
            string groupPart  = group.Name;

            if (String.IsNullOrEmpty(groupPart))
            {
                groupPart = groupContext["$GroupIndex"];
                if (String.IsNullOrEmpty(groupPart))
                {
                    return(false);
                }
                outputFile = "MissingTags" + groupPart + ".xml";
            }
            else
            {
                outputFile = "MissingTags-" + groupPart + ".xml";
            }
            if (!String.IsNullOrEmpty(_outputDir))
            {
                outputFile = Path.Combine(_outputDir, outputFile);
            }

            //<missingTags enabled="true" warn="true" indicate="true" log="true" logXml="true" logFile="..\..\MissingTags.xml">
            //    <tags roots="true" includeTargets="true" namespaces="true" parameters="true"
            //          remarks="true" returns="true" summaries="true" typeParameters="true"
            //          values="true" exceptions="true"/>
            //    <MissingTag message=""/>
            //    <MissingParamTag message=""/>
            //    <MissingIncludeTarget message=""/>
            //    <MissingExceptionText message=""/>
            //</missingTags>

            bool   notApplicable = false;
            string embeddedText  = groupContext["$IsEmbeddedGroup"];

            if (!String.IsNullOrEmpty(embeddedText) &&
                embeddedText.Equals(Boolean.TrueString, StringComparison.OrdinalIgnoreCase))
            {
                notApplicable = true;
            }

            writer.WriteComment(" Start: Missing tags options ");
            writer.WriteStartElement("missingTags");   //start: missingTags
            if (notApplicable)
            {
                writer.WriteAttributeString("enabled", "false");
            }
            else
            {
                writer.WriteAttributeString("enabled", this.Enabled.ToString());
            }
            writer.WriteAttributeString("warn", _warn.ToString());
            writer.WriteAttributeString("indicate", _indicate.ToString());
            writer.WriteAttributeString("log", _log.ToString());
            writer.WriteAttributeString("logXml", _logXml.ToString());
            writer.WriteAttributeString("logFile", outputFile);

            writer.WriteStartElement("tags");   //start: tags
            writer.WriteAttributeString("roots", _rootTags.ToString());
            writer.WriteAttributeString("includeTargets", _includeTargetTags.ToString());
            writer.WriteAttributeString("namespaces", _namespaceTags.ToString());
            writer.WriteAttributeString("parameters", _parameterTags.ToString());
            writer.WriteAttributeString("remarks", _remarkTags.ToString());
            writer.WriteAttributeString("returns", _returnTags.ToString());
            writer.WriteAttributeString("summaries", _summaryTags.ToString());
            writer.WriteAttributeString("typeParameters", _typeParameterTags.ToString());
            writer.WriteAttributeString("values", _valueTags.ToString());
            writer.WriteAttributeString("exceptions", _exceptionTags.ToString());
            writer.WriteEndElement();           //end: tags

            writer.WriteEndElement();           //end: missingTags
            writer.WriteComment(" End: Missing tags options ");

            return(true);
        }