├── .markdownlint.json
├── DocExamples
├── userdocs
│ ├── de
│ │ ├── .override
│ │ ├── plant-production
│ │ │ ├── second-file.md
│ │ │ └── example.md
│ │ └── index.md
│ ├── .attachments
│ │ ├── de.png
│ │ └── en.jpg
│ ├── en
│ │ ├── plant-production
│ │ │ ├── second-file.md
│ │ │ └── example.md
│ │ └── index.md
│ ├── toc.yml
│ └── index.md
├── docs
│ ├── .order
│ ├── .attachments
│ │ ├── markdown-icons.png
│ │ └── VSCodeMdPreview.gif
│ ├── tools
│ │ ├── doc-link-checker.md
│ │ └── toc-generator.md
│ ├── ui-specific-elements.md
│ ├── markdownlint.md
│ └── enduser-documentation.md
├── .override
├── toc.yml
├── ui-specific
│ └── web.config
├── docfx.json
└── index.md
├── src
├── Directory.Build.props
├── DocLinkChecker
│ ├── DocLinkChecker.Test
│ │ ├── Usings.cs
│ │ ├── Directory.Build.props
│ │ └── DocLinkChecker.Test.csproj
│ ├── DocLinkChecker
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── GlobalSuppressions.cs
│ │ ├── Enums
│ │ │ ├── MarkdownErrorSeverity.cs
│ │ │ ├── RelativeLinkType.cs
│ │ │ ├── ReturnValue.cs
│ │ │ └── HyperlinkType.cs
│ │ ├── Models
│ │ │ ├── PipeTable.cs
│ │ │ ├── FileMappingItem.cs
│ │ │ ├── Heading.cs
│ │ │ ├── MarkdownObjectBase.cs
│ │ │ ├── AppConfig.cs
│ │ │ ├── CommandLineOptions.cs
│ │ │ ├── MarkdownError.cs
│ │ │ └── DocLinkCheckerSettings.cs
│ │ ├── Constants
│ │ │ └── AppConstants.cs
│ │ ├── Helpers
│ │ │ ├── TextExtensions.cs
│ │ │ └── StringExtensions.cs
│ │ ├── Interfaces
│ │ │ ├── ICustomConsoleLogger.cs
│ │ │ └── IFileService.cs
│ │ ├── Services
│ │ │ ├── FileService.cs
│ │ │ └── CustomConsoleLogger.cs
│ │ └── DocLinkChecker.csproj
│ └── DocLinkChecker.sln
├── DocAssembler
│ ├── DocAssembler.Test
│ │ ├── Directory.Build.props
│ │ ├── DocAssembler.Test.csproj
│ │ ├── FileInfoServiceTests.cs
│ │ ├── ConfigInitActionTests.cs
│ │ ├── FileServiceTests.cs
│ │ └── Helpers
│ │ │ └── MockLogger.cs
│ ├── DocAssembler
│ │ ├── ReturnCode.cs
│ │ ├── stylecop.json
│ │ ├── Configuration
│ │ │ ├── Replacement.cs
│ │ │ ├── AssembleConfiguration.cs
│ │ │ └── Content.cs
│ │ ├── FileService
│ │ │ ├── HyperlinkType.cs
│ │ │ ├── FileData.cs
│ │ │ ├── FilePathExtensions.cs
│ │ │ ├── FileService.cs
│ │ │ └── IFileService.cs
│ │ ├── Utils
│ │ │ ├── SerializationUtil.cs
│ │ │ └── LogUtil.cs
│ │ ├── GlobalSuppressions.cs
│ │ ├── Actions
│ │ │ ├── ActionException.cs
│ │ │ └── ConfigInitAction.cs
│ │ └── DocAssembler.csproj
│ └── DocAssembler.sln
├── DocFxTocGenerator
│ ├── DocFxTocGenerator.Test
│ │ ├── Directory.Build.props
│ │ ├── .editorconfig
│ │ ├── DocFxTocGenerator.Test.csproj
│ │ └── Helpers
│ │ │ ├── MockLogger.cs
│ │ │ └── MarkdownExtensions.cs
│ ├── DocFxTocGenerator
│ │ ├── ReturnCode.cs
│ │ ├── stylecop.json
│ │ ├── TableOfContents
│ │ │ ├── TocOrderStrategy.cs
│ │ │ ├── TocFolderReferenceStrategy.cs
│ │ │ └── TocItem.cs
│ │ ├── FileService
│ │ │ ├── FilePathExtensions.cs
│ │ │ ├── FileData.cs
│ │ │ ├── FolderFileBase.cs
│ │ │ ├── FileService.cs
│ │ │ ├── IFileService.cs
│ │ │ └── FolderData.cs
│ │ ├── GlobalSuppressions.cs
│ │ ├── Actions
│ │ │ ├── ActionException.cs
│ │ │ └── GenerateTocAction.cs
│ │ ├── Liquid
│ │ │ ├── LiquidException.cs
│ │ │ └── LiquidService.cs
│ │ ├── Index
│ │ │ ├── IndexGenerationStrategy.cs
│ │ │ └── IndexService.cs
│ │ ├── Utils
│ │ │ └── LogUtil.cs
│ │ └── DocFxTocGenerator.csproj
│ └── DocFxTocGenerator.sln
├── DocLanguageTranslator
│ ├── DocLanguageTranslator.Test
│ │ ├── Directory.Build.props
│ │ ├── DocLanguageTranslator.Test.csproj
│ │ ├── Usings.cs
│ │ └── Helpers
│ │ │ ├── MockMessageHelper.cs
│ │ │ └── MockFileService.cs
│ ├── DocLanguageTranslator
│ │ ├── Domain
│ │ │ ├── ErrorResponse.cs
│ │ │ ├── TranslationResults.cs
│ │ │ ├── ErrorDetail.cs
│ │ │ ├── Translation.cs
│ │ │ ├── TranslationException.cs
│ │ │ └── CommandlineOptions.cs
│ │ ├── TranslationService
│ │ │ └── ITranslationService.cs
│ │ ├── Helpers
│ │ │ ├── IMessageHelper.cs
│ │ │ └── MessageHelper.cs
│ │ ├── FileService
│ │ │ ├── FileService.cs
│ │ │ └── IFileService.cs
│ │ ├── DocLanguageTranslator.csproj
│ │ ├── ReplacementRenderer.cs
│ │ └── MarkdownTransformRenderer.cs
│ └── DocLanguageTranslator.sln
├── DocFxOpenApi
│ ├── NuGet.Config
│ ├── GlobalSuppressions.cs
│ ├── DocFxOpenApi.csproj
│ ├── DocFxOpenApi.sln
│ ├── Helpers
│ │ └── MessageHelper.cs
│ ├── README.md
│ └── Domain
│ │ └── CommandlineOptions.cs
├── build
│ └── dotnet
│ │ ├── common.props
│ │ ├── tests.common.props
│ │ └── CodeAnalysis.ruleset
└── DocFxCompanionTools.sln
├── tools
└── config.ps1
├── deploy
└── chocolatey
│ ├── tools
│ └── chocolateyinstall.ps1
│ └── docfx-companion-tools.nuspec
├── Dockerfile
├── changelog-config.json
├── .github
└── workflows
│ ├── build.yml
│ └── release-and-publish.yml
├── LICENSE
├── PipelineExamples
├── documentation-validation.yml
└── documentation-build.yml
├── THIRD-PARTY-NOTICES.TXT
├── GitVersion.yml
└── pack.ps1
/.markdownlint.json:
--------------------------------------------------------------------------------
1 | {
2 | "MD013": false
3 | }
--------------------------------------------------------------------------------
/DocExamples/userdocs/de/.override:
--------------------------------------------------------------------------------
1 | plant-production;Anlagenproduktion
2 |
--------------------------------------------------------------------------------
/DocExamples/docs/.order:
--------------------------------------------------------------------------------
1 | markdown-creation
2 | markdownlint
3 | enduser-documentation
--------------------------------------------------------------------------------
/DocExamples/.override:
--------------------------------------------------------------------------------
1 | docs;Developer documentation
2 | userdocs;End user documentation
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker.Test/Usings.cs:
--------------------------------------------------------------------------------
1 | global using Xunit;
2 | global using Bogus;
3 | global using DocLinkChecker.Helpers;
4 |
--------------------------------------------------------------------------------
/DocExamples/userdocs/.attachments/de.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ellerbach/docfx-companion-tools/HEAD/DocExamples/userdocs/.attachments/de.png
--------------------------------------------------------------------------------
/DocExamples/userdocs/.attachments/en.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ellerbach/docfx-companion-tools/HEAD/DocExamples/userdocs/.attachments/en.jpg
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler.Test/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DocExamples/userdocs/en/plant-production/second-file.md:
--------------------------------------------------------------------------------
1 | # This is a second file to see the navigation
2 |
3 | You can add anything in this file. Enjoy!
4 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker.Test/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DocExamples/docs/.attachments/markdown-icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ellerbach/docfx-companion-tools/HEAD/DocExamples/docs/.attachments/markdown-icons.png
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator.Test/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DocExamples/docs/.attachments/VSCodeMdPreview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ellerbach/docfx-companion-tools/HEAD/DocExamples/docs/.attachments/VSCodeMdPreview.gif
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator.Test/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DocExamples/userdocs/toc.yml:
--------------------------------------------------------------------------------
1 | items:
2 | - name: Home
3 | href: ../index.html
4 | - name: English
5 | href: en/index.html
6 | - name: Deutsch
7 | href: de/index.html
--------------------------------------------------------------------------------
/DocExamples/userdocs/de/plant-production/second-file.md:
--------------------------------------------------------------------------------
1 | # Dies ist eine zweite Datei, um die Navigation zu sehen
2 |
3 | Sie können alles in dieser Datei hinzufügen. Viel Spaß damit!
4 |
--------------------------------------------------------------------------------
/DocExamples/userdocs/en/index.md:
--------------------------------------------------------------------------------
1 | # Welcome to Digital Manufacturing Platform documentation
2 |
3 | This is the main page of the user documentation in English. You can switch to German [here](../de/index.md).
4 |
--------------------------------------------------------------------------------
/DocExamples/toc.yml:
--------------------------------------------------------------------------------
1 | items:
2 | - name: Home
3 | href: index.html
4 | - name: .NET Reference
5 | - name: Developers
6 | href: docs/README.html
7 | - name: User documentation
8 | href: userdocs/index.html
--------------------------------------------------------------------------------
/DocExamples/userdocs/en/plant-production/example.md:
--------------------------------------------------------------------------------
1 | # This is an example of file
2 |
3 | You have content here in English. You can add pictures:
4 |
5 | 
6 |
7 | And more text.
8 |
--------------------------------------------------------------------------------
/DocExamples/userdocs/de/index.md:
--------------------------------------------------------------------------------
1 | # Willkommen in der Dokumentation der Digital Manufacturing Platform
2 |
3 | Dies ist die Hauptseite der Benutzerdokumentation in deutscher Sprache. Sie können zu Englisch [hier](../en/index.md).
4 |
--------------------------------------------------------------------------------
/DocExamples/userdocs/index.md:
--------------------------------------------------------------------------------
1 | # Digital Manufacturing Platform
2 |
3 | [ Documentation in English](./en/index.md)
4 |
5 | [ Dokumentation in deutscher Sprache](./de/index.md)
6 |
--------------------------------------------------------------------------------
/DocExamples/userdocs/de/plant-production/example.md:
--------------------------------------------------------------------------------
1 | # Dies ist ein Beispiel für Datei
2 |
3 | Hier sehen Sie Inhalte in deutscher Sprache und können auch Bilder hinzufügen:
4 |
5 | 
6 |
7 | Und mehr Text.
8 |
--------------------------------------------------------------------------------
/src/DocFxOpenApi/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "DocLinkChecker": {
4 | "commandName": "Project"
5 | },
6 | "WSL": {
7 | "commandName": "WSL2",
8 | "distributionName": ""
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/ReturnCode.cs:
--------------------------------------------------------------------------------
1 | namespace DocAssembler;
2 |
3 | ///
4 | /// Return code for the application.
5 | ///
6 | public enum ReturnCode
7 | {
8 | ///
9 | /// All went well.
10 | ///
11 | Normal = 0,
12 |
13 | ///
14 | /// A few warnings, but process completed.
15 | ///
16 | Warning = 1,
17 |
18 | ///
19 | /// An error occurred, process not completed.
20 | ///
21 | Error = 2,
22 | }
23 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 |
6 | using System.Diagnostics.CodeAnalysis;
7 |
8 | [assembly: SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "Literals are allowed in a tool. No need for localization.")]
9 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator.Test/DocLanguageTranslator.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/ReturnCode.cs:
--------------------------------------------------------------------------------
1 | namespace DocFxTocGenerator;
2 |
3 | ///
4 | /// Return code for the application.
5 | ///
6 | public enum ReturnCode
7 | {
8 | ///
9 | /// All went well.
10 | ///
11 | Normal = 0,
12 |
13 | ///
14 | /// A few warnings, but process completed.
15 | ///
16 | Warning = 1,
17 |
18 | ///
19 | /// An error occurred, process not completed.
20 | ///
21 | Error = 2,
22 | }
23 |
--------------------------------------------------------------------------------
/tools/config.ps1:
--------------------------------------------------------------------------------
1 | # General configuration settings for running
2 | # the build and package scripts
3 | $homeDir = (Resolve-Path "$PSScriptRoot\..").Path
4 | $gitCommand = "git"
5 | $chocoCommand = "choco"
6 |
7 | $solution = @{
8 | targetFolder = "$homeDir\output"
9 | assetZipPath = "$homeDir\tools.zip"
10 | }
11 |
12 | $choco = @{
13 | homeDir = "$homeDir\deploy\chocolatey"
14 | nuspec = "$homeDir\deploy\chocolatey\docfx-companion-tools.nuspec"
15 | chocoScript = "$homeDir\deploy\chocolatey\tools\chocolateyinstall.ps1"
16 | }
17 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator.Test/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 |
3 | # top-most EditorConfig file
4 | root = false
5 |
6 | [*.cs]
7 |
8 | # CS8604: Possible null reference argument.
9 | dotnet_diagnostic.CS8604.severity = none
10 |
11 | # CA1707: Identifiers should not contain underscores
12 | dotnet_diagnostic.CA1707.severity = none
13 |
14 | # Default severity for all analyzer diagnostics
15 | dotnet_analyzer_diagnostic.severity = none
16 |
17 | # CS8602: Dereference of a possibly null reference.
18 | dotnet_diagnostic.CS8602.severity = none
19 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator.Test/Usings.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 |
4 | global using System.Threading.Tasks;
5 | global using DocFXLanguageGenerator;
6 | global using DocFXLanguageGenerator.Domain;
7 | global using DocLanguageTranslator.Domain;
8 | global using DocLanguageTranslator.Test.Helpers;
9 | global using DocLanguageTranslator.TranslationService;
10 | global using Moq;
11 | global using Xunit;
12 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator.Test/DocFxTocGenerator.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 |
8 | false
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker.Test/DocLinkChecker.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "documentationRules": {
5 | "companyName": "DocFx Companion Tools",
6 | "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information.",
7 | "variables": {
8 | "licenseName": "MIT",
9 | "licenseFile": "LICENSE"
10 | }
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "documentationRules": {
5 | "companyName": "DocFx Companion Tools",
6 | "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information.",
7 | "variables": {
8 | "licenseName": "MIT",
9 | "licenseFile": "LICENSE"
10 | }
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/Domain/ErrorResponse.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 | using Newtonsoft.Json;
4 |
5 | namespace DocFXLanguageGenerator.Domain
6 | {
7 | ///
8 | /// Error response.
9 | ///
10 | public class ErrorResponse
11 | {
12 | ///
13 | /// Gets or sets the error.
14 | ///
15 | [JsonProperty(PropertyName = "error")]
16 | public ErrorDetail Error { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/deploy/chocolatey/tools/chocolateyinstall.ps1:
--------------------------------------------------------------------------------
1 | $ErrorActionPreference = 'Stop';
2 |
3 | $packageName= 'docfx-companion-tools'
4 | $version = 'v1.0.0'
5 | $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
6 | $url = "https://github.com/Ellerbach/docfx-companion-tools/releases/download/$version/tools.zip"
7 | $hash = 'c726597aa286436236a98b2915f93bf72632aadc248359abb3c7233fd81cb3f3'
8 |
9 | $packageArgs = @{
10 | packageName = $packageName
11 | unzipLocation = $toolsDir
12 | url = $url
13 | checksum = $hash
14 | checksumType = 'SHA256'
15 | }
16 |
17 | Install-ChocolateyZipPackage @packageArgs
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/DocFxOpenApi/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 |
6 | using System.Diagnostics.CodeAnalysis;
7 |
8 | [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File should have header", Justification = "We don't use file headers in DMP.")]
9 | [assembly: SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "Literals are allowed in a tool. No need for localization.")]
10 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Enums/MarkdownErrorSeverity.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Enums
2 | {
3 | ///
4 | /// Markdown error severity.
5 | ///
6 | public enum MarkdownErrorSeverity
7 | {
8 | ///
9 | /// Information.
10 | ///
11 | Information,
12 |
13 | ///
14 | /// Suggestion.
15 | ///
16 | Suggestion,
17 |
18 | ///
19 | /// Warning.
20 | ///
21 | Warning,
22 |
23 | ///
24 | /// Error.
25 | ///
26 | Error,
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Models/PipeTable.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Models
2 | {
3 | ///
4 | /// Pipe table in markdown file.
5 | ///
6 | public class PipeTable : MarkdownObjectBase
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | /// File path of markdown file.
12 | /// Line number.
13 | /// Column.
14 | public PipeTable(string filePath, int line, int pos)
15 | : base(filePath, line, pos)
16 | {
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
2 | ARG tool
3 | WORKDIR /app
4 |
5 | # Copy project file
6 | COPY . ./
7 | # Restore as distinct layers
8 | RUN dotnet restore "src/${tool}/${tool}.csproj"
9 | # Build and publish a release
10 | RUN dotnet publish "src/${tool}/${tool}.csproj" -c Release -r linux-musl-x64 -o out /p:PublishSingleFile=true /p:CopyOutputSymbolsToPublishDirectory=false /p:AssemblyName=docfx-companion-tools-entrypoint --self-contained false
11 |
12 | # Build runtime image
13 | FROM mcr.microsoft.com/dotnet/runtime:9.0
14 | RUN adduser -D docfx-companion-tools
15 | COPY --from=build-env /app/out /usr/bin/
16 | USER docfx-companion-tools
17 | ENTRYPOINT ["docfx-companion-tools-entrypoint"]
--------------------------------------------------------------------------------
/DocExamples/ui-specific/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/Domain/TranslationResults.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 | using Newtonsoft.Json;
4 |
5 | namespace DocFXLanguageGenerator.Domain
6 | {
7 | ///
8 | /// The translation result from the call to Azure Cognitive Service API.
9 | ///
10 | public class TranslationResults
11 | {
12 | ///
13 | /// Gets or sets the translation array.
14 | ///
15 | [JsonProperty(PropertyName = "translations")]
16 | public Translation[] Translations { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator.Test/Helpers/MockMessageHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using DocFXLanguageGenerator.Helpers;
3 |
4 | namespace DocLanguageTranslator.Test.Helpers;
5 |
6 | internal class MockMessageHelper : IMessageHelper
7 | {
8 | public List Errors { get; } = new List();
9 | public List Warnings { get; } = new List();
10 | public List VerboseMessages { get; } = new List();
11 |
12 | public void Error(string message)
13 | => this.Errors.Add(message);
14 |
15 | public void Verbose(string message)
16 | => this.VerboseMessages.Add(message);
17 |
18 | public void Warning(string message)
19 | => this.Warnings.Add(message);
20 | }
21 |
--------------------------------------------------------------------------------
/src/build/dotnet/common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | all
5 | runtime; build; native; contentfiles; analyzers; buildtransitive
6 |
7 |
8 | all
9 | runtime; build; native; contentfiles; analyzers; buildtransitive
10 |
11 |
12 |
13 | 12.0
14 | true
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/Configuration/Replacement.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | namespace DocAssembler.Configuration;
6 |
7 | ///
8 | /// Replacement definition.
9 | ///
10 | public sealed record Replacement
11 | {
12 | ///
13 | /// Gets or sets the regex expression for the replacement.
14 | ///
15 | public string Expression { get; set; } = string.Empty;
16 |
17 | ///
18 | /// Gets or sets the replacement value.
19 | ///
20 | public string? Value { get; set; }
21 | }
22 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Enums/RelativeLinkType.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Enums
2 | {
3 | ///
4 | /// Enumeration of hyperlink types.
5 | ///
6 | public enum RelativeLinkType
7 | {
8 | ///
9 | /// Relative links to all content is allowed.
10 | ///
11 | All,
12 |
13 | ///
14 | /// Relative links are only allowed within the same docs hierarchy.
15 | ///
16 | SameDocsHierarchyOnly,
17 |
18 | ///
19 | /// Relative links are allowed to content in any docs hierarchy.
20 | /// This means that the full path of the content is checked that it has /docs
21 | /// somewhere in the path.
22 | ///
23 | AnyDocsHierarchy,
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/Domain/ErrorDetail.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 | using Newtonsoft.Json;
4 |
5 | namespace DocFXLanguageGenerator.Domain
6 | {
7 | ///
8 | /// Error details.
9 | ///
10 | public class ErrorDetail
11 | {
12 | ///
13 | /// Gets or sets the error code.
14 | ///
15 | [JsonProperty(PropertyName = "code")]
16 | public int Code { get; set; }
17 |
18 | ///
19 | /// Gets or sets the error message.
20 | ///
21 | [JsonProperty(PropertyName = "message")]
22 | public string Message { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/TableOfContents/TocOrderStrategy.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | namespace DocFxTocGenerator.TableOfContents;
6 |
7 | ///
8 | /// Table of contents order strategy.
9 | ///
10 | public enum TocOrderStrategy
11 | {
12 | ///
13 | /// Order folders and files in one list.
14 | ///
15 | All,
16 |
17 | ///
18 | /// Order folders first, then order files.
19 | ///
20 | FoldersFirst,
21 |
22 | ///
23 | /// Order files first, then order folders.
24 | ///
25 | FilesFirst,
26 | }
27 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/Domain/Translation.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 | using Newtonsoft.Json;
4 |
5 | namespace DocFXLanguageGenerator.Domain
6 | {
7 | ///
8 | /// Actual translation results.
9 | ///
10 | public class Translation
11 | {
12 | ///
13 | /// Gets or sets the translated text.
14 | ///
15 | [JsonProperty(PropertyName = "text")]
16 | public string Text { get; set; }
17 |
18 | ///
19 | /// Gets or sets the translated language.
20 | ///
21 | [JsonProperty(PropertyName = "to")]
22 | public string To { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/changelog-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "categories": [
3 | {
4 | "title": "## 🚀 Features",
5 | "labels": ["feature", "enhancement"]
6 | },
7 | {
8 | "title": "## 🐛 Fixes",
9 | "labels": ["fix", "bug"]
10 | },
11 | {
12 | "title": "## 📄 Documentation",
13 | "labels": ["documentation"]
14 | }
15 | ],
16 | "ignore_labels": [
17 | "ignore"
18 | ],
19 | "sort": "ASC",
20 | "template": "${{CHANGELOG}}\n",
21 | "pr_template": "- ${{TITLE}} (PR: #${{NUMBER}})",
22 | "empty_template": "- no changes",
23 | "label_extractor": [ ],
24 | "duplicate_filter": {
25 | "pattern": "\\[ABC-....\\]",
26 | "on_property": "title",
27 | "method": "match"
28 | },
29 | "transformers": [ ],
30 | "max_tags_to_fetch": 200,
31 | "max_pull_requests": 200,
32 | "max_back_track_time_days": 365,
33 | "exclude_merge_branches": [ ]
34 | }
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler.Test/DocAssembler.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 |
8 | false
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Constants/AppConstants.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Constants
2 | {
3 | ///
4 | /// Constants for the app.
5 | ///
6 | public static class AppConstants
7 | {
8 | ///
9 | /// Application configuration filename.
10 | ///
11 | public const string AppConfigFileName = "docfx-companion-tools.json";
12 |
13 | ///
14 | /// Command to write a default configuration file.
15 | ///
16 | public const string AppConfigInitCommand = "INIT";
17 |
18 | ///
19 | /// HTTP Client name.
20 | ///
21 | public const string HttpClientName = "DocLinkChecker-Client";
22 |
23 | ///
24 | /// Markdown extension.
25 | ///
26 | public const string MarkdownExtension = "md";
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/DocExamples/docfx.json:
--------------------------------------------------------------------------------
1 | {
2 | "build": {
3 | "content": [
4 | {
5 | "files": [
6 | "docs/**/*.md",
7 | "userdocs/**/*.md",
8 | "*.md",
9 | ".order",
10 | "**/toc.yml"
11 | ]
12 | }
13 | ],
14 | "resource": [
15 | {
16 | "files": ["docs/.attachments/**", "userdocs/.attachments/**"]
17 | },
18 | { "files": ["web.config"], "src": "ui-specific", "dest": "" }
19 | ],
20 | "overwrite": "docs/*.md",
21 | "globalMetadata": {
22 | "_appTitle": "Example Documentation",
23 | "_enableSearch": true
24 | },
25 | "markdownEngineName": "markdig",
26 | "dest": "_site",
27 | "xrefService": ["https://xref.docs.microsoft.com/query?uid={uid}"]
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Helpers/TextExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Helpers;
2 |
3 | ///
4 | /// Text extension methods. Mainly for normalizing paths and content.
5 | ///
6 | public static class TextExtensions
7 | {
8 | ///
9 | /// Normalize the path to always forward-slashes.
10 | ///
11 | /// Path to normalize.
12 | /// Normalized path.
13 | public static string NormalizePath(this string path)
14 | {
15 | return path.Replace("\\", "/");
16 | }
17 |
18 | ///
19 | /// Normalize content for newlines to be always just "\n".
20 | ///
21 | /// Content to normalize.
22 | /// Normalized content.
23 | public static string NormalizeContent(this string content)
24 | {
25 | return content.Replace("\r", string.Empty);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Models/FileMappingItem.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json.Serialization;
2 |
3 | namespace DocLinkChecker.Models
4 | {
5 | ///
6 | /// Model class for file mapping.
7 | ///
8 | public class FileMappingItem
9 | {
10 | ///
11 | /// Gets or sets the source folder.
12 | ///
13 | [JsonPropertyName("src")]
14 | public string SourceFolder { get; set; }
15 |
16 | ///
17 | /// Gets or sets the folders and files to include.
18 | /// This list supports the file glob pattern.
19 | ///
20 | public List Files { get; set; } = new();
21 |
22 | ///
23 | /// Gets or sets the folders and files to exclude.
24 | /// This list supports the file glob pattern.
25 | ///
26 | public List Exclude { get; set; } = new();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | # Workflow triggered by push to main
2 | # For all solutions we run restore, build & test
3 | name: Build & Test
4 |
5 | on:
6 | pull_request:
7 | branches: [ main ]
8 | workflow_dispatch:
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v4
16 | with:
17 | fetch-depth: 0
18 | - name: Setup .NET
19 | uses: actions/setup-dotnet@v4
20 | with:
21 | dotnet-version: 8.x
22 |
23 | # Loop through all the solutions in src and restore, build & test
24 | # Skip DocFxCompanionTools.sln, as it is a combination of all solutions.
25 | - name: Restore, build & test
26 | shell: pwsh
27 | run: |
28 | foreach ($sln in (Get-ChildItem -Recurse src\*.sln -Exclude DocFxCompanionTools.sln)) {
29 | Write-Host "Start building $($sln.FullName)"
30 |
31 | & dotnet restore $sln.FullName
32 | & dotnet build $sln.FullName --no-restore
33 | & dotnet test $sln.FullName --no-build --verbosity normal
34 | }
35 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/TranslationService/ITranslationService.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 |
4 | namespace DocLanguageTranslator.TranslationService;
5 |
6 | ///
7 | /// Provides translation services between different languages.
8 | ///
9 | public interface ITranslationService
10 | {
11 | ///
12 | /// Translates text from one language to another asynchronously.
13 | ///
14 | /// The text to be translated.
15 | /// The language code of the source text (e.g., "en" for English).
16 | /// The language code to translate the text into (e.g., "fr" for French).
17 | /// A task that represents the asynchronous operation. The task result contains the translated text.
18 | Task TranslateAsync(string text, string sourceLang, string targetLang);
19 | }
20 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/FileService/HyperlinkType.cs:
--------------------------------------------------------------------------------
1 | namespace DocAssembler.FileService;
2 |
3 | ///
4 | /// Enumeration of hyperlink types.
5 | ///
6 | public enum HyperlinkType
7 | {
8 | ///
9 | /// Local file.
10 | ///
11 | Local,
12 |
13 | ///
14 | /// A web page (http or https).
15 | ///
16 | Webpage,
17 |
18 | ///
19 | /// A download link (ftp or ftps).
20 | ///
21 | Ftp,
22 |
23 | ///
24 | /// Mail address (mailto).
25 | ///
26 | Mail,
27 |
28 | ///
29 | /// A cross reference (xref).
30 | ///
31 | CrossReference,
32 |
33 | ///
34 | /// A local resource, like an image.
35 | ///
36 | Resource,
37 |
38 | ///
39 | /// A tab - DocFx special. See https://dotnet.github.io/docfx/docs/markdown.html?tabs=linux%2Cdotnet#tabs.
40 | ///
41 | Tab,
42 |
43 | ///
44 | /// Empty link.
45 | ///
46 | Empty,
47 | }
48 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Enums/ReturnValue.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Enums
2 | {
3 | ///
4 | /// Application return values.
5 | ///
6 | public enum ReturnValue
7 | {
8 | ///
9 | /// We're processing, so no return value yet.
10 | ///
11 | Processing = -1,
12 |
13 | ///
14 | /// Successful validation. No errors, no warnings.
15 | ///
16 | Success = 0,
17 |
18 | ///
19 | /// Errors in the commandline.
20 | ///
21 | CommandError = 1,
22 |
23 | ///
24 | /// Errors in the configuration by file.
25 | ///
26 | ConfigurationFileErrors = 3,
27 |
28 | ///
29 | /// There were only warnings in processing the files, no errors.
30 | ///
31 | WarningsOnly = 1000,
32 |
33 | ///
34 | /// There were errors in processing the files.
35 | ///
36 | Errors = 1001,
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) Microsoft Corporation.
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/Domain/TranslationException.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 |
4 | namespace DocLanguageTranslator.Domain;
5 |
6 | ///
7 | /// Represents errors that occur during translation operations.
8 | ///
9 | internal class TranslationException : Exception
10 | {
11 | ///
12 | /// Gets the error code associated with this translation exception.
13 | ///
14 | public int ErrorCode { get; }
15 |
16 | ///
17 | /// Initializes a new instance of the class with a specified error message and error code.
18 | ///
19 | /// The message that describes the error.
20 | /// The error code that identifies the specific translation error.
21 | public TranslationException(string message, int errorCode)
22 | : base(message)
23 | {
24 | ErrorCode = errorCode;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Models/Heading.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Models
2 | {
3 | ///
4 | /// Heading in markdown file.
5 | ///
6 | public class Heading : MarkdownObjectBase
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | /// File path of markdown file.
12 | /// Line number.
13 | /// Column.
14 | /// Title.
15 | /// Id.
16 | public Heading(string filePath, int line, int pos, string title, string id)
17 | : base(filePath, line, pos)
18 | {
19 | Title = title;
20 | Id = id;
21 | }
22 |
23 | ///
24 | /// Gets or sets the title of the heading.
25 | ///
26 | public string Title { get; set; }
27 |
28 | ///
29 | /// Gets or sets the id of the heading.
30 | ///
31 | public string Id { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/build/dotnet/tests.common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | runtime; build; native; contentfiles; analyzers; buildtransitive
7 | all
8 |
9 |
10 | runtime; build; native; contentfiles; analyzers; buildtransitive
11 | all
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/DocExamples/index.md:
--------------------------------------------------------------------------------
1 | # Welcome in the documentation sample
2 |
3 | This documentation sample is easy to use, on one side we've created a [developer documentation](./docs), on the other side an [end user documentation](./userdocs/index.md).
4 |
5 | IF you are trying to click on the first link, the file does not exists yet. It will be created automatically by the TOC Generator tool. You only see in the sources main `toc.yml` file but no others for the sub directory. The same tool is used to create them magically!
6 |
7 | It an use the `.order` file created and used by `Azure DevOps` to generate the TOC with a specific order. It can also uses advance features to find the main title in a markdown file, uses it as the name entry or just uses an override one for the folder names or file titles per directory. This feature is very useful when it comes to multi language automatically generated site and you want in the TOC to have a proper translated name.
8 |
9 | ## Examples of sub TOC generation
10 |
11 | TODO: add screen capture of the resulting directory + toc screen captures.
12 |
13 | ## Example of override
14 |
15 | TODO: add screen capture of the resulting directory + toc screen captures.
16 |
--------------------------------------------------------------------------------
/PipelineExamples/documentation-validation.yml:
--------------------------------------------------------------------------------
1 | ###########################################################################
2 | # This is a sample Azure DevOps pipeline that can be used for validating
3 | # documentation. In this pipeline we use markdownlint and the DocLinkChecker tool.
4 | ###########################################################################
5 | trigger: none
6 |
7 | pool:
8 | vmImage: windows-latest
9 |
10 | jobs:
11 | # Scan markdownfiles on style consistency
12 | - job:
13 | displayName: 'Execute Markdownlint'
14 | steps:
15 | - bash: npm install -g markdownlint-cli
16 | displayName: 'Install markdownlint'
17 |
18 | - bash: markdownlint -c $CONFIGFILE $WORKDIR
19 | env:
20 | WORKDIR: $(System.DefaultWorkingDirectory)
21 | CONFIGFILE: $(System.DefaultWorkingDirectory)/.markdownlint.json
22 | displayName: 'Run markdownlint'
23 |
24 | # install the companion tools
25 | - powershell: choco install docfx-companion-tools -y
26 | displayName: Install docfx companion tools
27 |
28 | # run the toc generator on /DocExamample folder
29 | - powershell: DocLinkChecker -d .\DocExamples -a
30 | displayName: 'Checking links in .\DocExamples'
31 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/FileService/FilePathExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 |
3 | namespace DocFxTocGenerator.FileService;
4 |
5 | ///
6 | /// File path extension methods.
7 | ///
8 | [ExcludeFromCodeCoverage]
9 | public static class FilePathExtensions
10 | {
11 | ///
12 | /// Normalize the path to have a common notation of directory separators.
13 | /// This is needed when used in Equal() methods and such.
14 | ///
15 | /// Path to normalize.
16 | /// Normalized path.
17 | public static string NormalizePath(this string path)
18 | {
19 | return path.Replace("\\", "/");
20 | }
21 |
22 | ///
23 | /// Normalize the content. This is used to make sure we always
24 | /// have "\n" only for new lines. Mostly used by the test mocks.
25 | ///
26 | /// Content to normalize.
27 | /// Normalized content.
28 | public static string NormalizeContent(this string content)
29 | {
30 | return content.Replace("\r", string.Empty);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/TableOfContents/TocFolderReferenceStrategy.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | namespace DocFxTocGenerator.TableOfContents;
6 |
7 | ///
8 | /// Table of contents folder reference strategy.
9 | ///
10 | public enum TocFolderReferenceStrategy
11 | {
12 | ///
13 | /// Folders don't have a reference to anything.
14 | ///
15 | None,
16 |
17 | ///
18 | /// Folders can have a reference to an index file, otherwise no reference.
19 | ///
20 | Index,
21 |
22 | ///
23 | /// Folders can have a reference to an index file or readme, otherwise no reference.
24 | ///
25 | IndexReadme,
26 |
27 | ///
28 | /// Folders can have a reference to an index file or readme or the first file in the folder.
29 | /// No reference if the folder is empty.
30 | ///
31 | First,
32 | }
33 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/Utils/SerializationUtil.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json;
2 | using System.Text.Json.Serialization;
3 |
4 | namespace DocAssembler.Utils;
5 |
6 | ///
7 | /// Serialization utilities.
8 | ///
9 | public static class SerializationUtil
10 | {
11 | ///
12 | /// Gets the JSON serializer options.
13 | ///
14 | public static JsonSerializerOptions Options => new()
15 | {
16 | ReadCommentHandling = JsonCommentHandling.Skip,
17 | PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
18 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
19 | WriteIndented = true,
20 | Converters =
21 | {
22 | new JsonStringEnumConverter(),
23 | },
24 | };
25 |
26 | ///
27 | /// Serialize object.
28 | ///
29 | public static string Serialize(object value) => JsonSerializer.Serialize(value, Options);
30 |
31 | ///
32 | /// Deserialize JSON string.
33 | ///
34 | /// Target type.
35 | public static T Deserialize(string json) => JsonSerializer.Deserialize(json, Options)!;
36 | }
37 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Interfaces/ICustomConsoleLogger.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Interfaces
2 | {
3 | ///
4 | /// Interface for the custom console logger.
5 | ///
6 | public interface ICustomConsoleLogger
7 | {
8 | ///
9 | /// Helper method for verbose messages.
10 | ///
11 | /// Message to show in verbose mode.
12 | void Output(string message);
13 |
14 | ///
15 | /// Helper method for verbose messages. Only displays when verbose is enabled.
16 | ///
17 | /// Message to show in verbose mode.
18 | void Verbose(string message);
19 |
20 | ///
21 | /// Helper method for warning messages.
22 | ///
23 | /// Message to show in verbose mode.
24 | void Warning(string message);
25 |
26 | ///
27 | /// Helper method for error messages.
28 | ///
29 | /// Message to show in verbose mode.
30 | void Error(string message);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/Helpers/IMessageHelper.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 | namespace DocFXLanguageGenerator.Helpers
4 | {
5 | ///
6 | /// Interface for handling different types of messages in the application.
7 | /// Provides methods for logging errors, verbose information, and warnings.
8 | ///
9 | public interface IMessageHelper
10 | {
11 | ///
12 | /// Logs an error message.
13 | ///
14 | /// The error message to be logged.
15 | void Error(string message);
16 |
17 | ///
18 | /// Logs a verbose (detailed) information message.
19 | ///
20 | /// The verbose message to be logged.
21 | void Verbose(string message);
22 |
23 | ///
24 | /// Logs a warning message.
25 | ///
26 | /// The warning message to be logged.
27 | void Warning(string message);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Enums/HyperlinkType.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Enums
2 | {
3 | ///
4 | /// Enumeration of hyperlink types.
5 | ///
6 | public enum HyperlinkType
7 | {
8 | ///
9 | /// Local file.
10 | ///
11 | Local,
12 |
13 | ///
14 | /// A web page (http or https).
15 | ///
16 | Webpage,
17 |
18 | ///
19 | /// A download link (ftp or ftps).
20 | ///
21 | Ftp,
22 |
23 | ///
24 | /// Mail address (mailto).
25 | ///
26 | Mail,
27 |
28 | ///
29 | /// A cross reference (xref).
30 | ///
31 | CrossReference,
32 |
33 | ///
34 | /// A local resource, like an image.
35 | ///
36 | Resource,
37 |
38 | ///
39 | /// A tab - DocFx special. See https://dotnet.github.io/docfx/docs/markdown.html?tabs=linux%2Cdotnet#tabs.
40 | ///
41 | Tab,
42 |
43 | ///
44 | /// Empty link.
45 | ///
46 | Empty,
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Helpers/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace DocLinkChecker.Helpers
4 | {
5 | ///
6 | /// String extension methods.
7 | ///
8 | public static class StringExtensions
9 | {
10 | ///
11 | /// Match a string against a wildcard pattern.
12 | /// You can use * and ? in the wildcard pattern.
13 | ///
14 | /// String to match with pattern.
15 | /// The pattern.
16 | /// A value indicating there is a match (true) or not (false).
17 | public static bool Matches(this string str, string pattern)
18 | {
19 | if (string.IsNullOrEmpty(pattern))
20 | {
21 | return false;
22 | }
23 |
24 | Regex r = new Regex(WildcardToRegex(pattern), RegexOptions.IgnoreCase);
25 | return r.IsMatch(str);
26 | }
27 |
28 | private static string WildcardToRegex(string pattern)
29 | {
30 | return "^" + Regex.Escape(pattern).
31 | Replace("\\*", ".*").
32 | Replace("\\?", ".") + "$";
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 |
6 | // This file is used by Code Analysis to maintain SuppressMessage
7 | // attributes that are applied to this project.
8 | // Project-level suppressions either have no target or are given
9 | // a specific target and scoped to a namespace, type, member, etc.
10 | using System.Diagnostics.CodeAnalysis;
11 |
12 | [assembly: SuppressMessage("Performance", "CA1848:Use the LoggerMessage delegates", Justification = "No need to optimaze in console app.")]
13 | [assembly: SuppressMessage("Usage", "CA2254:Template should be a static expression", Justification = "No need to optimize in console app.")]
14 | [assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1309:Field names should not begin with underscore", Justification = "Coding style different")]
15 | [assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "We don't want this.")]
16 | [assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "We will decide case by case.")]
17 |
--------------------------------------------------------------------------------
/src/build/dotnet/CodeAnalysis.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 |
6 | // This file is used by Code Analysis to maintain SuppressMessage
7 | // attributes that are applied to this project.
8 | // Project-level suppressions either have no target or are given
9 | // a specific target and scoped to a namespace, type, member, etc.
10 | using System.Diagnostics.CodeAnalysis;
11 |
12 | [assembly: SuppressMessage("Performance", "CA1848:Use the LoggerMessage delegates", Justification = "No need to optimaze in console app.")]
13 | [assembly: SuppressMessage("Usage", "CA2254:Template should be a static expression", Justification = "No need to optimize in console app.")]
14 | [assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1309:Field names should not begin with underscore", Justification = "Coding style different")]
15 | [assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "We don't want this.")]
16 | [assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "We will decide case by case.")]
17 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/FileService/FileService.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 |
4 | namespace DocLanguageTranslator.FileService;
5 |
6 | ///
7 | /// Provides file operations implementation.
8 | ///
9 | internal class FileService : IFileService
10 | {
11 | ///
12 | public bool DirectoryExists(string path) => Directory.Exists(path);
13 |
14 | ///
15 | public bool FileExists(string path) => File.Exists(path);
16 |
17 | ///
18 | public string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
19 | => Directory.GetFiles(path, searchPattern, searchOption);
20 |
21 | ///
22 | public string[] GetDirectories(string path)
23 | => Directory.GetDirectories(path);
24 |
25 | ///
26 | public string ReadAllText(string filePath)
27 | => File.ReadAllText(filePath);
28 |
29 | ///
30 | public void WriteAllText(string filePath, string content)
31 | => File.WriteAllText(filePath, content);
32 |
33 | ///
34 | public void CreateDirectory(string path)
35 | => Directory.CreateDirectory(path);
36 | }
37 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/FileService/FileData.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using DocAssembler.Configuration;
6 |
7 | namespace DocAssembler.FileService;
8 |
9 | ///
10 | /// File data.
11 | ///
12 | public sealed record FileData
13 | {
14 | ///
15 | /// Gets or sets the source full path of the file.
16 | ///
17 | public string SourcePath { get; set; } = string.Empty;
18 |
19 | ///
20 | /// Gets or sets the destination full path of the file.
21 | ///
22 | public string DestinationPath { get; set; } = string.Empty;
23 |
24 | ///
25 | /// Gets or sets the content set the file belongs to.
26 | ///
27 | public Content? ContentSet { get; set; }
28 |
29 | ///
30 | /// Gets or sets all links in the document we might need to work on.
31 | ///
32 | public List Links { get; set; } = [];
33 |
34 | ///
35 | /// Gets a value indicating whether the file is a markdown file.
36 | ///
37 | public bool IsMarkdown => Path.GetExtension(SourcePath).Equals(".md", StringComparison.OrdinalIgnoreCase);
38 | }
39 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/Utils/LogUtil.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 | using System.Globalization;
7 | using Microsoft.Extensions.Logging;
8 | using Serilog;
9 | using Serilog.Events;
10 |
11 | namespace DocAssembler.Utils;
12 |
13 | ///
14 | /// Log utils.
15 | ///
16 | [ExcludeFromCodeCoverage]
17 | internal static class LogUtil
18 | {
19 | ///
20 | /// Get the logger factory.
21 | ///
22 | /// Log level.
23 | /// Logger factory.
24 | /// When an unknown log level is given.
25 | public static ILoggerFactory GetLoggerFactory(LogLevel logLevel1)
26 | {
27 | var serilogLevel = (LogEventLevel)logLevel1;
28 |
29 | var serilog = new LoggerConfiguration()
30 | .MinimumLevel.Is(serilogLevel)
31 | .WriteTo.Console(standardErrorFromLevel: LogEventLevel.Warning, outputTemplate: "{Message:lj}{NewLine}", formatProvider: CultureInfo.InvariantCulture)
32 | .CreateLogger();
33 | return LoggerFactory.Create(p => p.AddSerilog(serilog));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/Actions/ActionException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 |
7 | namespace DocAssembler.Actions;
8 |
9 | ///
10 | /// Exception class for the ParserService.
11 | ///
12 | [ExcludeFromCodeCoverage]
13 | public class ActionException : Exception
14 | {
15 | ///
16 | /// Initializes a new instance of the class.
17 | ///
18 | public ActionException()
19 | {
20 | }
21 |
22 | ///
23 | /// Initializes a new instance of the class.
24 | ///
25 | /// Message of exception.
26 | public ActionException(string message)
27 | : base(message)
28 | {
29 | }
30 |
31 | ///
32 | /// Initializes a new instance of the class.
33 | ///
34 | /// Message of exception.
35 | /// Inner exception.
36 | public ActionException(string message, Exception innerException)
37 | : base(message, innerException)
38 | {
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/FileService/FilePathExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 |
7 | namespace DocAssembler.FileService;
8 |
9 | ///
10 | /// File path extension methods.
11 | ///
12 | [ExcludeFromCodeCoverage]
13 | public static class FilePathExtensions
14 | {
15 | ///
16 | /// Normalize the path to have a common notation of directory separators.
17 | /// This is needed when used in Equal() methods and such.
18 | ///
19 | /// Path to normalize.
20 | /// Normalized path.
21 | public static string NormalizePath(this string path)
22 | {
23 | return path.Replace("\\", "/");
24 | }
25 |
26 | ///
27 | /// Normalize the content. This is used to make sure we always
28 | /// have "\n" only for new lines. Mostly used by the test mocks.
29 | ///
30 | /// Content to normalize.
31 | /// Normalized content.
32 | public static string NormalizeContent(this string content)
33 | {
34 | return content.Replace("\r", string.Empty);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/Actions/ActionException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 |
7 | namespace DocFxTocGenerator.Actions;
8 |
9 | ///
10 | /// Exception class for the ParserService.
11 | ///
12 | [ExcludeFromCodeCoverage]
13 | public class ActionException : Exception
14 | {
15 | ///
16 | /// Initializes a new instance of the class.
17 | ///
18 | public ActionException()
19 | {
20 | }
21 |
22 | ///
23 | /// Initializes a new instance of the class.
24 | ///
25 | /// Message of exception.
26 | public ActionException(string message)
27 | : base(message)
28 | {
29 | }
30 |
31 | ///
32 | /// Initializes a new instance of the class.
33 | ///
34 | /// Message of exception.
35 | /// Inner exception.
36 | public ActionException(string message, Exception innerException)
37 | : base(message, innerException)
38 | {
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/Liquid/LiquidException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 |
7 | namespace DocFxTocGenerator.Liquid;
8 |
9 | ///
10 | /// Exception class for the ParserService.
11 | ///
12 | [ExcludeFromCodeCoverage]
13 | public class LiquidException : Exception
14 | {
15 | ///
16 | /// Initializes a new instance of the class.
17 | ///
18 | public LiquidException()
19 | {
20 | }
21 |
22 | ///
23 | /// Initializes a new instance of the class.
24 | ///
25 | /// Message of exception.
26 | public LiquidException(string message)
27 | : base(message)
28 | {
29 | }
30 |
31 | ///
32 | /// Initializes a new instance of the class.
33 | ///
34 | /// Message of exception.
35 | /// Inner exception.
36 | public LiquidException(string message, Exception innerException)
37 | : base(message, innerException)
38 | {
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/Index/IndexGenerationStrategy.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | namespace DocFxTocGenerator.Index;
6 |
7 | ///
8 | /// Enumeration of the type of generation for index.
9 | ///
10 | public enum IndexGenerationStrategy
11 | {
12 | ///
13 | /// Do not generate an index.
14 | ///
15 | Never,
16 |
17 | ///
18 | /// Generate an index for all folders without a default file (README.md or index.md).
19 | ///
20 | NoDefault,
21 |
22 | ///
23 | /// Generate an index for all folders without a default file (README.md or index.md), except
24 | /// when it contains only 1 file.
25 | ///
26 | NoDefaultMulti,
27 |
28 | ///
29 | /// Generate an index for all empty folders only.
30 | ///
31 | EmptyFolders,
32 |
33 | ///
34 | /// Generate an index for all folders that don't have an index file.
35 | ///
36 | NotExists,
37 |
38 | ///
39 | /// Generate an index for all folders that don't have an index file, except when it contains only 1 file.
40 | ///
41 | NotExistMulti,
42 | }
43 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Models/MarkdownObjectBase.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Models
2 | {
3 | ///
4 | /// Base class for markdown objects.
5 | ///
6 | public abstract class MarkdownObjectBase
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | public MarkdownObjectBase()
12 | {
13 | }
14 |
15 | ///
16 | /// Initializes a new instance of the class.
17 | ///
18 | /// Path of the markdown file.
19 | /// Line number.
20 | /// Column.
21 | public MarkdownObjectBase(string filePath, int line, int pos)
22 | {
23 | FilePath = filePath;
24 | Line = line;
25 | Column = pos;
26 | }
27 |
28 | ///
29 | /// Gets or sets the file path name of the markdown file.
30 | ///
31 | public string FilePath { get; set; }
32 |
33 | ///
34 | /// Gets or sets the line number in the file.
35 | ///
36 | public int Line { get; set; }
37 |
38 | ///
39 | /// Gets or sets the column in the file.
40 | ///
41 | public int Column { get; set; }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/THIRD-PARTY-NOTICES.TXT:
--------------------------------------------------------------------------------
1 | Most of those companion tools has been written jointly with ZF under a proper MIT license.
2 |
3 | The MIT License (MIT)
4 | Copyright © 2020, ZF and contributors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the “Software”), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | The Software is provided “as is”, without warranty of any kind, express or
17 | implied, including but not limited to the warranties of merchantability,
18 | fitness for a particular purpose and noninfringement. In no event shall the
19 | authors or copyright holders X be liable for any claim, damages or other
20 | liability, whether in an action of contract, tort or otherwise, arising from,
21 | out of or in connection with the software or the use or other dealings in
22 | the Software.
23 |
24 | Except as contained in this notice, the name of the ZF and contributors
25 | shall not be used in advertising or otherwise to promote the sale, use or
26 | other dealings in this Software without prior written authorization from the
27 | ZF and contributors
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/Domain/CommandlineOptions.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 |
4 | namespace DocFXLanguageGenerator.Domain
5 | {
6 | ///
7 | /// Class for command line options.
8 | ///
9 | public class CommandlineOptions
10 | {
11 | ///
12 | /// Gets or sets the folder with documents.
13 | ///
14 | public string DocFolder { get; set; }
15 |
16 | ///
17 | /// Gets or sets a value indicating whether verbose information is shown in the output.
18 | ///
19 | public bool Verbose { get; set; }
20 |
21 | ///
22 | /// Gets or sets the translator Azure Cognitive Services key.
23 | ///
24 | public string Key { get; set; }
25 |
26 | ///
27 | /// Gets or sets the translator Azure Cognitive Services location.
28 | ///
29 | public string Location { get; set; }
30 |
31 | ///
32 | /// Gets or sets the source language.
33 | ///
34 | public string SourceLanguage { get; set; }
35 |
36 | ///
37 | /// Gets or sets a value indicating whether to only check files are missing.
38 | ///
39 | public bool CheckOnly { get; set; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator.Test/Helpers/MockFileService.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 |
4 | using System.Collections.Generic;
5 | using DocLanguageTranslator.FileService;
6 | using System.IO;
7 | using System.Linq;
8 |
9 | namespace DocLanguageTranslator.Test.Helpers;
10 |
11 | public class MockFileService : IFileService
12 | {
13 | public Dictionary Files { get; } = new Dictionary();
14 | public List Directories { get; } = new List();
15 |
16 | public bool DirectoryExists(string path) => Directories.Contains(path);
17 |
18 | public bool FileExists(string path) => Files.ContainsKey(path);
19 |
20 | public string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
21 | => Files.Keys
22 | .Where(k => k.StartsWith(path) && k.EndsWith(".md"))
23 | .ToArray();
24 |
25 | public string[] GetDirectories(string path)
26 | => Directories.Where(d => d.StartsWith(path)).ToArray();
27 |
28 | public string ReadAllText(string filePath)
29 | => Files.TryGetValue(filePath, out var content) ? content : null;
30 |
31 | public void WriteAllText(string filePath, string content)
32 | => Files[filePath] = content;
33 |
34 | public void CreateDirectory(string path)
35 | {
36 | if (!Directories.Contains(path))
37 | Directories.Add(path);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/FileService/FileData.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 |
7 | namespace DocFxTocGenerator.FileService;
8 |
9 | ///
10 | /// File data record.
11 | ///
12 | [ExcludeFromCodeCoverage]
13 | public record FileData : FolderFileBase
14 | {
15 | ///
16 | /// Gets a value indicating whether this is a markdown file.
17 | ///
18 | public bool IsMarkdown => System.IO.Path.GetExtension(Name).Equals(".md", StringComparison.OrdinalIgnoreCase);
19 |
20 | ///
21 | /// Gets a value indicating whether this is a swagger file.
22 | ///
23 | public bool IsSwagger => Name.EndsWith("swagger.json", StringComparison.OrdinalIgnoreCase);
24 |
25 | ///
26 | /// Gets a value indicating whether this is a README file.
27 | ///
28 | public bool IsConfiguration => Name.StartsWith(".", StringComparison.OrdinalIgnoreCase);
29 |
30 | ///
31 | /// Gets a value indicating whether this is a README file.
32 | ///
33 | public bool IsReadme => Name.Equals("readme.md", StringComparison.OrdinalIgnoreCase);
34 |
35 | ///
36 | /// Gets a value indicating whether this is an INDEX file.
37 | ///
38 | public bool IsIndex => Name.Equals("index.md", StringComparison.OrdinalIgnoreCase);
39 | }
40 |
--------------------------------------------------------------------------------
/src/DocFxOpenApi/DocFxOpenApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | 12.0
7 | enable
8 | enable
9 | true
10 | true
11 | MIT
12 | README.md
13 | DocFx Companion Tools contributors
14 | DocFx Companion Tools
15 | DocFxOpenApi
16 | git
17 | https://github.com/Ellerbach/docfx-companion-tools
18 | https://github.com/Ellerbach/docfx-companion-tools
19 | This tool converts existing [OpenAPI](https://www.openapis.org/) specification files into the format compatible with DocFX (OpenAPI v2 JSON files). It allows DocFX to generate HTML pages from the OpenAPI specification. OpenAPI is also known as [Swagger](https://swagger.io/).
20 | docfx tools companion open api yml
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/GitVersion.yml:
--------------------------------------------------------------------------------
1 | mode: ContinuousDelivery
2 | branches:
3 | master:
4 | regex: ^main
5 | tag: ''
6 | increment: Minor
7 | prevent-increment-of-merged-branch-version: true
8 | track-merge-target: false
9 | tracks-release-branches: false
10 | is-release-branch: true
11 | release:
12 | regex: ^releases?[/-]
13 | tag: beta
14 | increment: Patch
15 | prevent-increment-of-merged-branch-version: true
16 | track-merge-target: false
17 | tracks-release-branches: false
18 | is-release-branch: true
19 | pre-release-weight: 1000
20 | feature:
21 | regex: ^features?[/-]
22 | tag: 'alpha'
23 | increment: Inherit
24 | prevent-increment-of-merged-branch-version: false
25 | track-merge-target: false
26 | tracks-release-branches: false
27 | is-release-branch: false
28 | pull-request:
29 | regex: ^(pull|pull\-requests|pr)[/-]
30 | tag: alpha
31 | increment: Inherit
32 | prevent-increment-of-merged-branch-version: false
33 | tag-number-pattern: '[/-](?\d+)[-/]'
34 | track-merge-target: false
35 | tracks-release-branches: false
36 | is-release-branch: false
37 | hotfix:
38 | regex: ^hotfix(es)?[/-]
39 | tag: beta
40 | increment: Patch
41 | prevent-increment-of-merged-branch-version: false
42 | track-merge-target: false
43 | tracks-release-branches: false
44 | is-release-branch: false
45 | support:
46 | regex: ^support[/-]
47 | tag: ''
48 | increment: Patch
49 | prevent-increment-of-merged-branch-version: true
50 | track-merge-target: false
51 | tracks-release-branches: false
52 | is-release-branch: false
53 | ignore:
54 | sha: []
55 | merge-message-formats: {}
56 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.11.35431.28
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocAssembler", "DocAssembler\DocAssembler.csproj", "{20348289-FB98-4EE3-987D-576E3C568EB3}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocAssembler.Test", "DocAssembler.Test\DocAssembler.Test.csproj", "{BA44E0E9-6D85-4185-99BA-8697A02663A1}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {20348289-FB98-4EE3-987D-576E3C568EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {20348289-FB98-4EE3-987D-576E3C568EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {20348289-FB98-4EE3-987D-576E3C568EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {20348289-FB98-4EE3-987D-576E3C568EB3}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {BA44E0E9-6D85-4185-99BA-8697A02663A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {BA44E0E9-6D85-4185-99BA-8697A02663A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {BA44E0E9-6D85-4185-99BA-8697A02663A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {BA44E0E9-6D85-4185-99BA-8697A02663A1}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {97487205-BC8C-4B1C-B40E-EDC19E4F01B9}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/DocLanguageTranslator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | 12.0
7 | true
8 | true
9 | enable
10 | disable
11 | MIT
12 | README.md
13 | DocFx Companion Tools contributors
14 | DocFx Companion Tools
15 | DocLanguageTranslator
16 | git
17 | https://github.com/Ellerbach/docfx-companion-tools
18 | https://github.com/Ellerbach/docfx-companion-tools
19 | This tool allows to generate and translate automatically missing files or identify missing files in multi language pattern directories.
20 | docfx tools companion language markdown translator
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.5.33530.505
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocLinkChecker", "DocLinkChecker\DocLinkChecker.csproj", "{F9426B04-9122-4CB6-9441-53DBB8A3D594}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocLinkChecker.Test", "DocLinkChecker.Test\DocLinkChecker.Test.csproj", "{4F73D786-2F9F-4B03-B8E9-3F078E8E6106}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {F9426B04-9122-4CB6-9441-53DBB8A3D594}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {F9426B04-9122-4CB6-9441-53DBB8A3D594}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {F9426B04-9122-4CB6-9441-53DBB8A3D594}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {F9426B04-9122-4CB6-9441-53DBB8A3D594}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {4F73D786-2F9F-4B03-B8E9-3F078E8E6106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {4F73D786-2F9F-4B03-B8E9-3F078E8E6106}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {4F73D786-2F9F-4B03-B8E9-3F078E8E6106}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {4F73D786-2F9F-4B03-B8E9-3F078E8E6106}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {B3F20EBE-7901-4F0F-AC02-FFBE72F662AC}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.11.35303.130
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocFxTocGenerator", "DocFxTocGenerator\DocFxTocGenerator.csproj", "{FA0CA120-2DA5-4167-98F0-37DC7C406918}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFxTocGenerator.Test", "DocFxTocGenerator.Test\DocFxTocGenerator.Test.csproj", "{921A1E89-9B56-4389-B156-D0D78C6A4CB6}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {FA0CA120-2DA5-4167-98F0-37DC7C406918}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {FA0CA120-2DA5-4167-98F0-37DC7C406918}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {FA0CA120-2DA5-4167-98F0-37DC7C406918}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {FA0CA120-2DA5-4167-98F0-37DC7C406918}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {921A1E89-9B56-4389-B156-D0D78C6A4CB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {921A1E89-9B56-4389-B156-D0D78C6A4CB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {921A1E89-9B56-4389-B156-D0D78C6A4CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {921A1E89-9B56-4389-B156-D0D78C6A4CB6}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {DB7435EE-AA7C-4AC6-A5A9-C10AA6DB1CC2}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.14.36202.13 d17.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocLanguageTranslator", "DocLanguageTranslator\DocLanguageTranslator.csproj", "{6557E453-2275-4231-AB6E-85BCA59D6E4D}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocLanguageTranslator.Test", "DocLanguageTranslator.Test\DocLanguageTranslator.Test.csproj", "{1D15BAAF-0ACD-463B-B18D-4C429A9D2139}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {6557E453-2275-4231-AB6E-85BCA59D6E4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {6557E453-2275-4231-AB6E-85BCA59D6E4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {6557E453-2275-4231-AB6E-85BCA59D6E4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {6557E453-2275-4231-AB6E-85BCA59D6E4D}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {1D15BAAF-0ACD-463B-B18D-4C429A9D2139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {1D15BAAF-0ACD-463B-B18D-4C429A9D2139}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {1D15BAAF-0ACD-463B-B18D-4C429A9D2139}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {1D15BAAF-0ACD-463B-B18D-4C429A9D2139}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {6AACDCB9-F8E3-4C4A-AA61-1105DDCF1952}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/src/DocFxOpenApi/DocFxOpenApi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26124.0
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFxOpenApi", "DocFxOpenApi.csproj", "{AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x64 = Debug|x64
12 | Debug|x86 = Debug|x86
13 | Release|Any CPU = Release|Any CPU
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Debug|x64.ActiveCfg = Debug|Any CPU
24 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Debug|x64.Build.0 = Debug|Any CPU
25 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Debug|x86.ActiveCfg = Debug|Any CPU
26 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Debug|x86.Build.0 = Debug|Any CPU
27 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Release|x64.ActiveCfg = Release|Any CPU
30 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Release|x64.Build.0 = Release|Any CPU
31 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Release|x86.ActiveCfg = Release|Any CPU
32 | {AFE399B5-4E43-4D11-A854-5E49EEFC9F2B}.Release|x86.Build.0 = Release|Any CPU
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/Configuration/AssembleConfiguration.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Text.Json.Serialization;
6 |
7 | namespace DocAssembler.Configuration;
8 |
9 | ///
10 | /// Assemble configuration.
11 | ///
12 | public sealed record AssembleConfiguration
13 | {
14 | ///
15 | /// Gets or sets the destination folder.
16 | ///
17 | [JsonPropertyName("dest")]
18 | public string DestinationFolder { get; set; } = string.Empty;
19 |
20 | ///
21 | /// Gets or sets the global URL replacements. Can be overruled by settings.
22 | ///
23 | public List? UrlReplacements { get; set; }
24 |
25 | ///
26 | /// Gets or sets the global content replacements. Can be overruled by settings.
27 | ///
28 | public List? ContentReplacements { get; set; }
29 |
30 | ///
31 | /// Gets or sets the prefix for external files like source files.
32 | /// This is for all references to files that are not part of the
33 | /// selected files (mostly markdown and assets).
34 | /// An example use is to prefix the URL with the url of the github repo.
35 | /// This is the global setting, that can be overruled by settings.
36 | ///
37 | public string? ExternalFilePrefix { get; set; }
38 |
39 | ///
40 | /// Gets or sets the content to process.
41 | ///
42 | public List Content { get; set; } = new();
43 | }
44 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/Utils/LogUtil.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 | using System.Globalization;
7 | using Microsoft.Extensions.Logging;
8 | using Serilog;
9 | using Serilog.Events;
10 |
11 | namespace DocFxTocGenerator.Utils;
12 |
13 | ///
14 | /// Log utils.
15 | ///
16 | [ExcludeFromCodeCoverage]
17 | internal static class LogUtil
18 | {
19 | ///
20 | /// Get the logger factory.
21 | ///
22 | /// Log level.
23 | /// Logger factory.
24 | /// When an unknown log level is given.
25 | public static ILoggerFactory GetLoggerFactory(LogLevel logLevel1)
26 | {
27 | var serilogLevel = logLevel1 switch
28 | {
29 | LogLevel.Critical => LogEventLevel.Fatal,
30 | LogLevel.Error => LogEventLevel.Error,
31 | LogLevel.Warning => LogEventLevel.Warning,
32 | LogLevel.Information => LogEventLevel.Information,
33 | LogLevel.Debug => LogEventLevel.Debug,
34 | LogLevel.Trace => LogEventLevel.Verbose,
35 | _ => throw new ArgumentOutOfRangeException(nameof(logLevel1)),
36 | };
37 |
38 | var serilog = new LoggerConfiguration()
39 | .MinimumLevel.Is(serilogLevel)
40 | .WriteTo.Console(standardErrorFromLevel: LogEventLevel.Warning, outputTemplate: "{Message:lj}{NewLine}", formatProvider: CultureInfo.InvariantCulture)
41 | .CreateLogger();
42 | return LoggerFactory.Create(p => p.AddSerilog(serilog));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/TableOfContents/TocItem.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 | using DocFxTocGenerator.FileService;
7 |
8 | namespace DocFxTocGenerator.TableOfContents;
9 |
10 | ///
11 | /// Table of contents item.
12 | ///
13 | [ExcludeFromCodeCoverage]
14 | public class TocItem
15 | {
16 | ///
17 | /// Gets or sets the name of the item.
18 | ///
19 | public string Name { get; set; } = string.Empty;
20 |
21 | ///
22 | /// Gets or sets the depth of this item in the complete hierarchy.
23 | ///
24 | public int Depth { get; set; }
25 |
26 | ///
27 | /// Gets or sets the reference path of the item.
28 | ///
29 | public string Href { get; set; } = string.Empty;
30 |
31 | ///
32 | /// Gets or sets the sequence of the item (for sorting).
33 | ///
34 | public int Sequence { get; set; } = int.MaxValue;
35 |
36 | ///
37 | /// Gets or sets the base folder or file for this item.
38 | ///
39 | public FolderFileBase? Base { get; set; }
40 |
41 | ///
42 | /// Gets a value indicating whether this is a folder item.
43 | ///
44 | public bool IsFolder => Base != null && Base is FolderData;
45 |
46 | ///
47 | /// Gets a value indicating whether this is a file item.
48 | ///
49 | public bool IsFile => Base != null && Base is FileData;
50 |
51 | ///
52 | /// Gets or sets child items.
53 | ///
54 | public List Items { get; set; } = new();
55 | }
56 |
--------------------------------------------------------------------------------
/PipelineExamples/documentation-build.yml:
--------------------------------------------------------------------------------
1 | ###########################################################################
2 | # This is a sample Azure DevOps pipeline that can be used for generating
3 | # a documentation website using DocFX. In this pipeline we use the
4 | # DocFxTocGenerator tool to generate the table of contents.
5 | ###########################################################################
6 | trigger:
7 | - none
8 |
9 | variables:
10 | - name: AzureConnectionName
11 | value: ''
12 |
13 | pool:
14 | vmImage: windows-latest
15 |
16 | steps:
17 | # install docfx
18 | - powershell: choco install docfx -y
19 | displayName: Install docfx
20 |
21 | # install the companion tools
22 | - powershell: choco install docfx-companion-tools -y
23 | displayName: Install docfx companion tools
24 |
25 | # run the toc generator on /DocExamample folder
26 | - powershell: DocFxTocGenerator -d .\DocExamples -si
27 | displayName: 'Generating TOC for .\DocExamples'
28 |
29 | # run docfx to generate documentation website
30 | - powershell: |
31 | &docfx DocEample\docfx.json
32 | if ($lastexitcode -ne 0)
33 | {
34 | throw [System.Exception] "docfx build failed with exit code $lastexitcode."
35 | }
36 | condition: succeeded()
37 | displayName: Run docfx
38 |
39 | # Create an archive
40 | - task: ArchiveFiles@2
41 | displayName: 'Packing Documentation Web Site'
42 | inputs:
43 | rootFolderOrFile: '$(System.DefaultWorkingDirectory)/_site'
44 | includeRootFolder: false
45 | archiveType: 'zip'
46 | archiveFile: '$(Build.ArtifactStagingDirectory)/site.zip'
47 | replaceExistingArchive: true
48 |
49 | # deployment to Azure
50 | - task: AzureRmWebAppDeployment@4
51 | displayName: 'Publish website to Azure App Service'
52 | inputs:
53 | azureSubscription: $(AzureConnectionName)
54 | WebAppName: docs-website
55 | packageForLinux: '$(Build.ArtifactStagingDirectory)/site.zip'
56 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/DocAssembler.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | 12.0
7 | true
8 | true
9 | enable
10 | enable
11 | true
12 | latest-Recommended
13 |
14 | MIT
15 | README.md
16 | DocFx Companion Tools contributors
17 | DocFx Companion Tools
18 | DocAssembler
19 | git
20 | https://github.com/Ellerbach/docfx-companion-tools
21 | https://github.com/Ellerbach/docfx-companion-tools
22 | Tool to assemble documentation from various locations and change links where necessary.
23 | docfx tools companion documentation assembler
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Services/FileService.cs:
--------------------------------------------------------------------------------
1 | using DocLinkChecker.Interfaces;
2 | using Microsoft.Extensions.FileSystemGlobbing;
3 |
4 | namespace DocLinkChecker.Services
5 | {
6 | ///
7 | /// File service implementation.
8 | ///
9 | public class FileService : IFileService
10 | {
11 | ///
12 | public bool ExistsFileOrDirectory(string path)
13 | {
14 | return File.Exists(path) || Directory.Exists(path);
15 | }
16 |
17 | ///
18 | public string GetDirectory(string path)
19 | {
20 | return Path.GetDirectoryName(path);
21 | }
22 |
23 | ///
24 | public IEnumerable GetFiles(string root, List includes, List excludes)
25 | {
26 | string fullRoot = GetFullPath(root);
27 | Matcher matcher = new();
28 | foreach (string folderName in includes)
29 | {
30 | matcher.AddInclude(folderName);
31 | }
32 |
33 | foreach (string folderName in excludes)
34 | {
35 | matcher.AddExclude(folderName);
36 | }
37 |
38 | return matcher.GetResultsInFullPath(fullRoot);
39 | }
40 |
41 | ///
42 | public string GetRelativePath(string relativeTo, string path)
43 | {
44 | return Path.GetRelativePath(relativeTo, path);
45 | }
46 |
47 | ///
48 | public string GetFullPath(string path)
49 | {
50 | return Path.GetFullPath(path);
51 | }
52 |
53 | ///
54 | public void DeleteFile(string path)
55 | {
56 | File.Delete(path);
57 | }
58 |
59 | ///
60 | public void DeleteFiles(string[] paths)
61 | {
62 | foreach (string path in paths)
63 | {
64 | File.Delete(path);
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/deploy/chocolatey/docfx-companion-tools.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | docfx-companion-tools
5 | 1.0.0
6 | https://github.com/Ellerbach/docfx-companion-tools/tree/main/deploy/chocolatey
7 |
8 | Laurent Ellerbach, Martin Tirion
9 |
10 |
11 |
12 |
13 | DocFx Companion Tools
14 | Laurent Ellerbach, Martin Tirion
15 | https://github.com/Ellerbach/docfx-companion-tools
16 | https://github.com/Ellerbach/docfx-companion-tools/blob/main/LICENSE
17 | true
18 | docfx tool linter
19 | The DocFx Companion Tools contains a set of utilities for generating documentation from MD-files and source files using DocFx.
20 | The DocFx Companion Tools contains a set of utilities for generating documentation from MD-files and source files using DocFx.
21 | It contains these tools:
22 |
23 | * DocFxTocGenerator - generates a table of contents from a folder-structure with MD-files.
24 | * DocLinkChecker - a validation tool for checking links and attachments used in MD-files.
25 | * DocLanguageTranslator - an automatic translator of MD-files using Azure Cognitive Services.
26 | * DocFxOpenApi - converts existing OpenAPI specification files into the format compatible with DocFX.
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/DocExamples/docs/tools/doc-link-checker.md:
--------------------------------------------------------------------------------
1 | # Documentation link checker
2 |
3 | This tool can be used to check references in markdown files.
4 |
5 | ## Usage
6 |
7 | ```text
8 | DocLinkChecker -d [-vac]
9 |
10 | -d, --docfolder Required. Folder containing the documents.
11 | -v, --verbose Show verbose messages.
12 | -a, --attachments Check the .attachments folder in the root of the docfolder for unreferenced files.
13 | -c, --cleanup Remove all unreferenced files from the .attachments folder in the root of the docfolder. Must be used in combination with -a flag.
14 | --help Display this help screen.
15 | --version Display version information.
16 | ```
17 |
18 | If normal return code of the tool is 0, but on error it returns 1.
19 |
20 | ## Warnings, errors and verbose
21 |
22 | If the tool encounters situations that might need some action, a warning is written to the output. The table of contents is still created.
23 |
24 | If the tool encounters an error, an error message is written to the output. The table of contents will not be created. The tool will return errorcode 1.
25 |
26 | If you want to trace what the tool is doing, use the `-v or verbose` flag to output all details of processing the files and folders and creating the table of contents.
27 |
28 | ## What it checks
29 |
30 | The tool will track all use of `[]()`. If the link is a web URL, an internal reference (starting with a '#') an e-mail address or a reference to a folder, it's not checked. Other links are checked if they exist in the existing docs hierarchy or on local disc (for code references). Errors are written to the ouput mentioning the filename, the linenumber and position in the line. In the check we also decode the references to make sure we properly check HTML enccoded strings as well (using %20 for instance).
31 |
32 | All references are stored in a table to use in the check of the .attachments folder (with the -a flag). All files in this folder that are not referenced are marked as 'unreferenced'. If the -c flag is provided as well, the files are removed from the .attachments folder.
33 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/FileService/FolderFileBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 |
7 | namespace DocFxTocGenerator.FileService;
8 |
9 | ///
10 | /// Base record for folders and files.
11 | ///
12 | [ExcludeFromCodeCoverage]
13 | public record FolderFileBase
14 | {
15 | ///
16 | /// Gets or sets the name.
17 | ///
18 | public string Name { get; set; } = string.Empty;
19 |
20 | ///
21 | /// Gets or sets the full path.
22 | ///
23 | public string Path { get; set; } = string.Empty;
24 |
25 | ///
26 | /// Gets or sets the display name of the item.
27 | ///
28 | public string DisplayName { get; set; } = string.Empty;
29 |
30 | ///
31 | /// Gets or sets a value indicating whether the display name is coming from the .override.
32 | /// This should always be the preference then.
33 | ///
34 | public bool IsDisplayNameOverride { get; set; }
35 |
36 | ///
37 | /// Gets or sets the sequence value of this item.
38 | ///
39 | public int Sequence { get; set; } = int.MaxValue;
40 |
41 | ///
42 | /// Gets or sets the parent folder.
43 | ///
44 | public FolderData? Parent { get; set; }
45 |
46 | ///
47 | /// Gets the relative path to the item.
48 | ///
49 | public string RelativePath
50 | {
51 | get
52 | {
53 | return Parent == null ? string.Empty : System.IO.Path.Combine(Parent.RelativePath, Name).NormalizePath();
54 | }
55 | }
56 |
57 | ///
58 | /// Gets the root full path of the hierarchy.
59 | ///
60 | public string RootFullPath
61 | {
62 | get
63 | {
64 | return Parent == null ? Path : Parent.RootFullPath;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/DocLinkChecker.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | 12.0
7 | true
8 | true
9 | enable
10 | disable
11 | MIT
12 | README.md
13 | DocFx Companion Tools contributors
14 | DocFx Companion Tools
15 | DocLinkChecker
16 | git
17 | https://github.com/Ellerbach/docfx-companion-tools
18 | https://github.com/Ellerbach/docfx-companion-tools
19 | This tool can be used to check references in markdown files.
20 | docfx tools companion link check
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | all
38 | runtime; build; native; contentfiles; analyzers; buildtransitive
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/DocFxTocGenerator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | 12.0
7 | true
8 | true
9 | enable
10 | enable
11 | true
12 | latest-Recommended
13 |
14 | MIT
15 | README.md
16 | DocFx Companion Tools contributors
17 | DocFx Companion Tools
18 | DocFxTocGenerator
19 | git
20 | https://github.com/Ellerbach/docfx-companion-tools
21 | https://github.com/Ellerbach/docfx-companion-tools
22 | This tool allow to generate a yaml compatible `toc.yml` file for DocFX.
23 | docfx tools companion toc builder yml
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/DocAssembler/DocAssembler/Configuration/Content.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 | using System.Text.Json.Serialization;
7 |
8 | namespace DocAssembler.Configuration;
9 |
10 | ///
11 | /// Content definition using globbing patterns.
12 | ///
13 | public sealed record Content
14 | {
15 | ///
16 | /// Gets or sets the source folder.
17 | ///
18 | [JsonPropertyName("src")]
19 | public string SourceFolder { get; set; } = string.Empty;
20 |
21 | ///
22 | /// Gets or sets the optional destination folder.
23 | ///
24 | [JsonPropertyName("dest")]
25 | public string? DestinationFolder { get; set; }
26 |
27 | ///
28 | /// Gets or sets the folders and files to include.
29 | /// This list supports the file glob pattern.
30 | ///
31 | public List Files { get; set; } = new();
32 |
33 | ///
34 | /// Gets or sets the folders and files to exclude.
35 | /// This list supports the file glob pattern.
36 | ///
37 | public List? Exclude { get; set; }
38 |
39 | ///
40 | /// Gets or sets a value indicating whether we need to do just a raw copy.
41 | ///
42 | public bool? RawCopy { get; set; }
43 |
44 | ///
45 | /// Gets or sets the URL replacements.
46 | ///
47 | public List? UrlReplacements { get; set; }
48 |
49 | ///
50 | /// Gets or sets the content replacements.
51 | ///
52 | public List? ContentReplacements { get; set; }
53 |
54 | ///
55 | /// Gets or sets the prefix for external files like source files.
56 | /// This is for all references to files that are not part of the
57 | /// selected files (mostly markdown and assets).
58 | /// An example use is to prefix the URL with the url of the github repo.
59 | ///
60 | public string? ExternalFilePrefix { get; set; }
61 | }
62 |
--------------------------------------------------------------------------------
/src/DocLinkChecker/DocLinkChecker/Interfaces/IFileService.cs:
--------------------------------------------------------------------------------
1 | namespace DocLinkChecker.Interfaces
2 | {
3 | ///
4 | /// Interface for file service.
5 | ///
6 | public interface IFileService
7 | {
8 | ///
9 | /// Check if the given path exists as file or directory.
10 | ///
11 | /// Path to check.
12 | /// A value indicating whether the path exists.
13 | bool ExistsFileOrDirectory(string path);
14 |
15 | ///
16 | /// Get files with the Glob File Pattern.
17 | ///
18 | /// Root path.
19 | /// Include patterns.
20 | /// Exclude patterns.
21 | /// List of files.
22 | IEnumerable GetFiles(string root, List includes, List excludes);
23 |
24 | ///
25 | /// Get the directory of the given path.
26 | ///
27 | /// Path.
28 | /// Directory.
29 | string GetDirectory(string path);
30 |
31 | ///
32 | /// Get the full path of the given path.
33 | ///
34 | /// Relative path.
35 | /// Full path.
36 | string GetFullPath(string path);
37 |
38 | ///
39 | /// Get the relative path of the given path, relative to the relativeTo path.
40 | ///
41 | /// Relative to this folder.
42 | /// Path to determine the relative path for.
43 | /// Relative path.
44 | string GetRelativePath(string relativeTo, string path);
45 |
46 | ///
47 | /// Delete the given file.
48 | ///
49 | /// Path of file.
50 | void DeleteFile(string path);
51 |
52 | ///
53 | /// Delete the list of files.
54 | ///
55 | /// Paths of files.
56 | void DeleteFiles(string[] paths);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/DocFxOpenApi/Helpers/MessageHelper.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 | using global::DocFxOpenApi.Domain;
4 |
5 | namespace DocFxOpenApi.Helpers
6 | {
7 | ///
8 | /// Helper methods to write messages to the console.
9 | ///
10 | public class MessageHelper
11 | {
12 | private readonly CommandlineOptions _options;
13 |
14 | ///
15 | /// Initializes a new instance of the class.
16 | ///
17 | /// Command line options.
18 | public MessageHelper(CommandlineOptions options)
19 | {
20 | this._options = options;
21 | }
22 |
23 | ///
24 | /// Helper method for verbose messages.
25 | ///
26 | /// Message to show in verbose mode.
27 | public void Verbose(string message)
28 | {
29 | if (this._options.Verbose)
30 | {
31 | Console.WriteLine(message);
32 | }
33 | }
34 |
35 | ///
36 | /// Helper method for warning messages.
37 | ///
38 | /// Message to show in verbose mode.
39 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "We want same access for all methods.")]
40 | public void Warning(string message)
41 | {
42 | Console.ForegroundColor = ConsoleColor.Yellow;
43 | Console.WriteLine(message);
44 | Console.ResetColor();
45 | }
46 |
47 | ///
48 | /// Helper method for error messages.
49 | ///
50 | /// Message to show in verbose mode.
51 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "We want same access for all methods.")]
52 | public void Error(string message)
53 | {
54 | Console.ForegroundColor = ConsoleColor.Red;
55 | Console.WriteLine(message);
56 | Console.ResetColor();
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/DocFxTocGenerator/DocFxTocGenerator/FileService/FileService.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) DocFx Companion Tools. All rights reserved.
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 | //
5 | using System.Diagnostics.CodeAnalysis;
6 | using Microsoft.Extensions.FileSystemGlobbing;
7 |
8 | namespace DocFxTocGenerator.FileService;
9 |
10 | ///
11 | /// File service implementation working with class.
12 | ///
13 | [ExcludeFromCodeCoverage]
14 | public class FileService : IFileService
15 | {
16 | ///
17 | public string GetFullPath(string path)
18 | {
19 | return Path.GetFullPath(path);
20 | }
21 |
22 | ///
23 | public bool ExistsFileOrDirectory(string path)
24 | {
25 | return File.Exists(path) || Directory.Exists(path);
26 | }
27 |
28 | ///
29 | public IEnumerable GetFiles(string root, List includes, List excludes)
30 | {
31 | string fullRoot = Path.GetFullPath(root);
32 | Matcher matcher = new();
33 | foreach (string folderName in includes)
34 | {
35 | matcher.AddInclude(folderName);
36 | }
37 |
38 | foreach (string folderName in excludes)
39 | {
40 | matcher.AddExclude(folderName);
41 | }
42 |
43 | // make sure we normalize the directory separator
44 | return matcher.GetResultsInFullPath(fullRoot)
45 | .Select(x => x.Replace("\\", "/"))
46 | .ToList();
47 | }
48 |
49 | ///
50 | public IEnumerable GetDirectories(string folder)
51 | {
52 | return Directory.GetDirectories(folder);
53 | }
54 |
55 | /// >
56 | public string ReadAllText(string path)
57 | {
58 | return File.ReadAllText(path);
59 | }
60 |
61 | ///
62 | public string[] ReadAllLines(string path)
63 | {
64 | return File.ReadAllLines(path);
65 | }
66 |
67 | ///
68 | public void WriteAllText(string path, string content)
69 | {
70 | File.WriteAllText(path, content);
71 | }
72 |
73 | ///
74 | public Stream OpenRead(string path)
75 | {
76 | return File.OpenRead(path);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/DocExamples/docs/ui-specific-elements.md:
--------------------------------------------------------------------------------
1 | # UI specific elements for DocFX
2 |
3 | ## Serving specific files
4 |
5 | If you start customizing the DocFX templates, you'll most likely end up having to support specific files for the search and for the fonts. Depending where you deploy them, this may require to adjust your web server. In the case of deployment in an Azure Web Application, you will need to adjust the [web.config](../ui-specific/web.config) file.
6 |
7 | You will have to add it to the file you deploy as well in the root directory. See how it's done in this example in the [docfx.json](../docfx.json) file.
8 |
9 | ## Adding support for mermaid schemas
10 |
11 | [Mermaid](https://github.com/mermaid-js/mermaid) is a nice way to get support for relational drawing, flowchart and diagram out of text. It is not supported out of the box by DocFX, you need to add this support. One of the best way is to customize the UI template and adjust the file in `partials/scripts.tmpl.partial` like that:
12 |
13 | ```js
14 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
40 | ```
41 |
42 | *Note*: like any other script, please don't forget to update the version regularly.
43 |
44 | Here is a very simple mermaid example:
45 |
46 | ```mermaid
47 | requests
48 | | where name == "POST Idoc/Send"
49 | | where resultCode == 200
50 | | where customDimensions contains "ResponseBody"
51 | | order by timestamp desc
52 | ```
53 |
--------------------------------------------------------------------------------
/src/DocLanguageTranslator/DocLanguageTranslator/Helpers/MessageHelper.cs:
--------------------------------------------------------------------------------
1 | // Licensed to DocFX Companion Tools and contributors under one or more agreements.
2 | // DocFX Companion Tools and contributors licenses this file to you under the MIT license.
3 | using DocFXLanguageGenerator.Domain;
4 |
5 | namespace DocFXLanguageGenerator.Helpers
6 | {
7 | ///
8 | /// Helper methods to write messages to the console.
9 | ///
10 | public class MessageHelper : IMessageHelper
11 | {
12 | private readonly CommandlineOptions _options;
13 |
14 | ///
15 | /// Initializes a new instance of the class.
16 | ///
17 | /// Command line options.
18 | public MessageHelper(CommandlineOptions options)
19 | {
20 | _options = options;
21 | }
22 |
23 | ///
24 | /// Helper method for verbose messages.
25 | ///
26 | /// Message to show in verbose mode.
27 | public void Verbose(string message)
28 | {
29 | if (_options == null || _options.Verbose)
30 | {
31 | Console.WriteLine(message);
32 | }
33 | }
34 |
35 | ///
36 | /// Helper method for warning messages.
37 | ///
38 | /// Message to show in verbose mode.
39 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "We want same access for all methods.")]
40 | public void Warning(string message)
41 | {
42 | Console.ForegroundColor = ConsoleColor.Yellow;
43 | Console.WriteLine(message);
44 | Console.ResetColor();
45 | }
46 |
47 | ///
48 | /// Helper method for error messages.
49 | ///
50 | /// Message to show in verbose mode.
51 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "We want same access for all methods.")]
52 | public void Error(string message)
53 | {
54 | Console.ForegroundColor = ConsoleColor.Red;
55 | Console.WriteLine(message);
56 | Console.ResetColor();
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/DocFxOpenApi/README.md:
--------------------------------------------------------------------------------
1 | # OpenAPI specification converter for DocFX
2 |
3 | This tool converts existing [OpenAPI](https://www.openapis.org/) specification files into the format compatible with DocFX (OpenAPI v2 JSON files). It allows DocFX to generate HTML pages from the OpenAPI specification. OpenAPI is also known as [Swagger](https://swagger.io/).
4 |
5 | ## Usage
6 |
7 | ```text
8 | DocFxOpenApi -s [-o