public ContentFileInput AddContentFile(string fileName, string fileContent)
        {
            var contentFileInput = GetContentFileInput(fileName, fileContent);

            ContentFiles.Add(contentFileInput);
            return(contentFileInput);
        }
Exemple #2
0
        public ContentFileInput AddContentFile(string fileName, string fileContent)
        {
            var contentFileInput     = new ContentFileInput(fileName, fileContent);
            var existingContentFiles = ContentFiles.Where(cf => cf.FileName == fileName).ToList();

            if (existingContentFiles.Any())
            {
                existingContentFiles.ForEach(i => ContentFiles.Remove(i));
            }

            ContentFiles.Add(contentFileInput);
            return(contentFileInput);
        }
Exemple #3
0
        /// <summary>
        /// Reads the config file
        /// </summary>
        /// <returns>an empty string if no exception occurs</returns>
        public bool Read()
        {
            Log.Trace(@"ConfigFileHelper.Read() ...");

            try
            {
                if (!ConfigFileExists)
                {
                    return(false);
                }

                bool isConfigRead = true;

                ParityFile1 = string.Empty;
                ParityFile2 = string.Empty;
                ZParityFile = string.Empty;
                ParityFile3 = string.Empty;
                ParityFile4 = string.Empty;
                ParityFile5 = string.Empty;
                ParityFile6 = string.Empty;

                ConfigErrors.Clear();

                ConfigWarnings.Clear();

                ContentFiles.Clear();

                SnapShotSources.Clear();

                ExcludePatterns.Clear();

                IncludePatterns.Clear();

                BlockSizeKB = Constants.DefaultBlockSize;

                AutoSaveGB = Constants.DefaultAutoSave;

                foreach (string line in File.ReadLines(ConfigPath))
                {
                    string lineStart = line.Trim();

                    if (string.IsNullOrWhiteSpace(lineStart) || lineStart.StartsWith(@"#"))
                    {
                        continue;
                    }

                    // Not a comment so process the line

                    // split the line by the first space encountered
                    string[] configItem = lineStart.Split(new[] { ' ' }, 2);
                    Log.Trace(@"configItem [{0}]", string.Join(" ", configItem));
                    string configItemName = configItem[0] ?? string.Empty;
                    Log.Trace(@"configItemName [{0}]", configItemName);
                    string configItemValue = (configItem.Length > 1) ? configItem[1] : string.Empty;
                    Log.Trace(@"configItemValue [{0}]", configItemValue);

                    // ignore the line if it is not an a recognized setting
                    if (!validConfigNames.Contains(configItemName))
                    {
                        continue;
                    }
                    Log.Trace(@"configItemName found in validConfigNames");

                    switch (configItemName)
                    {
                    case @"parity":
                        ParityFile1 = configItemValue;
                        break;

                    case @"q-parity":
                        Log.Warn(@"'q-parity' entry in config file will be changed to '2-parity' when config is saved");
                        ParityFile2 = configItemValue;
                        break;

                    case @"2-parity":
                        // handle legacy 'q-parity' entry by giving it priority over any '2-parity' entry; saving config will rename 'q-parity' to '2-parity' and leave the path unchanged
                        if (string.IsNullOrEmpty(ParityFile2))
                        {
                            ParityFile2 = configItemValue;
                        }
                        break;

                    case @"z-parity":
                        // #WARNING! Your CPU doesn't have a fast implementation for triple parity.
                        // #WARNING! It's recommended to switch to 'z-parity' instead than '3-parity'.
                        ZParityFile = configItemValue;
                        ParityFile3 = string.Empty;
                        break;

                    case @"3-parity":
                        if (string.IsNullOrWhiteSpace(ZParityFile))
                        {
                            ParityFile3 = configItemValue;
                        }
                        break;

                    case @"4-parity":
                        ParityFile4 = configItemValue;
                        break;

                    case @"5-parity":
                        ParityFile5 = configItemValue;
                        break;

                    case @"6-parity":
                        ParityFile6 = configItemValue;
                        break;

                    case @"content":
                        ContentFiles.Add(configItemValue);
                        break;

                    case @"disk":
                    case @"data":     // Handle older configs
                    {
                        // get the data name, d1,d2,d3 etc
                        string diskName = configItemValue.Split(' ')[0];

                        // get the path
                        int diskSplitIndex = configItemValue.IndexOf(' ');

                        string diskPath = configItemValue.Substring(diskSplitIndex + 1);

                        // special handling of data sources since order preservation is extremely important
                        if (!string.IsNullOrEmpty(diskName) && !string.IsNullOrEmpty(diskPath))
                        {
                            SnapShotSources.Add(new SnapShotSource {
                                    Name = diskName, DirSource = diskPath
                                });
                        }
                    }
                    break;

                    case @"exclude":
                        ExcludePatterns.Add(configItemValue);
                        break;

                    case @"include":
                        IncludePatterns.Add(configItemValue);
                        break;

                    case @"block_size":
                        BlockSizeKB = uint.Parse(configItemValue);
                        if (BlockSizeKB < Constants.MinBlockSize || BlockSizeKB > Constants.MaxBlockSize)
                        {
                            isConfigRead = false;
                        }
                        break;

                    case @"autosave":
                        AutoSaveGB = uint.Parse(configItemValue);
                        // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                        if (AutoSaveGB < Constants.MinAutoSave || AutoSaveGB > Constants.MaxAutoSave)
                        {
                            isConfigRead = false;
                        }
                        break;

                    case @"nohidden":
                        Nohidden = true;
                        break;
                    }
                }

                return(isConfigRead);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// Reads the config file
        /// </summary>
        /// <returns>an empty string if no exception occurrs</returns>
        public string Read()
        {
            try
            {
                ParityFile  = string.Empty;
                QParityFile = string.Empty;
                ContentFiles.Clear();
                SnapShotSources.Clear();
                ExcludePatterns.Clear();
                IncludePatterns.Clear();
                BlockSizeKB = 256;
                AutoSaveGB  = 250;

                foreach (string line in File.ReadLines(ConfigPath))
                {
                    string lineStart = line.TrimStart();
                    if (!string.IsNullOrWhiteSpace(lineStart) &&
                        !lineStart.StartsWith("#")
                        )
                    {
                        // Not a comment, so off we go.
                        int    splitIndex = lineStart.IndexOf(' ');
                        string value      = lineStart.Substring(splitIndex + 1);
                        if (string.IsNullOrWhiteSpace(value))
                        {
                            continue;
                        }
                        switch (lineStart.Substring(0, splitIndex).ToLower())
                        {
                        case "parity":
                            ParityFile = value;
                            break;

                        case "q-parity":
                            QParityFile = value;
                            break;

                        case "content":
                            ContentFiles.Add(value);
                            break;

                        case "disk":
                        {
                            // Step over the disk name
                            int diskSplitIndex = value.IndexOf(' ');
                            SnapShotSources.Add(value.Substring(diskSplitIndex + 1));
                        }
                        break;

                        case "exclude":
                            ExcludePatterns.Add(value);
                            break;

                        case "include":
                            IncludePatterns.Add(value);
                            break;

                        case "block_size":
                            BlockSizeKB = uint.Parse(value);
                            break;

                        case "nohidden":
                            Nohidden = true;
                            break;

                        case "autosave":
                            AutoSaveGB = uint.Parse(value);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return(string.Empty);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public VulkanSandcastlePresentationStyle()
        {
            // The base path of the presentation style files relative to the assembly's location.  If your
            // assembly will reside in the same folder as the presentation style content, you can remove this
            // property setting.  If adding multiple presentation styles to the assembly, set this to the name
            // of the subfolder that contains the presentation style content folders.
            BasePath = "VulkanSandcastlePresentation";

            // TODO: Adjust the rest of these properties as needed.

            SupportedFormats = HelpFileFormats.Website;


            SupportsNamespaceGrouping = SupportsCodeSnippetGrouping = true;

            // If relative, these paths are relative to the base path
            ResourceItemsPath = "Content";

            ToolResourceItemsPath = "SHFBContent";


            DocumentModelTransformation = new TransformationFile(
                @"%SHFBROOT%\ProductionTransforms\ApplyVSDocModel.xsl", new Dictionary <string, string> {
                { "IncludeAllMembersTopic", "false" },
                { "project", "{@ProjectNodeIDOptional}" }
            });


            IntermediateTocTransformation = new TransformationFile(
                @"%SHFBROOT%\ProductionTransforms\CreateVSToc.xsl");


            BuildAssemblerConfiguration = @"Configuration\BuildAssembler.config";

            // Note that UNIX based web servers may be case-sensitive with regard to folder and filenames so
            // match the case of the folder and filenames in the literals to their actual casing on the file
            // system.

            ContentFiles.Add(new ContentFiles(SupportedFormats, @"icons\*.*"));

            ContentFiles.Add(new ContentFiles(SupportedFormats, @"scripts\*.*"));

            ContentFiles.Add(new ContentFiles(SupportedFormats, @"styles\*.*"));

            // By default, this will use the standard web file content from the Sandcastle Help File Builder
            ContentFiles.Add(new ContentFiles(HelpFileFormats.Website, null, @"Web\*.*",
                                              string.Empty, new[] { ".aspx", ".html", ".htm", ".php" }));


            TransformComponentArguments.Add(new TransformComponentArgument("logoFile", true, true, null,
                                                                           "An optional logo file to insert into the topic headers.  Specify the filename only, omit " +
                                                                           "the path.  Place the file in your project in an icons\\ folder and set the Build Action to " +
                                                                           "Content.  If blank, no logo will appear in the topic headers.  If building website output " +
                                                                           "and your web server is case-sensitive, be sure to match the case of the folder name in your " +
                                                                           "project with that of the presentation style.  The same applies to the logo filename itself."));


            TransformComponentArguments.Add(new TransformComponentArgument("logoFileSvg", true, true, null,
                                                                           "An optional logo svg file to replace the logo file image.  Specify the filename only, omit " +
                                                                           "the path.  Place the file in your project in an icons\\ folder and set the Build Action to " +
                                                                           "Content.  If blank, only the non-svg logo will appear in the topic headers.  If building website output " +
                                                                           "and your web server is case-sensitive, be sure to match the case of the folder name in your " +
                                                                           "project with that of the presentation style.  The same applies to the logo filename itself."));

            TransformComponentArguments.Add(new TransformComponentArgument("logoHeight", true, true, null,
                                                                           "An optional logo height.  If left blank, the actual logo image height is used."));

            TransformComponentArguments.Add(new TransformComponentArgument("logoWidth", true, true, null,
                                                                           "An optional logo width.  If left blank, the actual logo image width is used."));

            TransformComponentArguments.Add(new TransformComponentArgument("logoAltText", true, true, null,
                                                                           "Optional logo alternate text.  If left blank, no alternate text is added."));

            TransformComponentArguments.Add(new TransformComponentArgument("logoPlacement", true, true,
                                                                           "left", "An optional logo placement.  Specify left, right, or above.  If not specified, the " +
                                                                           "default is left."));

            TransformComponentArguments.Add(new TransformComponentArgument("logoAlignment", true, true,
                                                                           "left", "An optional logo alignment when using the 'above' placement option.  Specify left, " +
                                                                           "right, or center.  If not specified, the default is left."));

            TransformComponentArguments.Add(new TransformComponentArgument("maxVersionParts", false, true,
                                                                           null, "The maximum number of assembly version parts to show in API member topics.  Set to 2, " +
                                                                           "3, or 4 to limit it to 2, 3, or 4 parts or leave it blank for all parts including the " +
                                                                           "assembly file version value if specified."));

            TransformComponentArguments.Add(new TransformComponentArgument("defaultLanguage", true, true,
                                                                           "cs", "The default language to use for syntax sections, code snippets, and a language-specific " +
                                                                           "text.  This should be set to cs, vb, cpp, fs, or the keyword style parameter value of a " +
                                                                           "third-party syntax generator if you want to use a non-standard language as the default."));

            TransformComponentArguments.Add(new TransformComponentArgument("includeEnumValues", false, true,
                                                                           "true", "Set this to 'true' to include the column for the numeric value of each field in " +
                                                                           "enumerated type topics.  Set it to 'false' to omit the numeric values column."));

            TransformComponentArguments.Add(new TransformComponentArgument("baseSourceCodeUrl", false, true,
                                                                           null, "If you set the Source Code Base Path property in the Paths category, specify the URL to " +
                                                                           "the base source code folder on your project's website here.  Some examples for GitHub are " +
                                                                           "shown below.\r\n\r\n" +
                                                                           "Important: Be sure to set the Source Code Base Path property and terminate the URL below with " +
                                                                           "a slash if necessary.\r\n\r\n" +
                                                                           "Format: https://github.com/YourUserID/YourProject/blob/BranchNameOrCommitHash/BaseSourcePath/ \r\n\r\n" +
                                                                           "Master branch: https://github.com/JohnDoe/WidgestProject/blob/master/src/ \r\n" +
                                                                           "A different branch: https://github.com/JohnDoe/WidgestProject/blob/dev-branch/src/ \r\n" +
                                                                           "A specific commit: https://github.com/JohnDoe/WidgestProject/blob/c6e41c4fc2a4a335352d2ae8e7e85a1859751662/src/"));

            TransformComponentArguments.Add(new TransformComponentArgument("requestExampleUrl", false, true,
                                                                           null, "To include a link that allows users to request an example for an API topic, set the URL " +
                                                                           "to which the request will be sent.  This can be a web page URL or an e-mail URL.  Only include " +
                                                                           "the URL as the parameters will be added automatically by the topic.  For example:\r\n\r\n" +
                                                                           "Create a new issue on GitHub: https://github.com/YourUserID/YourProject/issues/new \r\n" +
                                                                           "Send via e-mail: mailto:[email protected]"));

            // Add plug-in dependencies
            PlugInDependencies.Add(new PlugInDependency("Lightweight Website Style", null));
        }
Exemple #6
0
        /// <summary>
        /// Reads the config file
        /// </summary>
        /// <returns>an empty string if no exception occurrs</returns>
        public bool Read()
        {
            try
            {
                if (!ConfigFileExists)
                {
                    return(false);
                }

                ParityFile1 = string.Empty;
                ParityFile2 = string.Empty;
                ParityFile3 = string.Empty;
                ParityFile4 = string.Empty;
                ParityFile5 = string.Empty;
                ParityFile6 = string.Empty;
                ContentFiles.Clear();
                SnapShotSources.Clear();
                ExcludePatterns.Clear();
                IncludePatterns.Clear();
                BlockSizeKB = 256;
                AutoSaveGB  = 250;

                foreach (string line in File.ReadLines(ConfigPath))
                {
                    string lineStart = line.Trim();
                    if (string.IsNullOrWhiteSpace(lineStart) || lineStart.StartsWith("#"))
                    {
                        continue;
                    }

                    // Not a comment so process the line

                    // split the line by the first space encountered
                    string[] configItem      = lineStart.Split(new[] { ' ' }, 2);
                    string   configItemName  = configItem[0] ?? string.Empty;
                    string   configItemValue = (configItem.Length > 1) ? configItem[1] : string.Empty;

                    // ignore the line if it is not an a recognized setting
                    if (!_validConfigNames.Contains(configItemName))
                    {
                        continue;
                    }

                    switch (configItemName)
                    {
                    case "parity":
                        ParityFile1 = configItemValue;
                        break;

                    case "q-parity":
                        Log.Instance.Warn("'q-parity' entry in config file should be changed to '2-parity'");
                        ParityFile2 = configItemValue;
                        break;

                    case "2-parity":
                        // handle legacy 'q-parity' entry by giving it priority over any '2-parity' entry; saving config will rename 'q-parity' to '2-parity' and leave the path unchanged
                        if (string.IsNullOrEmpty(ParityFile2))
                        {
                            ParityFile2 = configItemValue;
                        }
                        break;

                    case "3-parity":
                        ParityFile3 = configItemValue;
                        break;

                    case "4-parity":
                        ParityFile4 = configItemValue;
                        break;

                    case "5-parity":
                        ParityFile5 = configItemValue;
                        break;

                    case "6-parity":
                        ParityFile6 = configItemValue;
                        break;

                    case "content":
                        ContentFiles.Add(configItemValue);
                        break;

                    case "disk":
                        // Step over the disk name
                        int diskSplitIndex = configItemValue.IndexOf(' ');
                        SnapShotSources.Add(configItemValue.Substring(diskSplitIndex + 1));
                        break;

                    case "exclude":
                        ExcludePatterns.Add(configItemValue);
                        break;

                    case "include":
                        IncludePatterns.Add(configItemValue);
                        break;

                    case "block_size":
                        BlockSizeKB = uint.Parse(configItemValue);
                        break;

                    case "nohidden":
                        Nohidden = true;
                        break;

                    case "autosave":
                        AutoSaveGB = uint.Parse(configItemValue);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex);
                return(false);
            }
            return(true);
        }