public override void Uninitialize() { _format = null; _context = null; base.Uninitialize(); }
public void Initialize(BuildContext context, BuildFormat format) { BuildExceptions.NotNull(format, "format"); _format = format; this.Initialize(context); }
public override void Uninitialize() { _context = null; _singleFormat = null; _listFormats = null; base.Uninitialize(); }
private void WriteSaveOutput(XmlWriter writer) { BuildFormat format = this.Format; // We automatically turn off the output indentation, if building // multiple format targets, since the cloning used in the multiple // format targets does not work well for indentations... BuildContext context = this.Context; int buildFormats = 1; string formatCount = context["$HelpFormatCount"]; if (!String.IsNullOrEmpty(formatCount)) { buildFormats = Convert.ToInt32(formatCount); } bool indentOutput = format.Indent; if (indentOutput) { indentOutput = (buildFormats <= 1); } //<component type="Microsoft.Ddue.Tools.SaveComponent" assembly="$(SandcastleComponent)"> //<save base=".\Output\html" path="concat($key,'.htm')" // indent="true" omit-xml-declaration="true" /> //</component> writer.WriteComment(" Save the result... "); writer.WriteStartElement("component"); // start - component writer.WriteAttributeString("type", "Microsoft.Ddue.Tools.SaveComponent"); writer.WriteAttributeString("assembly", "$(SandcastleComponent)"); // For now, lets simply write the default... writer.WriteStartElement("save"); writer.WriteAttributeString("base", Path.Combine(@".\Output\", format.FormatFolder)); string outputExt = format.OutputExtension; if (String.IsNullOrEmpty(outputExt)) { outputExt = ".htm"; } writer.WriteAttributeString("path", String.Format("concat($key,'{0}')", outputExt)); writer.WriteAttributeString("indent", indentOutput.ToString()); writer.WriteAttributeString("omit-xml-declaration", format.OmitXmlDeclaration.ToString()); writer.WriteAttributeString("add-xhtml-namespace", format.AddXhtmlNamespace.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); // end - component }
private void WriteMshc(XmlWriter writer) { BuildFormat format = this.Format; BuildSettings settings = this.Settings; BuildContext context = this.Context; if (format.FormatType != BuildFormatType.HtmlHelp3) { return; } BuildTocContext tocContext = context.TocContext; string tocFile = tocContext.GetValue("$" + format.Name); if (!String.IsNullOrEmpty(tocFile) && File.Exists(tocFile)) { tocFile = Path.GetFileName(tocFile); } else { tocFile = context["$HelpTocFile"]; } FormatMhv mshcFormat = (FormatMhv)format; //<!-- add Microsoft Help System data --> //<component type="Microsoft.Ddue.Tools.MSHCComponent" assembly="%DXROOT%\ProductionTools\BuildComponents.dll"> // <data self-branded="true" topic-version="100" toc-file=".\toc.xml" toc-parent="" toc-parent-version="100" /> //</component> writer.WriteComment(" Add Microsoft Help System data "); writer.WriteStartElement("component"); // start - component writer.WriteAttributeString("type", "Sandcastle.Components.MshcComponent"); writer.WriteAttributeString("assembly", "$(SandAssistComponent)"); // For now, lets simply write the default... writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("self-branded", mshcFormat.Selfbranded.ToString()); writer.WriteAttributeString("topic-version", mshcFormat.TopicVersion.ToString()); writer.WriteAttributeString("toc-file", @".\" + tocFile); writer.WriteAttributeString("toc-parent", mshcFormat.TocParent.ToString()); writer.WriteAttributeString("toc-parent-version", mshcFormat.TocParentVersion.ToString()); writer.WriteAttributeString("locale", settings.CultureInfo.Name.ToLower()); writer.WriteEndElement(); // end - data writer.WriteEndElement(); // end - component }
public virtual void Initialize(BuildFormat format, BuildSettings settings, BuildGroup group) { BuildExceptions.NotNull(format, "format"); BuildExceptions.NotNull(settings, "group"); BuildExceptions.NotNull(group, "group"); if (this.IsInitialized) { return; } _group = group; _format = format; _settings = settings; }
public override void Initialize(BuildContext context) { base.Initialize(context); if (base.IsInitialized) { _context = context; BuildSettings settings = context.Settings; if (settings == null || settings.Style == null) { this.IsInitialized = false; return; } BuildFormatList listFormats = settings.Formats; if (listFormats == null || listFormats.Count == 0) { this.IsInitialized = false; return; } int itemCount = listFormats.Count; _listFormats = new BuildFormatList(); 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; } else if (_listFormats.Count == 1) { _singleFormat = _listFormats[0]; } } }
public override void Initialize(BuildFormat format, BuildSettings settings, BuildGroup group) { base.Initialize(format, settings, group); if (!this.IsInitialized) { return; } _engineSettings = settings.EngineSettings[ BuildEngineType.Conceptual] as ConceptualEngineSettings; Debug.Assert(_engineSettings != null, "The settings does not include the reference engine settings."); if (_engineSettings == null) { this.IsInitialized = false; return; } }
public virtual void Uninitialize() { _group = null; _format = null; _settings = null; }
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; } } }
/// <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); } if (_singleFormat != null) { writer.WriteComment(String.Format( " For the help format: {0} ", _singleFormat.Name)); writer.WriteStartElement("default"); // start - default _singleFormat.WriteAssembler(_context, group, writer); writer.WriteEndElement(); // end - default } else { if (_listFormats == null) { return(false); } //<component type="Sandcastle.Components.CloneComponent" // assembly="%DXROOT%\ProductionTools\BuildComponents.dll"> // <branch> // </branch> // <default> // </default> //</component> int itemCount = _listFormats.Count; for (int i = 0; i < itemCount - 1; i++) { BuildFormat format = _listFormats[i]; if (format != null) { writer.WriteComment(String.Format( " For the help format: {0} ", format.Name)); writer.WriteStartElement("branch"); // start - branch format.WriteAssembler(_context, group, writer); writer.WriteEndElement(); // end - branch } } // For the default branch... BuildFormat formatDefault = _listFormats[itemCount - 1]; if (formatDefault != null) { writer.WriteComment(String.Format( " For the help format: {0} ", formatDefault.Name)); writer.WriteStartElement("default"); // start - default formatDefault.WriteAssembler(_context, group, writer); writer.WriteEndElement(); // end - default } } return(true); }
private bool ProcessToc(BuildContext context) { _logger = context.Logger; _tocContext = context.TocContext; bool tocIsCreated = false; if (_helpToc != null && !_helpToc.IsEmpty) { TocContent tocContent = _helpToc.Content; if (tocContent.Enabled) { tocIsCreated = this.CustomMergeToc(_mergedToc, tocContent); } } IList <BuildFormat> formats = context.Settings.Formats; int enabledFormats = 0; int customizedToc = 0; for (int i = 0; i < formats.Count; i++) { BuildFormat format = formats[i]; if (format.Enabled) { enabledFormats++; TocContent tocContent = format.TocContent; if (tocContent != null && !tocContent.IsEmpty && tocContent.Enabled) { string mergedToc = this.ExpandPath(format.TocFileName); if (this.CustomMergeToc(mergedToc, tocContent)) { string tocKey = "$" + format.Name; _tocContext.SetValue(tocKey, mergedToc); // For a successful merge, get the "root/first" topic... using (XmlReader reader = XmlReader.Create(mergedToc)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && String.Equals(reader.Name, "topic", StringComparison.OrdinalIgnoreCase)) { _tocContext.SetValue(tocKey + "-HelpTocRoot", reader.GetAttribute("file")); break; } } } customizedToc++; } } } } // If all the formats have customized TOC, there is no need to // proceed further, creating a general merged TOC... if (customizedToc != 0 && customizedToc == enabledFormats) { if (!tocIsCreated) { tocIsCreated = true; } } if (tocIsCreated) { return(tocIsCreated); } if (_listTocMerges != null && _listTocMerges.Count != 0) { int itemCount = _listTocMerges.Count; // If there is a single TOC, we simply rename it... if (itemCount == 1) { tocIsCreated = RenameToc(_mergedToc); } else { tocIsCreated = MergeToc(_mergedToc, itemCount); } } return(tocIsCreated); }
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; } int itemCount = _listGroups.Count; for (int i = 0; i < itemCount; i++) { ConceptualGroup 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); } _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; } itemCount = _listGroups.Count; for (int i = 0; i < itemCount; i++) { ConceptualGroup group = _listGroups[i]; group.Initialize(context); if (!group.IsInitialized) { this.IsInitialized = false; break; } } }