/// <summary> /// Initializes a new instance of the <see cref="BuildStyle"/> class /// with parameters copied from the specified instance of the /// <see cref="BuildStyle"/> class, a copy constructor. /// </summary> /// <param name="source"> /// An instance of the <see cref="BuildStyle"/> class from which the /// initialization parameters or values will be copied. /// </param> /// <exception cref="ArgumentNullException"> /// If the parameter <paramref name="source"/> is <see langword="null"/>. /// </exception> public BuildStyle(BuildStyle source) : base(source) { _styleDir = source._styleDir; _styleName = source._styleName; _stylePresentation = source._stylePresentation; _styleType = source._styleType; _scripts = source._scripts; _snippets = source._snippets; _styleSheets = source._styleSheets; _mathPackages = source._mathPackages; _mathCommands = source._mathCommands; }
/// <summary> /// Initializes a new instance of the <see cref="BuildStyle"/> class with /// the specified style type. /// </summary> /// <param name="type"> /// An enumeration of the type <see cref="BuildStyleType"/> specifying the type /// of the transformation and presentation style. /// </param> public BuildStyle(BuildStyleType type) { _styleType = type; _scripts = new ScriptContent("CommonScripts"); _styleSheets = new StyleSheetContent("CommonStyleSheets"); _snippets = new SnippetContent("CommonSnippets"); _mathPackages = new MathPackageContent(); _mathCommands = new MathCommandContent(); string sandAssistDir = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location); string codeStyleFile = Path.Combine(sandAssistDir, @"Styles\IrisModifiedVS.css"); string assistStyleFile = Path.Combine(sandAssistDir, String.Format(@"Styles\{0}\SandAssist.css", BuildStyle.StyleFolder(type))); StyleSheetItem codeStyle = new StyleSheetItem("CodeStyle", codeStyleFile); codeStyle.Condition = "CodeHighlight"; _styleSheets.Add(codeStyle); StyleSheetItem assistStyle = new StyleSheetItem("AssistStyle", assistStyleFile); _styleSheets.Add(assistStyle); string assistScriptFile = Path.Combine(sandAssistDir, String.Format(@"Scripts\{0}\SandAssist.js", BuildStyle.StyleFolder(type))); ScriptItem assistScript = new ScriptItem("AssistScripts", assistScriptFile); _scripts.Add(assistScript); }
/// <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); } BuildStyle buildStyle = _settings.Style; Debug.Assert(buildStyle != null, "The style object cannot be null (or Nothing)."); if (buildStyle == null) { return(false); } //<component type="Sandcastle.Components.ReferenceCodeComponent" assembly="$(SandAssistComponent)"> // <options mode="IndirectIris" tabSize="4" lineNumbers="true" outlining="false" storage="Sqlite" separator="..."/> // // <!--The following options are for processing codeReference tags in the // reference help. // It is a replacement of the ExampleComponent, providing better coloring, // minimum memory usage etc. // // $codeSnippets // @storage: * Indicates where the code snippets should be stored after loading // * Possible values are // - Memory: the snippets are stored in memory similar to // the ExampleComponent. // - Database: the snippets are stored in Sqlite database. // * Default: Database // @separator: * For multi-parts snippets, this defines the separator... // * Default: ...--> // // <!--<codeSnippets> // <codeSnippet source=".\CodeSnippetSample.xml" format="Sandcastle" /> // </codeSnippets>--> // <SandcastleItem name="%CodeSnippets%" /> //</component> writer.WriteStartElement("options"); //start: options writer.WriteAttributeString("mode", _highlightMode); writer.WriteAttributeString("tabSize", _tabSize.ToString()); writer.WriteAttributeString("lineNumbers", _showLineNumbers.ToString()); writer.WriteAttributeString("outlining", _showOutlining.ToString()); writer.WriteAttributeString("storage", _snippetStorage.ToString()); writer.WriteAttributeString("separator", _snippetSeparator); writer.WriteEndElement(); //end: options IList <CodeSnippetContent> listSnippets = group.SnippetContents; if (listSnippets != null && listSnippets.Count != 0) { writer.WriteStartElement("codeSnippets"); // start - codeSnippets int contentCount = listSnippets.Count; for (int i = 0; i < contentCount; i++) { CodeSnippetContent snippetContent = listSnippets[i]; if (snippetContent == null || snippetContent.IsEmpty) { continue; } writer.WriteStartElement("codeSnippet"); // start - codeSnippet writer.WriteAttributeString("source", snippetContent.ContentFile); writer.WriteAttributeString("format", "Sandcastle"); writer.WriteEndElement(); // end - codeSnippet } writer.WriteEndElement(); // end - codeSnippets } SnippetContent snippets = buildStyle.Snippets; if (snippets != null && snippets.Count != 0) { writer.WriteStartElement("codeSources"); // start - codeSources for (int i = 0; i < snippets.Count; i++) { SnippetItem snippetItem = snippets[i]; if (snippetItem == null || snippetItem.IsEmpty) { continue; } writer.WriteStartElement("codeSource"); // start - codeSource writer.WriteAttributeString("source", snippetItem.Source); writer.WriteAttributeString("format", "Sandcastle"); writer.WriteEndElement(); // end - codeSource } // The excludedUnits is required by the SnippetComponent, // we maintain that... writer.WriteStartElement("excludedUnits"); // start - excludedUnits IList <string> excludedUnits = snippets.ExcludedUnitFolders; if (excludedUnits != null && excludedUnits.Count != 0) { for (int i = 0; i < excludedUnits.Count; i++) { string unitFolder = excludedUnits[i]; if (String.IsNullOrEmpty(unitFolder)) { continue; } writer.WriteStartElement("unitFolder"); // start - unitFolder writer.WriteAttributeString("name", unitFolder); writer.WriteEndElement(); // end - unitFolder } } writer.WriteEndElement(); // end - excludedUnits writer.WriteStartElement("languages"); // start - languages IList <SnippetLanguage> languages = snippets.Languages; if (languages != null && languages.Count != 0) { for (int i = 0; i < languages.Count; i++) { SnippetLanguage language = languages[i]; if (!language.IsValid) { continue; } writer.WriteStartElement("language"); // start - language writer.WriteAttributeString("unit", language.Unit); writer.WriteAttributeString("languageId", language.LanguageId); writer.WriteAttributeString("extension", language.Extension); writer.WriteEndElement(); // end - language } } writer.WriteEndElement(); // end - languages writer.WriteEndElement(); // end - codeSources } return(true); }
private void ReadXmlContents(XmlReader reader) { string startElement = reader.Name; Debug.Assert(String.Equals(startElement, "contents")); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (!reader.IsEmptyElement && String.Equals(reader.Name, "content", StringComparison.OrdinalIgnoreCase)) { switch (reader.GetAttribute("type").ToLower()) { case "scripts": if (_scripts == null) { _scripts = new ScriptContent(); } if (reader.ReadToDescendant(ScriptContent.TagName)) { _scripts.ReadXml(reader); } break; case "snippets": if (_snippets == null) { _snippets = new SnippetContent(); } if (reader.ReadToDescendant(SnippetContent.TagName)) { _snippets.ReadXml(reader); } break; case "stylesheets": if (_styleSheets == null) { _styleSheets = new StyleSheetContent(); } if (reader.ReadToDescendant(StyleSheetContent.TagName)) { _styleSheets.ReadXml(reader); } break; case "packages": if (_mathPackages == null) { _mathPackages = new MathPackageContent(); } if (reader.ReadToDescendant(MathPackageContent.TagName)) { _mathPackages.ReadXml(reader); } break; case "commands": if (_mathCommands == null) { _mathCommands = new MathCommandContent(); } if (reader.ReadToDescendant(MathCommandContent.TagName)) { _mathCommands.ReadXml(reader); } break; } } } else if (reader.NodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, startElement, StringComparison.OrdinalIgnoreCase)) { break; } } } }
public void Create() { bool useCustomStyles = true; BuildStyleType styleType = BuildStyleType.ClassicWhite; _settings.WorkingDirectory = new BuildDirectoryPath(_workingDir); _settings.CleanIntermediate = false; _settings.ShowPreliminary = true; _settings.Style.StyleType = styleType; //_settings.SyntaxType = BuildSyntaxType.None; _settings.HeaderText = "Header: This is the header text."; _settings.FooterText = "Footer: This is the footer text."; BuildFeedback feedBack = _settings.Feedback; feedBack.CompanyName = "Sandcastle Assist"; feedBack.ProductName = "Sandcastle Helpers"; feedBack.EmailAddress = "*****@*****.**"; feedBack.FeedbackType = BuildFeedbackType.None; feedBack.CopyrightText = "Copyright © 2007-2008 Sandcastle Assist. All Rights Reserved."; feedBack.CopyrightLink = "http://www.codeplex.com/SandAssist"; // Configure the logo image information... feedBack.LogoEnabled = true; // show it... feedBack.LogoImage = new BuildFilePath(Path.Combine(_sandAssistDir, "AssistLogo.jpg")); feedBack.LogoWidth = 64; feedBack.LogoHeight = 64; feedBack.LogoPadding = 3; feedBack.LogoText = "Sandcastle Assist"; feedBack.LogoLink = "http://www.codeplex.com/SandAssist"; feedBack.LogoAlignment = BuildLogoAlignment.Center; feedBack.LogoPlacement = BuildLogoPlacement.Right; // Configure the logging, we add some loggers by their names... BuildLogging logging = _settings.Logging; //logging.Verbosity = BuildLoggerVerbosity.Detailed; //logging.AddLogger(XmlLogger.LoggerName); //logging.AddLogger(HtmlLogger.LoggerName); ///logging.AddLogger(XamlLogger.LoggerName); logging.AddLogger(ConsoleLogger.LoggerName); BuildStyle style = _settings.Style; // Add direct code snippet root folder... SnippetContent snippets = style.Snippets; snippets.Add(new SnippetItem( Path.Combine(_sampleDir, "SampleSnippets"))); // Add some custom math packages and commands... MathPackageContent mathPackages = style.MathPackages; mathPackages.Add("picture", "calc"); mathPackages.Add("xy", "all", "knot", "poly"); MathCommandContent mathCommands = style.MathCommands; mathCommands.Add(@"\quot", @"\dfrac{\varphi \cdot X_{n, #1}}{\varphi_{#2} \times \varepsilon_{#1}}", 2); mathCommands.Add(@"\exn", @"(x+\varepsilon_{#1})^{#1}", 1); if (useCustomStyles) { string stylesDir = @"Presentations"; stylesDir = Path.GetFullPath(stylesDir); if (Directory.Exists(stylesDir)) { _settings.Style.Directory = new BuildDirectoryPath(stylesDir); } } FormatChm chmFormat = _settings.Formats[BuildFormatType.HtmlHelp1] as FormatChm; if (chmFormat != null) { chmFormat.Enabled = true; chmFormat.UseBinaryToc = false; chmFormat.Indent = true; } //FormatHxs hxsFormat = // _settings.Formats[BuildFormatType.HtmlHelp2] as FormatHxs; //if (hxsFormat != null) //{ // //hxsFormat.SeparateIndexFile = true; // hxsFormat.Enabled = true; // hxsFormat.Indent = true; //} //FormatMhv mhvFormat = // _settings.Formats[BuildFormatType.HtmlHelp3] as FormatMhv; //if (mhvFormat != null) //{ // mhvFormat.Enabled = true; // mhvFormat.Indent = true; //} //FormatWeb webFormat = // _settings.Formats[BuildFormatType.WebHelp] as FormatWeb; //if (webFormat != null) //{ // webFormat.Enabled = true; // webFormat.Indent = true; //} //_settings.HelpName = "HelpRegister"; //_settings.HelpTitle = "Sandcastle HelpRegister"; _settings.HelpName = "SandcastleHelpers"; _settings.HelpTitle = "Sandcastle Helpers Test Sample"; }