예제 #1
0
 /// <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;
 }
예제 #2
0
        /// <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);
        }
예제 #3
0
        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;
                    }
                }
            }
        }
예제 #4
0
        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 &#169; 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";
        }
        /// <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);
            }

            //<component type="Sandcastle.Components.ConceptualMathComponent" assembly="$(SandAssistComponent)">
            //    <paths inputPath=".\maths\" baseOutput=".\Output" outputPath="maths"/>
            //    <!--
            //    Specifying the equation image file naming method
            //     @method (enumeration): default - Sequential
            //          - Sequential, using Math0001, Math0002 etc, using the prefix.
            //          - Guid, using dynamically generated guid values.
            //          - Random, using the random file name generation provided by the framework.
            //     @prefix - only used for the Sequential type.
            //    -->
            //    <naming method="Sequential" prefix="math" />
            //    <!--
            //    This specifies the equation numbering...only the displayed equations
            //      @show (Boolean): default - true
            //           Whether to display equation numbers or not
            //      @byPage (Boolean): default - true
            //           Whether to display equations numbers by page.
            //           - If true, each topic page starts with equation numbering 1, 2, ...
            //           - If false, the sequential numbering from a page continues on the next page.
            //       @format (String): default - ({0})
            //          Specifies the format of the equation number.
            //       @formatIncludesPage (Boolean): default - false
            //          Indicates whether the "format" includes the page number of the topic.
            //       Note: Topic pages are not numbered, but this component numbers them as
            //             they are being processed.
            //    -->
            //    <numbering show="true" byPage="false" format="Eqn. ({0}.{1})" formatIncludesPage="true" />
            //    <!--
            //    We keep this separate, just in case we offer a MathML render with
            //    different metrics.
            //      formatter:
            //          @format: Only "LaTeX" is currently supported.
            //          @type: MimeTeX or MikTeX
            //          @baseSize: 10, 11 or 12 for LaTeX font sizes. This is used for
            //          both inline and displayed (optional).
            //      style:
            //          @type: inline or displayed.
            //          @baseSize: 10, 11 or 12 for LaTeX font sizes.
            //          @zoomLevel: 0 (\tiny) to 8 (\Huge). 2 is \normalsize, 3 is \large.
            //    -->
            //    <formatter format="LaTeX" type="MikTeX" baseSize="10">
            //        <style type="inline" baseSize="10" zoomLevel="2" />
            //        <style type="displayed" baseSize="10" zoomLevel="3" />
            //    </formatter>
            //    <!-- NOTE: Only for MikTeX
            //    Specify the LaTeX packages your equations will require.
            //    Note: The default setting uses the following:
            //      \usepackage{amsmath, amsfonts, amssymb, latexsym}
            //      \usepackage[mathscr]{eucal}
            //    Any packages specified here only adds to this default.
            //    Examples:
            //    <packages>
            //        <package use="amstext" />
            //        <package use="amsbsy, amscd" />
            //        <package use="noamsfonts" options="psamsfonts" />
            //    </packages>
            //    -->
            //    <packages>
            //        <package use="picture" options="calc" />
            //        <package use="xy" options="all,knot,poly" />
            //    </packages>
            //    <!-- NOTE: Currently Only MikTeX. MimeTeX supports user commands at
            //               compile time only and I am working on that...
            //    Define any new or user commands to be used in your equations.
            //    This is added as \newcommand in the formatting of the equations.
            //    Note: There is no default new or user commands.
            //    Examples:
            //    1. For \newcommand{\la}{\leftarrow}...
            //        <command name="\\la" value="\\leftarrow" />
            //    2. For command with arguments \newcommand{\env}[1]{\emph{#1}}
            //          <command name="\env" value="\emph{#1}" arguments="1" />
            //        for \newcommand{\con}[3]{#1\equiv#2\pod{\#3}}
            //          <command name="\con" value="#1\equiv#2\pod{\#3}" arguments="3" />
            //        and for optional arguments \newcommand{\NNSum}[2][n]{#2_{1}+#2_{3}+\cdots+#2_{#1}}
            //          <command name="\NNSum" value="#2_{1}+#2_{3}+\cdots+#2_{#1}" arguments="2 n" />
            //    -->
            //    <commands>
            //        <!-- For testing an example
            //        <command name="" value="" />-->
            //        <command name="\quot" value="\dfrac{\varphi \cdot X_{n, #1}}{\varphi_{#2} \times \varepsilon_{#1}}" arguments="2" />
            //        <command name="\exn" value="(x+\varepsilon_{#1})^{#1}" arguments="1" />
            //    </commands>
            //</component>

            writer.WriteStartElement("paths");  // start: paths
            writer.WriteAttributeString("inputPath", _inputPath);
            writer.WriteAttributeString("baseOutput", _baseOutput);
            writer.WriteAttributeString("outputPath", _outputPath);
            writer.WriteEndElement();           // end: paths

            writer.WriteStartElement("naming"); // start: naming
            writer.WriteAttributeString("method", _namingMethod.ToString());
            writer.WriteAttributeString("prefix", _namingPrefix);
            writer.WriteEndElement();              // end: naming

            writer.WriteStartElement("numbering"); // start: numbering
            writer.WriteAttributeString("show", _numEnabled.ToString());
            writer.WriteAttributeString("byPage", _numByPage.ToString());
            writer.WriteAttributeString("format", _numFormat);
            writer.WriteAttributeString("formatIncludesPage", _numFormatIncludesPage.ToString());
            writer.WriteEndElement();               // end: numbering

            writer.WriteStartElement("formatter");  // start: formatter
            writer.WriteAttributeString("format", "LaTeX");
            writer.WriteAttributeString("type", "MikTeX");
            writer.WriteAttributeString("baseSize", "10");

            writer.WriteStartElement("style");  // start: style
            writer.WriteAttributeString("type", "inline");
            writer.WriteAttributeString("baseSize", _inlineSize.ToString());
            writer.WriteAttributeString("zoomLevel", _inlineZoom.ToString());
            writer.WriteEndElement();           // end: style

            writer.WriteStartElement("style");  // start: style
            writer.WriteAttributeString("type", "displayed");
            writer.WriteAttributeString("baseSize", _displayedSize.ToString());
            writer.WriteAttributeString("zoomLevel", _displayedZoom.ToString());
            writer.WriteEndElement();           // end: style

            writer.WriteEndElement();           // end: formatter

            MathPackageContent packages = _style.MathPackages;

            if (packages != null && packages.Count != 0)
            {
                StringBuilder builder = new StringBuilder();

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

                for (int i = 0; i < packages.Count; i++)
                {
                    MathPackageItem package = packages[i];
                    if (package != null && !packages.IsEmpty &&
                        package.FormatOptions(builder))
                    {
                        writer.WriteStartElement("package");  // start: package
                        writer.WriteAttributeString("use", package.Use);
                        writer.WriteAttributeString("options", builder.ToString());
                        writer.WriteEndElement();             // end: package

                        builder.Length = 0;
                    }
                }

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

            MathCommandContent commands = _style.MathCommands;

            if (commands != null && commands.Count != 0)
            {
                writer.WriteStartElement("commands");   // start: commands

                for (int i = 0; i < commands.Count; i++)
                {
                    MathCommandItem command = commands[i];
                    if (command != null && !command.IsEmpty)
                    {
                        writer.WriteStartElement("command");  // start: command
                        writer.WriteAttributeString("name", command.Name);
                        writer.WriteAttributeString("value", command.Value);
                        int arguments = command.Arguments;
                        if (arguments >= 1 && arguments <= 9)
                        {
                            writer.WriteAttributeString("arguments",
                                                        arguments.ToString());
                        }
                        writer.WriteEndElement();             // end: command
                    }
                }

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

            return(true);
        }