public virtual void BeginGroups(IBuildNamedList <BuildGroup> groups, IBuildNamedList <BuildGroupContext> contexts) { BuildExceptions.NotNull(groups, "groups"); BuildExceptions.NotNull(contexts, "contexts"); _listGroups = groups; _groupContexts = contexts; }
/// <summary> /// Initializes a new instance of the <see cref="ConceptualEngineSettings"/> class /// with the default parameters. /// </summary> public ConceptualEngineSettings() : base("Sandcastle.Conceptual.ConceptualEngineSettings", BuildEngineType.Conceptual) { IBuildNamedList <BuildComponentConfiguration> componentConfigurations = this.ComponentConfigurations; if (componentConfigurations != null) { ConceptualPreTransConfiguration preTrans = new ConceptualPreTransConfiguration(); ConceptualIntelliSenseConfiguration intelliSense = new ConceptualIntelliSenseConfiguration(); ConceptualCloneConfiguration cloneDocument = new ConceptualCloneConfiguration(); ConceptualPostTransConfiguration postTrans = new ConceptualPostTransConfiguration(); ConceptualCodeConfiguration codeComponent = new ConceptualCodeConfiguration(); ConceptualMathConfiguration mathComponent = new ConceptualMathConfiguration(); ConceptualMediaConfiguration mediaComponent = new ConceptualMediaConfiguration(); ConceptualLinkConfiguration topicLinkComponent = new ConceptualLinkConfiguration(); ConceptualReferenceLinkConfiguration referenceLinkComponent = new ConceptualReferenceLinkConfiguration(); ConceptualSharedConfiguration sharedComponent = new ConceptualSharedConfiguration(); componentConfigurations.Add(preTrans); componentConfigurations.Add(intelliSense); componentConfigurations.Add(codeComponent); componentConfigurations.Add(mathComponent); componentConfigurations.Add(mediaComponent); componentConfigurations.Add(postTrans); componentConfigurations.Add(cloneDocument); componentConfigurations.Add(topicLinkComponent); componentConfigurations.Add(referenceLinkComponent); componentConfigurations.Add(sharedComponent); } }
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; }
private void PrepareVisitors(BuildContext context) { if (_dictVisitors == null) { _dictVisitors = new Dictionary <string, ReferenceTocVisitor>(); } _listConfigurations = new List <ReferenceConfiguration>(); // List out enabled Sandcastle Assist and the Plugin configurations... IBuildNamedList <BuildConfiguration> dicAssistConfigs = _engineSettings.Configurations; if (dicAssistConfigs != null && dicAssistConfigs.Count != 0) { foreach (ReferenceConfiguration config in dicAssistConfigs) { // It must be both enabled to be used and active/valid... if (config.Enabled && config.IsActive && String.Equals(config.Category, "ReferenceTocVisitor", StringComparison.OrdinalIgnoreCase)) { // Make sure there is a handler of this configuration... ReferenceTocVisitor visitor = config.CreateVisitor() as ReferenceTocVisitor; if (visitor != null) { _listConfigurations.Add(config); if (!_dictVisitors.ContainsKey(config.Name)) { _dictVisitors.Add(config.Name, visitor); } } } } } IBuildNamedList <BuildConfiguration> dicPluginConfigs = _engineSettings.PluginConfigurations; if (dicPluginConfigs != null && dicPluginConfigs.Count != 0) { foreach (ReferenceConfiguration config in dicPluginConfigs) { // It must be both enabled to be used and active/valid... if (config.Enabled && config.IsActive && String.Equals(config.Category, "ReferenceTocVisitor", StringComparison.OrdinalIgnoreCase)) { // Make sure there is a handler of this configuration... ReferenceTocVisitor visitor = config.CreateVisitor() as ReferenceTocVisitor; if (visitor != null) { _listConfigurations.Add(config); if (!_dictVisitors.ContainsKey(config.Name)) { _dictVisitors.Add(config.Name, visitor); } } } } } }
private void ProcessDocuments(BuildContext context) { if (_listDocuments == null || _listDocuments.Count == 0) { return; } List <BuildConfiguration> listConfigurations = new List <BuildConfiguration>(); // List out enabled Sandcastle Assist and the Plugin configurations... IBuildNamedList <BuildConfiguration> dicAssistConfigs = _engineSettings.Configurations; if (dicAssistConfigs != null && dicAssistConfigs.Count != 0) { foreach (ReferenceConfiguration config in dicAssistConfigs) { // It must be both enabled to be used and active/valid... if (config.Enabled && config.IsActive && String.Equals(config.Category, "ReferenceTocVisitor", StringComparison.OrdinalIgnoreCase)) { // Make sure there is a handler of this configuration... if (_dictVisitors.ContainsKey(config.Name)) { listConfigurations.Add(config); } } } } IBuildNamedList <BuildConfiguration> dicPluginConfigs = _engineSettings.PluginConfigurations; if (dicPluginConfigs != null && dicPluginConfigs.Count != 0) { foreach (ReferenceConfiguration config in dicPluginConfigs) { // It must be both enabled to be used and active/valid... if (config.Enabled && config.IsActive && String.Equals(config.Category, "ReferenceTocVisitor", StringComparison.OrdinalIgnoreCase)) { // Make sure there is a handler of this configuration... if (_dictVisitors.ContainsKey(config.Name)) { listConfigurations.Add(config); } } } } if (listConfigurations.Count == 0) { return; } // Initialize the configurations and get them ready for processing... for (int i = 0; i < listConfigurations.Count; i++) { listConfigurations[i].Initialize(context); } FileSystemWatcher fileWatcher = null; try { fileWatcher = new FileSystemWatcher(); int itemCount = _listDocuments.Count; for (int i = 0; i < itemCount; i++) { ReferenceDocument document = _listDocuments[i]; if (document == null || document.IsEmpty) { continue; } this.ProcessDocument(fileWatcher, context, document, listConfigurations); } // Un-initialize the configurations after the processing... for (int i = 0; i < listConfigurations.Count; i++) { listConfigurations[i].Uninitialize(); } } finally { if (fileWatcher != null) { fileWatcher.EnableRaisingEvents = false; fileWatcher.Dispose(); fileWatcher = null; } } }
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 /// 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); }
/// <summary> /// Initializes a new instance of the <see cref="ReferenceEngineSettings"/> class /// with the default parameters. /// </summary> public ReferenceEngineSettings() : base("Sandcastle.References.ReferenceEngineSettings", BuildEngineType.Reference) { _webMvcSdkType = BuildSpecialSdkType.Null; _rootContainer = false; _embedScriptSharp = true; _includeAllMembersTopic = true; _includeInheritedOverloadTopics = true; _refNamer = ReferenceNamer.Orcas; _refNaming = ReferenceNamingMethod.Guid; IBuildNamedList <BuildConfiguration> configurations = this.Configurations; if (configurations != null) { // For the ReferenceVisitors... ReferenceCommentConfiguration comments = new ReferenceCommentConfiguration(); ReferenceSpellCheckConfiguration spellCheck = new ReferenceSpellCheckConfiguration(); ReferenceVisibilityConfiguration documentVisibility = new ReferenceVisibilityConfiguration(); ReferenceXPathConfiguration pathDocumentVisibility = new ReferenceXPathConfiguration(); pathDocumentVisibility.Enabled = false; // For the ReferenceTocVistors... ReferenceTocExcludeConfiguration excludeToc = new ReferenceTocExcludeConfiguration(); ReferenceTocLayoutConfiguration layoutToc = new ReferenceTocLayoutConfiguration(); configurations.Add(comments); configurations.Add(documentVisibility); configurations.Add(pathDocumentVisibility); configurations.Add(spellCheck); configurations.Add(excludeToc); configurations.Add(layoutToc); } IBuildNamedList <BuildComponentConfiguration> componentConfigurations = this.ComponentConfigurations; if (componentConfigurations != null) { ReferencePreTransConfiguration preTrans = new ReferencePreTransConfiguration(); ReferenceMissingTagsConfiguration missingTags = new ReferenceMissingTagsConfiguration(); ReferenceAutoDocConfiguration autoDocument = new ReferenceAutoDocConfiguration(); ReferenceIntelliSenseConfiguration intelliSense = new ReferenceIntelliSenseConfiguration(); ReferencePlatformsConfiguration platforms = new ReferencePlatformsConfiguration(); ReferenceCloneConfiguration cloneDocument = new ReferenceCloneConfiguration(); ReferencePostTransConfiguration postTrans = new ReferencePostTransConfiguration(); ReferenceCodeConfiguration codeComponent = new ReferenceCodeConfiguration(); ReferenceMathConfiguration mathComponent = new ReferenceMathConfiguration(); ReferenceMediaConfiguration mediaComponent = new ReferenceMediaConfiguration(); ReferenceLinkConfiguration linkComponent = new ReferenceLinkConfiguration(); ReferenceSharedConfiguration sharedComponent = new ReferenceSharedConfiguration(); componentConfigurations.Add(preTrans); componentConfigurations.Add(autoDocument); componentConfigurations.Add(missingTags); componentConfigurations.Add(intelliSense); componentConfigurations.Add(platforms); componentConfigurations.Add(cloneDocument); componentConfigurations.Add(postTrans); componentConfigurations.Add(codeComponent); componentConfigurations.Add(mathComponent); componentConfigurations.Add(mediaComponent); componentConfigurations.Add(linkComponent); componentConfigurations.Add(sharedComponent); } }
/// <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); }
protected void OnReferenceDataItem(string keyword, XPathNavigator navigator) { BuildContext context = this.Context; 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."); } BuildFramework framework = groupContext.Framework; BuildFrameworkKind kind = framework.FrameworkType.Kind; string sandcastleDir = context.SandcastleDirectory; //<data base="%DXROOT%\Data\Reflection" recurse="true" files="*.xml" /> //<data files=".\reflection.xml" /> XmlWriter writer = navigator.InsertAfter(); // For now, lets simply write the default... bool dataAvailable = false; if (kind == BuildFrameworkKind.Silverlight) { string silverlightDir = groupContext["$SilverlightDataDir"]; if (!String.IsNullOrEmpty(silverlightDir) && Directory.Exists(silverlightDir)) { dataAvailable = true; writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", silverlightDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... Version latestVersion = BuildFrameworks.LatestSilverlightVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.Silverlight, silverlightDir, latestVersion, true, true); writer.WriteEndElement(); // end - data } } else if (kind == BuildFrameworkKind.Portable) { string portableDir = groupContext["$PortableDataDir"]; if (!String.IsNullOrEmpty(portableDir) && Directory.Exists(portableDir)) { dataAvailable = true; writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", portableDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... Version latestVersion = BuildFrameworks.LatestPortableVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.Portable, portableDir, latestVersion, true, false); writer.WriteEndElement(); // end - data } } else if (kind == BuildFrameworkKind.ScriptSharp) { string scriptSharpDir = groupContext["$ScriptSharpDataDir"]; if (!String.IsNullOrEmpty(scriptSharpDir) && Directory.Exists(scriptSharpDir)) { dataAvailable = true; if (!groupContext.IsEmbeddedGroup) { writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", scriptSharpDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... Version latestVersion = BuildFrameworks.LatestScriptSharpVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.ScriptSharp, scriptSharpDir, latestVersion, true, false); writer.WriteEndElement(); // end - data } } } if (!dataAvailable || kind == BuildFrameworkKind.None || kind == BuildFrameworkKind.DotNet || kind == BuildFrameworkKind.Compact) { string dotNetDataDir = Path.GetFullPath( Environment.ExpandEnvironmentVariables(ReferenceEngine.ReflectionDirectory)); writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", dotNetDataDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... this.WriteDataSource(writer, DataSourceType.Framework, dotNetDataDir, ReferenceEngine.ReflectionVersion, true, false); writer.WriteEndElement(); // end - data } // 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)) { dataAvailable = true; writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", blendDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // 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); writer.WriteEndElement(); // end - data } } //IList<string> linkDirs = groupContext.LinkDirectories; //if (linkDirs != null && linkDirs.Count != 0) //{ // for (int i = 0; i < linkDirs.Count; i++) // { // writer.WriteStartElement("data"); // start - data // writer.WriteAttributeString("base", linkDirs[i]); // writer.WriteAttributeString("recurse", "true"); // // Prevent warning, when the same namespace occurs in different // // assemblies... // writer.WriteAttributeString("warnOverride", "false"); // writer.WriteAttributeString("files", "*.xml"); // writer.WriteEndElement(); // end - data // } //} writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("files", String.Format(@".\{0}", groupContext["$ReflectionFile"])); writer.WriteEndElement(); // end - data writer.Close(); navigator.DeleteSelf(); }
private void CustomMergeToc(BuildTopicTocInfo topicParent, TocItem tocItem) { TocItemSourceType sourceType = tocItem.SourceType; if (sourceType == TocItemSourceType.None) { return; } IBuildNamedList <BuildGroupTocInfo> groupTocItems = _tocContext.Items; BuildGroupTocInfo groupToc = null; BuildTopicTocInfo tocInfo = null; switch (sourceType) { case TocItemSourceType.None: break; case TocItemSourceType.Group: groupToc = groupTocItems[tocItem.SourceId]; Debug.Assert(groupToc != null); break; case TocItemSourceType.Namespace: tocInfo = _tocContext[tocItem.SourceId]; break; case TocItemSourceType.NamespaceRoot: groupToc = groupTocItems[tocItem.SourceId]; Debug.Assert(groupToc != null); if (groupToc != null) { if (groupToc.IsRooted) { tocInfo = groupToc[0]; } else { throw new BuildException( "The specified reference group does not have a root container."); } groupToc = null; } break; case TocItemSourceType.Topic: tocInfo = _tocContext[tocItem.SourceId]; break; } if (groupToc != null) { if (!groupToc.Exclude) { topicParent.AddRange(groupToc.Items); } return; } if (tocInfo == null) { if (_logger != null) { _logger.WriteLine(String.Format( "The TOC topic for the item '{0}' cannot be found.", tocItem.Name), BuildLoggerLevel.Warn); } return; } BuildTopicTocInfo topicToc = null; if (tocItem.SourceRecursive) { topicToc = tocInfo; } else { topicToc = new BuildTopicTocInfo(tocInfo.Name, tocInfo.Source, topicParent); topicToc.Container = tocInfo.Container; } topicParent.Add(topicToc); for (int j = 0; j < tocItem.ItemCount; j++) { this.CustomMergeToc(topicToc, tocItem[j]); } }
private bool CustomMergeToc(string mergedToc, TocContent tocContent) { _tocContext.LoadAll(); IBuildNamedList <BuildGroupTocInfo> groupTocItems = _tocContext.Items; Debug.Assert(groupTocItems != null && groupTocItems.Count != 0); int itemCount = tocContent.Count; List <BuildTopicTocInfo> listToc = new List <BuildTopicTocInfo>(); for (int i = 0; i < itemCount; i++) { TocItem tocItem = tocContent[i]; TocItemSourceType sourceType = tocItem.SourceType; if (sourceType == TocItemSourceType.None) { continue; } BuildGroupTocInfo groupToc = null; BuildTopicTocInfo tocInfo = null; switch (sourceType) { case TocItemSourceType.None: break; case TocItemSourceType.Group: groupToc = groupTocItems[tocItem.SourceId]; Debug.Assert(groupToc != null); break; case TocItemSourceType.Namespace: tocInfo = _tocContext[tocItem.SourceId]; break; case TocItemSourceType.NamespaceRoot: groupToc = groupTocItems[tocItem.SourceId]; Debug.Assert(groupToc != null); if (groupToc != null) { if (groupToc.IsRooted) { tocInfo = groupToc[0]; } else { throw new BuildException( "The specified reference group does not have a root container."); } groupToc = null; } break; case TocItemSourceType.Topic: tocInfo = _tocContext[tocItem.SourceId]; break; } if (groupToc != null) { if (!groupToc.Exclude && groupToc.Count != 0) { listToc.AddRange(groupToc.Items); } continue; } if (tocInfo == null) { if (_logger != null) { _logger.WriteLine(String.Format( "The TOC topic for the item '{0}' cannot be found.", tocItem.Name), BuildLoggerLevel.Warn); } continue; } BuildTopicTocInfo topicToc = null; if (tocItem.SourceRecursive) { topicToc = tocInfo; } else { topicToc = new BuildTopicTocInfo(tocInfo.Name, tocInfo.Source, null); topicToc.Container = tocInfo.Container; } listToc.Add(topicToc); for (int j = 0; j < tocItem.ItemCount; j++) { this.CustomMergeToc(topicToc, tocItem[j]); } } if (listToc.Count == 0) { if (_logger != null) { _logger.WriteLine("The custom merging of the table of contents failed.", BuildLoggerLevel.Error); } return(false); } XmlWriter xmlWriter = null; try { XmlWriterSettings writerSettings = new XmlWriterSettings(); writerSettings.Indent = true; writerSettings.OmitXmlDeclaration = false; xmlWriter = XmlWriter.Create(mergedToc, writerSettings); xmlWriter.WriteStartElement("topics"); for (int i = 0; i < listToc.Count; i++) { listToc[i].WriteXml(xmlWriter); } xmlWriter.WriteEndElement(); xmlWriter.Close(); xmlWriter = null; return(true); } catch (Exception ex) { if (xmlWriter != null) { xmlWriter.Close(); xmlWriter = null; } if (_logger != null) { _logger.WriteLine(ex); } return(false); } }
public virtual void EndGroups() { _listGroups = null; _groupContexts = null; }