Skip to content

Commit

Permalink
Changed from PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mtirionMSFT committed Dec 16, 2024
1 parent 917922a commit 7eb4818
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/DocAssembler/DocAssembler/Actions/ConfigInitAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DocAssembler.Actions;
/// </summary>
public class ConfigInitAction
{
private const string CONFIGFILENAME = ".docassembler.json";
private const string ConfigFileName = ".docassembler.json";

private readonly string _outFolder;

Expand Down Expand Up @@ -48,7 +48,7 @@ public Task<ReturnCode> 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.");
Expand Down
10 changes: 5 additions & 5 deletions src/DocAssembler/DocAssembler/FileService/Hyperlink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace DocAssembler.FileService;
/// </summary>
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();

/// <summary>
/// Initializes a new instance of the <see cref="Hyperlink"/> class.
Expand Down Expand Up @@ -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);
Expand All @@ -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++)
Expand Down
11 changes: 1 addition & 10 deletions src/DocAssembler/DocAssembler/Utils/LogUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@ internal static class LogUtil
/// <exception cref="ArgumentOutOfRangeException">When an unknown log level is given.</exception>
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)
Expand Down
6 changes: 2 additions & 4 deletions src/DocAssembler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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`

Expand All @@ -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. |


0 comments on commit 7eb4818

Please sign in to comment.