diff --git a/src/DocAssembler/DocAssembler/Actions/ConfigInitAction.cs b/src/DocAssembler/DocAssembler/Actions/ConfigInitAction.cs index 12aac2f..c75cfab 100644 --- a/src/DocAssembler/DocAssembler/Actions/ConfigInitAction.cs +++ b/src/DocAssembler/DocAssembler/Actions/ConfigInitAction.cs @@ -14,7 +14,7 @@ namespace DocAssembler.Actions; /// public class ConfigInitAction { - private const string CONFIGFILENAME = ".docassembler.json"; + private const string ConfigFileName = ".docassembler.json"; private readonly string _outFolder; @@ -48,7 +48,7 @@ public Task RunAsync() try { - string path = Path.Combine(_outFolder, CONFIGFILENAME); + string path = Path.Combine(_outFolder, ConfigFileName); if (_fileService!.ExistsFileOrDirectory(path)) { _logger.LogError($"*** ERROR: '{path}' already exists. We don't overwrite."); diff --git a/src/DocAssembler/DocAssembler/FileService/Hyperlink.cs b/src/DocAssembler/DocAssembler/FileService/Hyperlink.cs index e919597..ac43374 100644 --- a/src/DocAssembler/DocAssembler/FileService/Hyperlink.cs +++ b/src/DocAssembler/DocAssembler/FileService/Hyperlink.cs @@ -11,9 +11,9 @@ namespace DocAssembler.FileService; /// public class Hyperlink { - private static readonly char[] UriFragmentOrQueryString = new char[] { '#', '?' }; - private static readonly char[] AdditionalInvalidChars = @"\/?:*".ToArray(); - private static readonly char[] InvalidPathChars = Path.GetInvalidPathChars().Concat(AdditionalInvalidChars).ToArray(); + private static readonly char[] _uriFragmentOrQueryString = new char[] { '#', '?' }; + private static readonly char[] _additionalInvalidChars = @"\/?:*".ToArray(); + private static readonly char[] _invalidPathChars = Path.GetInvalidPathChars().Concat(_additionalInvalidChars).ToArray(); /// /// Initializes a new instance of the class. @@ -230,7 +230,7 @@ private string UrlDecode(string url) } var anchor = string.Empty; - var index = url.IndexOfAny(UriFragmentOrQueryString); + var index = url.IndexOfAny(_uriFragmentOrQueryString); if (index != -1) { anchor = url.Substring(index); @@ -249,7 +249,7 @@ private string UrlDecode(string url) var origin = parts[i]; var value = Uri.UnescapeDataString(origin); - var splittedOnInvalidChars = value.Split(InvalidPathChars); + var splittedOnInvalidChars = value.Split(_invalidPathChars); var originIndex = 0; var valueIndex = 0; for (int j = 0; j < splittedOnInvalidChars.Length; j++) diff --git a/src/DocAssembler/DocAssembler/Utils/LogUtil.cs b/src/DocAssembler/DocAssembler/Utils/LogUtil.cs index a39cf74..20ac599 100644 --- a/src/DocAssembler/DocAssembler/Utils/LogUtil.cs +++ b/src/DocAssembler/DocAssembler/Utils/LogUtil.cs @@ -24,16 +24,7 @@ internal static class LogUtil /// When an unknown log level is given. public static ILoggerFactory GetLoggerFactory(LogLevel logLevel1) { - var serilogLevel = logLevel1 switch - { - LogLevel.Critical => LogEventLevel.Fatal, - LogLevel.Error => LogEventLevel.Error, - LogLevel.Warning => LogEventLevel.Warning, - LogLevel.Information => LogEventLevel.Information, - LogLevel.Debug => LogEventLevel.Debug, - LogLevel.Trace => LogEventLevel.Verbose, - _ => throw new ArgumentOutOfRangeException(nameof(logLevel1)), - }; + var serilogLevel = (LogEventLevel)logLevel1; var serilog = new LoggerConfiguration() .MinimumLevel.Is(serilogLevel) diff --git a/src/DocAssembler/README.md b/src/DocAssembler/README.md index aa6cb8f..93d1712 100644 --- a/src/DocAssembler/README.md +++ b/src/DocAssembler/README.md @@ -127,7 +127,7 @@ As we don't want to find a link like `[AB#1234](https://...)`, we look for all A > [!NOTE] > -> As the expression is configured in a string in a JSON file, special characters like back-slashes need to be escaped by an (extra) back-slash. +> As the expression is configured in a string in a JSON file, special characters like back-slashes need to be escaped by an (extra) back-slash like you see in the example above, where `\s` is escaped with an extra `\`. The second part is to get the numbers after the AB# text. This is configured here to be between 3 and 6 characters. We also want to reuse this ID in the value, so we capture it as a named subexpression called `id`. @@ -137,7 +137,7 @@ In the value we can reuse these named subexpression like this: ${pre}[AB#${id}](https://dev.azure.com/[your organization]/_workitems/edit/${id}) ``` -We start with the `pre` value, after which we build a markdown link with AB# combined with the `id` as the text and the `id` as parameter for the URL. We reference an Azure Board work item here. Of course you need to replace the `[your organization]` with the proper value for your ADO environment here. +We start with the `pre` value, after which we build a markdown link with AB# combined with the `id` as the text and the `id` as parameter for the URL. We reference an Azure Board work item here. Of course you need to replace the `[your organization]` with the proper value for your ADO environment here. With the examples above the text *AB#1234* would be translated to *[AB#1234(https://dev.azure.com/[your organization]/_workitems/edit/1234)*. ### `Content` @@ -153,5 +153,3 @@ The content is defined with these properties: | `urlReplacements` | A collection of [`Replacement`](#replacement) objects to use for URL paths in this content set, overruling any global setting. These replacements are applied to calculated destination paths for files in the content sets. This can be used to modify the path. The generated template removes /docs/ from paths and replaces it by a /. More information can be found under [`Replacement`](#replacement). | | `contentReplacements` | A collection of [`Replacement`](#replacement) objects to use for content of files in this content set, overruling any global setting. These replacements are applied to all content of markdown files in the content sets. This can be used to modify for instance URLs or other content items. More information can be found under [`Replacement`](#replacement). | | `externalFilePrefix` | The prefix to use for all referenced files in this content sets that are not part of the complete documentation set, like source files. It overrides any global prefix. This prefix is used in combination with the sub-path from the working folder. | - -