public override BuildGroup Clone() { ReferenceGroup group = new ReferenceGroup(this); base.Clone(group); if (_rootTitle != null) { group._rootTitle = String.Copy(_rootTitle); } if (_rootTopicId != null) { group._rootTopicId = String.Copy(_rootTopicId); } if (_topicSource != null) { group._topicSource = _topicSource.Clone(); } if (_topicContent != null) { group._topicContent = _topicContent.Clone(); } if (_versionInfo != null) { group._versionInfo = _versionInfo.Clone(); } return(group); }
public virtual void Initialize(BuildContext context, ReferenceGroup group) { BuildExceptions.NotNull(context, "context"); BuildExceptions.NotNull(group, "group"); if (_isInitialized) { return; } _context = context; _group = group; if (_engineSettings == null) { BuildSettings settings = context.Settings; Debug.Assert(settings != null, "The settings is not associated with the context."); if (settings == null) { return; } _engineSettings = (ReferenceEngineSettings)settings.EngineSettings[ BuildEngineType.Reference]; Debug.Assert(_engineSettings != null, "The settings does not include the reference engine settings."); if (_engineSettings == null) { return; } } _isInitialized = true; }
public override void Initialize(BuildContext context, ReferenceGroup group) { base.Initialize(context, group); if (this.IsInitialized) { if (_comments == null) { ReferenceEngineSettings engineSettings = this.EngineSettings; Debug.Assert(engineSettings != null); if (engineSettings == null) { this.IsInitialized = false; return; } _comments = engineSettings.Comments; Debug.Assert(_comments != null); if (_comments == null) { this.IsInitialized = false; return; } } } }
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 void Configure(ReferenceGroup group, string sourceFile, string destFile) { base.Configure(group, sourceFile, destFile); _group = group; this.Configure(); }
/// <summary> /// Initializes a new instance of the <see cref="ReferenceGroup"/> class with /// parameters copied from the specified argument, a copy constructor. /// </summary> /// <param name="source"> /// An instance of the <see cref="ReferenceGroup"/> class specifying the initial /// properties and states for this newly created instance. /// </param> /// <exception cref="ArgumentNullException"> /// If the <paramref name="source"/> is <see langword="null"/>. /// </exception> public ReferenceGroup(ReferenceGroup source) : base(source) { _versionType = source._versionType; _xmlnsForXaml = source._xmlnsForXaml; _rootTitle = source._rootTitle; _rootTopicId = source._rootTopicId; _topicSource = source._topicSource; _topicContent = source._topicContent; _rootTopicId = source._rootTopicId; }
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; } } }
public void Add(ReferenceGroup group) { BuildExceptions.NotNull(group, "group"); if (group.IsEmpty || group.Exclude) { throw new BuildException( "The build engine requires a valid build group."); } if (_listGroups == null) { _listGroups = new BuildList <ReferenceGroup>(); } _listGroups.Add(group); }
public override void Uninitialize() { if (_listGroups != null) { int itemCount = _listGroups.Count; for (int i = 0; i < itemCount; i++) { ReferenceGroup group = _listGroups[i]; if (group != null) { group.EndSources(); group.Uninitialize(); } } } base.Uninitialize(); }
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; } } } }
public override BuildStep CreateInitialSteps(BuildGroup group) { ReferenceGroup refGroup = group as ReferenceGroup; if (refGroup == null) { throw new BuildException("The build engine requires reference group."); } if (_listFormats == null || _listFormats.Count == 0) { return(null); } BuildMultiStep listSteps = new BuildMultiStep(); listSteps.Message = "References topics for the group: " + group.Name; listSteps.LogTitle = String.Empty; listSteps.LogTimeSpan = true; BuildSettings settings = this.Settings; string sandcastleDir = this.Context.StylesDirectory; BuildStyle outputStyle = settings.Style; if (String.IsNullOrEmpty(sandcastleDir)) { return(null); } // 1. Initialize the conceptual topics... StepReferenceInit stepInit = new StepReferenceInit(refGroup); stepInit.Message = "Initializing and copying reference contents"; stepInit.LogTitle = String.Empty; listSteps.Add(stepInit); string helpStyle = BuildStyle.StyleFolder( outputStyle.StyleType); string workingDir = this.Context.WorkingDirectory; // 2. Ensure that we have a valid list of folders... IList <string> listFolders = new List <string>(); IDictionary <string, bool> dicFolders = this.GetOutputFolders(listFolders); // 3. Handle the resources... StepDirectoryCopy copyResources = new StepDirectoryCopy( workingDir); copyResources.LogTitle = String.Empty; copyResources.Message = "Copying user-defined resources."; IList <ResourceContent> resourceContents = group.ResourceContents; if (resourceContents != null && resourceContents.Count != 0) { int contentCount = resourceContents.Count; for (int j = 0; j < contentCount; j++) { ResourceContent resourceContent = resourceContents[j]; if (resourceContent == null || resourceContent.Count == 0) { continue; } int itemCount = resourceContent.Count; for (int i = 0; i < itemCount; i++) { ResourceItem resource = resourceContent[i]; if (resource != null && !resource.IsEmpty) { string destFolder = resource.Destination; copyResources.Add(resource.Source, destFolder); // Add this to the output folders so that it is copied // to the final output/build directories... if (destFolder.StartsWith("Output", StringComparison.OrdinalIgnoreCase)) { DirectoryInfo info = new DirectoryInfo(destFolder); destFolder = info.Name; if (!String.IsNullOrEmpty(destFolder) && !dicFolders.ContainsKey(destFolder)) { dicFolders.Add(destFolder, true); listFolders.Add(destFolder); } } } } } } if (copyResources.IsValid) { listSteps.Add(copyResources); } else { StepNone placeHolder = new StepNone(); placeHolder.LogTitle = String.Empty; placeHolder.Message = "Copying user-defined resources."; listSteps.Add(placeHolder); } _listFolders = listFolders; this.CreateReflectionSteps(listSteps, refGroup, sandcastleDir, helpStyle); if (listSteps.Count != 0) { return(listSteps); } return(null); }
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 void Initialize(BuildContext context, ReferenceGroup group) { base.Initialize(context, group); if (!this.IsInitialized) { return; } _notApplicable = false; context["$TocExcludedNamespaces"] = String.Empty; if (_tocExclude == null) { ReferenceEngineSettings engineSettings = this.EngineSettings; Debug.Assert(engineSettings != null); if (engineSettings == null) { this.IsInitialized = false; return; } _tocExclude = engineSettings.TocExclude; Debug.Assert(_tocExclude != null); if (_tocExclude == null) { this.IsInitialized = false; return; } } ReferenceGroupContext groupContext = context.GroupContexts[group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } // 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; } IList <string> commentFiles = groupContext.CommentFiles; if (commentFiles != null && commentFiles.Count != 0) { _listTocExcludes = new BuildList <string>(); for (int i = 0; i < commentFiles.Count; i++) { XPathDocument document = new XPathDocument(commentFiles[i]); XPathNavigator documentNavigator = document.CreateNavigator(); XPathNodeIterator iterator = documentNavigator.Select( "//member[.//tocexclude or .//excludetoc]/@name"); if (iterator != null && iterator.Count != 0) { foreach (XPathNavigator navigator in iterator) { _listTocExcludes.Add(navigator.Value); } } } if (_listTocExcludes.Count == 0) { this.IsInitialized = false; return; } } else { this.IsInitialized = false; return; } }
/// <summary> /// Applies the processing operations defined by this visitor to the /// specified reference group. /// </summary> /// <param name="group"> /// The <see cref="ReferenceGroup">reference group</see> to which the processing /// operations defined by this visitor will be applied. /// </param> /// <exception cref="ArgumentNullException"> /// If the <paramref name="group"/> is <see langword="null"/>. /// </exception> protected abstract void OnVisit(ReferenceGroup group);
/// <summary> /// Applies the processing operations defined by this visitor to the /// specified reference group. /// </summary> /// <param name="group"> /// The <see cref="ReferenceGroup">reference group</see> to which the processing /// operations defined by this visitor will be applied. /// </param> /// <remarks> /// The visitor must be initialized before any call this method. /// </remarks> /// <exception cref="ArgumentNullException"> /// If the <paramref name="group"/> is <see langword="null"/>. /// </exception> public void Visit(ReferenceGroup group) { BuildExceptions.NotNull(group, "group"); this.OnVisit(group); }
/// <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); } BuildStyle style = _settings.Style; IList <string> sharedContents = style.GetSharedContents( BuildEngineType.Reference); if (sharedContents == null || sharedContents.Count == 0) { throw new BuildException( "A document shared content is required."); } string workingDir = _context.WorkingDirectory; if (String.IsNullOrEmpty(workingDir)) { throw new BuildException( "The working directory is required, it is not specified."); } writer.WriteComment(" Include the reference shared content files "); int itemCount = sharedContents.Count; for (int i = 0; i < itemCount; i++) { string sharedContent = sharedContents[i]; if (String.IsNullOrEmpty(sharedContent) == false) { writer.WriteStartElement("content"); writer.WriteAttributeString("file", sharedContent); writer.WriteEndElement(); } } //<!-- Overrides the contents to customize it --> //<content file=".\SharedContent.xml" /> sharedContents = null; string path = _settings.ContentsDirectory; if (String.IsNullOrEmpty(path) == false && System.IO.Directory.Exists(path) == true) { sharedContents = style.GetSharedContents(); } if (sharedContents != null && sharedContents.Count != 0) { SharedContentConfigurator configurator = new SharedContentConfigurator(); // Initialize the configurator... configurator.Initialize(_context, BuildEngineType.Reference); // Create and add any shared contents... IList <SharedItem> formatShared = _format.PrepareShared( _settings, group); if (formatShared != null && formatShared.Count > 0) { configurator.Contents.Add(formatShared); } IList <SharedItem> groupShared = group.PrepareShared(_context); if (groupShared != null && groupShared.Count > 0) { configurator.Contents.Add(groupShared); } // Create and add any shared content rule... IList <RuleItem> formatRules = _format.PrepareSharedRule( _settings, group); if (formatRules != null && formatRules.Count != 0) { configurator.Rules.Add(formatRules); } writer.WriteComment(" Overrides the contents to customize it... "); itemCount = sharedContents.Count; for (int i = 0; i < itemCount; i++) { string sharedContent = sharedContents[i]; if (String.IsNullOrEmpty(sharedContent)) { continue; } string sharedFile = Path.Combine(path, sharedContent); if (!File.Exists(sharedFile)) { continue; } string fileName = groupContext["$SharedContentFile"]; string filePrefix = _format["SharedContentSuffix"]; if (!String.IsNullOrEmpty(filePrefix)) { string groupIndex = groupContext["$GroupIndex"]; if (groupIndex == null) { groupIndex = String.Empty; } fileName = "ApiSharedContent-" + filePrefix + groupIndex + ".xml"; } if (itemCount > 1) // not yet the case.... { fileName = fileName.Replace(".", i.ToString() + "."); } string finalSharedFile = Path.Combine(workingDir, fileName); configurator.Configure(sharedFile, finalSharedFile); writer.WriteStartElement("content"); writer.WriteAttributeString("file", fileName); writer.WriteEndElement(); } configurator.Uninitialize(); } ReferenceGroup refGroup = (ReferenceGroup)group; if (!refGroup.IsSingleVersion) { writer.WriteComment(" Shared items from the version information. "); writer.WriteStartElement("content"); writer.WriteAttributeString("file", Path.Combine(workingDir, groupContext["$ApiVersionsSharedContentFile"])); writer.WriteEndElement(); } return(true); }
private void CreateLinkGroups(BuildContext context) { context["$EmbeddedScriptSharp"] = Boolean.FalseString; if (_listGroups == null || _listGroups.Count == 0) { return; } BuildLogger logger = context.Logger; List <ReferenceGroup> buildGroups = new List <ReferenceGroup>(); IList <BuildGroupContext> groupContexts = context.GroupContexts; bool hasScriptSharp = false; BuildFrameworkType latestScriptSharp = BuildFrameworkType.None; int itemCount = _listGroups.Count; int index = 0; for (int i = 0; i < itemCount; i++) { ReferenceGroup group = _listGroups[i]; ReferenceContent content = group.Content; if (content != null) { BuildFrameworkType frameworkType = content.FrameworkType; if (frameworkType.Kind == BuildFrameworkKind.ScriptSharp) { hasScriptSharp = true; if (frameworkType > latestScriptSharp) { latestScriptSharp = frameworkType; } } } } // Include contents from the Script# framework for correct // linking, since there is MSDN links for the Script#... if (hasScriptSharp && _engineSettings.EmbedScriptSharpFramework && latestScriptSharp.Kind == BuildFrameworkKind.ScriptSharp) { BuildFramework framework = BuildFrameworks.GetFramework(latestScriptSharp); if (framework == null) { framework = BuildFrameworks.LatestScriptSharp; } if (framework != null) { ReferenceGroup buildGroup = new ReferenceGroup( "Embedded ScriptSharp - " + ReferenceGroup.NextGroupName(), Guid.NewGuid().ToString()); ReferenceContent content = buildGroup.Content; string[] assemblies = Directory.GetFiles(framework.AssemblyDir, "*.dll", SearchOption.AllDirectories); for (int i = 0; i < assemblies.Length; i++) { string assembly = assemblies[i]; string comments = Path.ChangeExtension(assembly, ".xml"); if (File.Exists(comments)) { content.AddItem(comments, assembly); } } buildGroup.ExcludeToc = true; buildGroup.SyntaxType = BuildSyntaxType.CSharp | BuildSyntaxType.JavaScript; buildGroups.Add(buildGroup); // Create the group context... ReferenceGroupContext buildGroupContext = new ReferenceGroupContext(buildGroup); buildGroupContext.IsEmbeddedGroup = true; groupContexts.Add(buildGroupContext); string indexText = (itemCount + index + 1).ToString(); // Create the build dynamic properties... buildGroupContext.CreateProperties(indexText); // This has no effect, since the newly created group will // not have any content source. buildGroup.BeginSources(context); context["$EmbeddedScriptSharp"] = Boolean.TrueString; } } if (buildGroups.Count != 0) { _listGroups.Add(buildGroups); } // Process the user-provided link sources... List <ReferenceLinkSource> linkSources = null; IList <ReferenceLinkSource> listSources = _engineSettings.LinkSources as IList <ReferenceLinkSource>; if (listSources != null && listSources.Count != 0) { for (int i = 0; i < listSources.Count; i++) { ReferenceLinkSource linkSource = listSources[i]; if (linkSource == null || !linkSource.IsValid) { if (logger != null) { string title = linkSource.Title; if (title == null) { title = String.Empty; } logger.WriteLine(String.Format( "A provided reference link source titled = '{0}', at index = '{1}' is invalid.", title, i), BuildLoggerLevel.Warn); } continue; } if (linkSources == null) { linkSources = new List <ReferenceLinkSource>(); } linkSources.Add(linkSource); } } // Process the automatic link sources... BuildSpecialSdkType webMvcSdkType = _engineSettings.WebMvcSdkType; if (webMvcSdkType != BuildSpecialSdkType.None && webMvcSdkType != BuildSpecialSdkType.Null) { BuildSpecialSdk webSdk = BuildSpecialSdks.GetSdk(webMvcSdkType, BuildFrameworkKind.DotNet); if (webSdk != null) { ReferenceLinkSource linkSource = new ReferenceLinkSource(); linkSource.LinkType = BuildLinkType.Msdn; linkSource.Title = webMvcSdkType.Label; linkSource.FrameworkType = BuildFrameworks.LatestFramework.FrameworkType; string aspMVCDir = webSdk.AssemblyDir; string[] assemblyFiles = Directory.GetFiles( webSdk.AssemblyDir, "*.dll", SearchOption.TopDirectoryOnly); for (int i = 0; i < assemblyFiles.Length; i++) { string assemblyFile = assemblyFiles[i]; string commentFile = Path.ChangeExtension(assemblyFile, ".xml"); if (File.Exists(commentFile)) { ReferenceItem refItem = new ReferenceItem( commentFile, assemblyFile); refItem.XamlSyntax = false; linkSource.Add(refItem); } } if (linkSource.IsValid) { if (linkSources == null) { linkSources = new List <ReferenceLinkSource>(); } linkSources.Add(linkSource); } } } if (linkSources != null && linkSources.Count != 0) { context.SetValue("$ReferenceLinkSources", linkSources); itemCount = linkSources.Count; if (_linkGroups == null) { _linkGroups = new BuildList <ReferenceGroup>(); } for (int i = 0; i < itemCount; i++) { ReferenceLinkSource linkSource = linkSources[i]; ReferenceGroup linkGroup = new ReferenceGroup( "Reference Links - " + ReferenceGroup.NextGroupName(), linkSource.SourceId, linkSource); linkGroup.ExcludeToc = true; _linkGroups.Add(linkGroup); // Create the group context... ReferenceGroupContext linkGroupContext = new ReferenceGroupContext(linkGroup); linkGroupContext.IsLinkGroup = true; groupContexts.Add(linkGroupContext); string indexText = String.Empty; if (itemCount > 1) { indexText = (i + 1).ToString(); } // Create the build dynamic properties... linkGroupContext.CreateProperties(indexText); // This has no effect, since the newly created group will // not have any content source. linkGroup.BeginSources(context); } } }
private void CreateReflectionSteps(BuildMultiStep listSteps, ReferenceGroup group, string sandcastleDir, string helpStyle) { Debug.Assert(_engineSettings != null); if (_engineSettings == null) { return; } BuildContext context = this.Context; BuildSettings settings = this.Settings; ReferenceGroupContext groupContext = context.GroupContexts[group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } string workingDir = context.WorkingDirectory; ReferenceContent content = group.Content; string assemblyDir = Path.Combine(workingDir, groupContext.AssemblyFolder); string dependencyDir = Path.Combine(workingDir, groupContext.DependencyFolder); DependencyContent dependencies = content.Dependencies; string reflectionFile = groupContext["$ReflectionFile"]; string manifestFile = groupContext["$ManifestFile"]; string refBuilderFile = groupContext["$ReflectionBuilderFile"]; string tocFile = groupContext["$TocFile"]; BuildStyleType outputStyle = settings.Style.StyleType; string tempText = null; string arguments = null; string application = null; bool ripOldApis = true; string assemblyFiles = null; string dependencyFiles = null; string outputFile = null; string configurationFile = null; ReferenceVisibilityConfiguration visibility = _engineSettings.Visibility; Debug.Assert(visibility != null); // 1. Create the reflection and the manifest StringBuilder textBuilder = new StringBuilder(); if (group.IsSingleVersion) { // Call MRefBuilder to generate the reflection... // MRefBuilder Assembly.dll // /out:reflection.org /config:MRefBuilder.config // /internal- application = Path.Combine(context.SandcastleToolsDirectory, "MRefBuilder.exe"); assemblyFiles = String.Format(@"{0}\*.*", assemblyDir); dependencyFiles = String.Format(@"{0}\*.*", dependencyDir); outputFile = Path.ChangeExtension(reflectionFile, ".ver"); configurationFile = Path.Combine(workingDir, refBuilderFile); textBuilder.Append(assemblyFiles); textBuilder.Append(" /dep:" + dependencyFiles); textBuilder.AppendFormat(" /out:{0} /config:{1}", outputFile, refBuilderFile); if (visibility != null && visibility.IncludeInternalsMembers) { textBuilder.Append(" /internal+"); } else { textBuilder.Append(" /internal-"); } arguments = textBuilder.ToString(); outputFile = Path.Combine(workingDir, outputFile); } else { // Call the VersionBuilder to create the combined reflection file... application = Path.Combine(context.SandcastleToolsDirectory, "VersionBuilder.exe"); textBuilder.AppendFormat(" /config:{0} /out:{1}", groupContext["$ApiVersionsBuilderFile"], Path.ChangeExtension(reflectionFile, ".org")); configurationFile = Path.Combine(workingDir, groupContext["$ApiVersionsBuilderFile"]); ReferenceVersionInfo versionInfo = group.VersionInfo; ripOldApis = versionInfo.RipOldApis; if (ripOldApis) { textBuilder.Append(" /rip+"); } else { textBuilder.Append(" /rip-"); } arguments = textBuilder.ToString(); } StepReflectionBuilder refBuilder = new StepReflectionBuilder(workingDir, application, arguments); refBuilder.Group = group; refBuilder.LogTitle = String.Empty; refBuilder.Message = "Creating XML-formatted reflection information."; refBuilder.CopyrightNotice = 2; // For the direct use of the Sandcastle library, we need the // following parameters... refBuilder.RipOldApis = ripOldApis; refBuilder.DocumentInternals = (visibility != null && visibility.IncludeInternalsMembers); refBuilder.ConfigurationFile = configurationFile; refBuilder.ReflectionFile = outputFile; refBuilder.AssemblyFiles.Add(assemblyFiles); refBuilder.DependencyFiles.Add(dependencyFiles); listSteps.Add(refBuilder); textBuilder.Length = 0; // 2. Create the reflection and comment refining step... StepReferenceRefine referenceRefine = new StepReferenceRefine(workingDir); referenceRefine.LogTitle = String.Empty; referenceRefine.Message = "Refining the reflection files - filtering and cleaning"; referenceRefine.Group = group; listSteps.Add(referenceRefine); textBuilder.Length = 0; // 3. Apply Transforms // XslTransform.exe // /xsl:"%DXROOT%\ProductionTransforms\ApplyVSDocModel.xsl" // reflection.org // /xsl:"%DXROOT%\ProductionTransforms\AddFriendlyFilenames.xsl" // /out:reflection.xml /arg:IncludeAllMembersTopic=true // /arg:IncludeInheritedOverloadTopics=true /arg:project=Project application = Path.Combine(context.SandcastleToolsDirectory, "XslTransform.exe"); string prodPath = Path.Combine(sandcastleDir, "ProductionTransforms"); string textTemp = String.Empty; if (group.EnableXmlnsForXaml) { textTemp = Path.Combine(prodPath, "AddXamlSyntaxData.xsl"); if (!String.IsNullOrEmpty(textTemp)) { textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp); textTemp = String.Empty; } } if (outputStyle == BuildStyleType.ClassicWhite || outputStyle == BuildStyleType.ClassicBlue) { textTemp = Path.Combine(prodPath, "ApplyVSDocModel.xsl"); } else if (outputStyle == BuildStyleType.Lightweight) { } else if (outputStyle == BuildStyleType.ScriptFree) { } if (!String.IsNullOrEmpty(textTemp)) { textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp); textTemp = String.Empty; } ReferenceNamingMethod namingMethod = _engineSettings.Naming; if (namingMethod == ReferenceNamingMethod.Guid) { textTemp = Path.Combine(prodPath, "AddGuidFilenames.xsl"); } else if (namingMethod == ReferenceNamingMethod.MemberName) { textTemp = Path.Combine(prodPath, "AddFriendlyFilenames.xsl"); } else { textTemp = Path.Combine(prodPath, "AddGuidFilenames.xsl"); } if (!String.IsNullOrEmpty(textTemp)) { textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp); textTemp = String.Empty; } textBuilder.Append(" " + Path.ChangeExtension(reflectionFile, ".org")); textBuilder.AppendFormat(" /out:{0}", reflectionFile); textBuilder.AppendFormat(" /arg:IncludeAllMembersTopic={0}", _engineSettings.IncludeAllMembersTopic ? "true" : "false"); textBuilder.AppendFormat(" /arg:IncludeInheritedOverloadTopics={0}", _engineSettings.IncludeInheritedOverloadTopics ? "true" : "false"); bool rootContainer = _engineSettings.RootNamespaceContainer; string rootTitle = group.RootNamespaceTitle; if (rootContainer && !String.IsNullOrEmpty(rootTitle)) { textBuilder.Append(" /arg:project=Project"); // Indicate that this reference group is rooted... groupContext["$IsRooted"] = Boolean.TrueString; } arguments = textBuilder.ToString(); StepReferenceModel applyDocProcess = new StepReferenceModel( workingDir, application, arguments); applyDocProcess.Group = group; applyDocProcess.LogTitle = String.Empty; applyDocProcess.Message = "Xsl Transformation - Applying model and adding filenames"; applyDocProcess.CopyrightNotice = 2; listSteps.Add(applyDocProcess); textBuilder.Length = 0; // 4. and finally the manifest... // XslTransform.exe // /xsl:"%DXROOT%\ProductionTransforms\ReflectionToManifest.xsl" // reflection.xml /out:manifest.xml application = Path.Combine(context.SandcastleToolsDirectory, "XslTransform.exe"); textTemp = Path.Combine(prodPath, "ReflectionToManifest.xsl"); textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp); textBuilder.AppendFormat(" {0} /out:{1}", reflectionFile, manifestFile); arguments = textBuilder.ToString(); StepReferenceManifest manifestProcess = new StepReferenceManifest( workingDir, application, arguments); manifestProcess.Group = group; manifestProcess.LogTitle = String.Empty; manifestProcess.Message = "Xsl Transformation - Reflection to Manifest"; manifestProcess.CopyrightNotice = 2; listSteps.Add(manifestProcess); // 5. Create the reflection table of contents // XslTransform.exe // /xsl:"%DXROOT%\ProductionTransforms\createvstoc.xsl" // reflection.xml /out:ApiToc.xml application = Path.Combine(context.SandcastleToolsDirectory, "XslTransform.exe"); if (outputStyle == BuildStyleType.ClassicWhite || outputStyle == BuildStyleType.ClassicBlue) { tempText = Path.Combine(sandcastleDir, @"ProductionTransforms\CreateVSToc.xsl"); } else if (outputStyle == BuildStyleType.Lightweight) { } else if (outputStyle == BuildStyleType.ScriptFree) { } arguments = String.Format("/xsl:\"{0}\" {1} /out:{2}", tempText, reflectionFile, tocFile); StepReferenceToc tocProcess = new StepReferenceToc(workingDir, application, arguments); tocProcess.LogTitle = String.Empty; tocProcess.Message = "Xsl Transformation - Creating References TOC"; tocProcess.Group = group; tocProcess.CopyrightNotice = 2; listSteps.Add(tocProcess); }
public ReferenceGroupContext(ReferenceGroup group, string contextId) : base(group, contextId) { _contexts = new BuildKeyedList <ReferenceGroupContext>(); }
/// <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); } ReferenceGroup refGroup = group as ReferenceGroup; if (refGroup == null) { return(false); } ReferenceGroupContext theContext = _context.GroupContexts[group.Id] as ReferenceGroupContext; if (theContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceVersionType versionType = refGroup.VersionType; bool isBasicVersion = versionType == ReferenceVersionType.Assembly || versionType == ReferenceVersionType.AssemblyAndFile; writer.WriteStartElement("versionInfo"); //start: versionInfo writer.WriteAttributeString("enabled", isBasicVersion.ToString()); writer.WriteAttributeString("type", versionType.ToString()); writer.WriteAttributeString("sourceFile", Path.Combine(_context.WorkingDirectory, theContext["$ReflectionFile"])); writer.WriteEndElement(); //end: versionInfo //NOTE: This is now handled by the ReferenceCommentVisitor... //if (_settings.BuildConceptual) //{ // IList<BuildGroupContext> groupContexts = _context.GroupContexts; // for (int i = 0; i < groupContexts.Count; i++) // { // BuildGroupContext groupContext = groupContexts[i]; // if (groupContext.GroupType == BuildGroupType.Conceptual) // { // writer.WriteStartElement("conceptualLinks"); //start: conceptualLinks // writer.WriteAttributeString("enabled", "true"); // writer.WriteEndElement(); //end: conceptualLinks // break; // } // } //} 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"); if (!this.Enabled || !this.IsInitialized) { return(false); } ReferenceGroup refGroup = group as ReferenceGroup; if (refGroup == null) { return(false); } ReferenceGroupContext theContext = _context.GroupContexts[group.Id] as ReferenceGroupContext; if (theContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceVersionType versionType = refGroup.VersionType; if (versionType != ReferenceVersionType.Advanced) { return(false); } ReferenceVersionInfo versionInfo = refGroup.VersionInfo; if (versionInfo == null || versionInfo.IsEmpty || !versionInfo.PlatformFilters) { return(false); } IList <ReferenceVersions> platforms = theContext.Versions; if (platforms == null || platforms.Count == 0) { return(false); } //<component type="Microsoft.Ddue.Tools.PlatformsComponent" assembly="%DXROOT%\ProductionTools\BuildComponents.dll"> // <!-- The order of filter files in this config determines the order of platforms in the output. --> // <filter files=".\SupportFiles\Platforms\WinVista.xml"/> // <filter files=".\SupportFiles\Platforms\WinXP.xml"/> // <filter files=".\SupportFiles\Platforms\WinXpMediaCenter.xml"/> // <filter files=".\SupportFiles\Platforms\WinXPPro64.xml"/> // <filter files=".\SupportFiles\Platforms\WinXPSE.xml"/> // <filter files=".\SupportFiles\Platforms\WinSvr2003.xml"/> // <filter files=".\SupportFiles\Platforms\WinSvr2000.xml"/> // <filter files=".\SupportFiles\Platforms\WinME.xml"/> // <filter files=".\SupportFiles\Platforms\Win98.xml"/> // <filter files=".\SupportFiles\Platforms\WindowsCE.xml"/> // <filter files=".\SupportFiles\Platforms\SmartPhone.xml"/> // <filter files=".\SupportFiles\Platforms\PocketPC.xml"/> // <filter files=".\SupportFiles\Platforms\Xbox360.xml"/> //</component> writer.WriteComment(" The order of filter files in this config determines the order of platforms in the output. "); for (int i = 0; i < platforms.Count; i++) { ReferenceVersions platform = platforms[i]; string platformFile = platform.PlatformFile; if (String.IsNullOrEmpty(platformFile) || !File.Exists(platformFile)) { continue; } writer.WriteStartElement("filter"); //start: filter writer.WriteAttributeString("files", platformFile); writer.WriteEndElement(); //end: filter } return(true); }
/// <summary> /// Applies the processing operations defined by this visitor to the /// specified reference group. /// </summary> /// <param name="group"> /// The <see cref="ReferenceGroup">reference group</see> to which the processing /// operations defined by this visitor will be applied. /// </param> /// <exception cref="ArgumentNullException"> /// If the <paramref name="group"/> is <see langword="null"/>. /// </exception> protected override void OnVisit(ReferenceGroup group) { BuildExceptions.NotNull(group, "group"); if (!this.IsInitialized) { throw new BuildException( "ReferenceProjectVisitor: The reference dependency resolver is not initialized."); } BuildContext context = this.Context; BuildLogger logger = context.Logger; if (logger != null) { logger.WriteLine("Begin - Resolving reference dependencies.", BuildLoggerLevel.Info); } ReferenceGroupContext groupContext = context.GroupContexts[group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceGroupContext sourceContext = groupContext; if (!String.IsNullOrEmpty(_sourceId)) { sourceContext = groupContext.Contexts[_sourceId] as ReferenceGroupContext; } if (sourceContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } _linkCommentFiles = new List <string>(); _bindingRedirects = new List <DependencyItem>(); _searchDirectories = new HashSet <string>(StringComparer.OrdinalIgnoreCase); sourceContext.LinkCommentFiles = _linkCommentFiles; sourceContext.BindingRedirects = _bindingRedirects; // We add the comment files from the link sources so that the // document can contain comments from these sources if needed... IList <ReferenceLinkSource> linkSources = context.GetValue("$ReferenceLinkSources") as IList <ReferenceLinkSource>; if (linkSources != null && linkSources.Count != 0) { for (int i = 0; i < linkSources.Count; i++) { ReferenceLinkSource linkSource = linkSources[i]; IEnumerable <ReferenceItem> linkItems = linkSource.Items; foreach (ReferenceItem linkItem in linkItems) { // Set if the comment file exists and link it... BuildFilePath linkCommentPath = linkItem.Comments; if (linkCommentPath != null && linkCommentPath.Exists) { _linkCommentFiles.Add(linkCommentPath.Path); } else { string linkCommentFile = Path.ChangeExtension( linkItem.Assembly, ".xml"); if (File.Exists(linkCommentFile)) { _linkCommentFiles.Add(linkCommentFile); } } } } } string dependencyDir = sourceContext.DependencyDir; string searchDir = String.Copy(dependencyDir); if (!searchDir.EndsWith("\\")) { searchDir += "\\"; } _searchDirectories.Add(searchDir); ReferenceContent content = _content; if (content == null) { content = group.Content; } DependencyContent dependencies = content.Dependencies; _dependencyContent = dependencies; this.ResolveDependency(sourceContext, content); if (_dependencyContent != null && _dependencyContent.Count != 0) { this.CreateDependency(_dependencyContent, dependencyDir); } if (_resolveContent != null && _resolveContent.Count != 0) { this.CreateDependency(_resolveContent, dependencyDir); } //IList<string> bindingSources = sourceContext.BindingSources; //if (bindingSources == null) //{ // bindingSources = new BuildList<string>(); // sourceContext.BindingSources = bindingSources; //} //foreach (string dir in _searchDirectories) //{ // bindingSources.Add(dir); //} if (logger != null) { logger.WriteLine("Completed - Resolving reference dependencies.", BuildLoggerLevel.Info); } }
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; } } }
public void Configure(ReferenceGroup group, string sourceFile, string destFile) { BuildExceptions.NotNull(group, "group"); BuildExceptions.PathMustExist(sourceFile, "sourceFile"); BuildExceptions.NotNullNotEmpty(destFile, "destFile"); if (this.IsInitialized == false) { throw new BuildException( "The reference filter configurator is not initialized."); } _group = group; _sourceFile = sourceFile; _destFile = destFile; string destDir = Path.GetDirectoryName(destFile); if (Directory.Exists(destDir) == false) { Directory.CreateDirectory(destDir); } if (this.IsInitialized == false || String.IsNullOrEmpty(_sourceFile) || String.IsNullOrEmpty(_destFile)) { return; } XmlDocument document = new XmlDocument(); document.Load(_sourceFile); XPathNavigator navigator = document.CreateNavigator(); XPathNodeIterator iterator = navigator.Select("//SandcastleItem"); int nodeCount = iterator.Count; XPathNavigator[] nodeNavigators = new XPathNavigator[iterator.Count]; for (int i = 0; i < nodeNavigators.Length; i++) { iterator.MoveNext(); nodeNavigators[i] = iterator.Current.Clone(); } string configKeyword = null; ConfiguratorItem configItem = null; for (int i = 0; i < nodeCount; i++) { XPathNavigator nodeNavigator = nodeNavigators[i]; configKeyword = nodeNavigator.GetAttribute("name", String.Empty); if (String.IsNullOrEmpty(configKeyword)) { continue; } configItem = _configContent[configKeyword]; if (configItem != null) { configItem.Execute(nodeNavigator); } } this.ApplyContents(document); document.Save(_destFile); }
public ReferenceGroupContext(ReferenceGroup group) : base(group) { _contexts = new BuildKeyedList <ReferenceGroupContext>(); }