Skip to content

Commit 617f87c

Browse files
authored
LG-35978Update docfx plugin to work with new version of docfx (#232)
* update * update * update * update * update
1 parent 2fb3a6c commit 617f87c

File tree

360 files changed

+1369
-1124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

360 files changed

+1369
-1124
lines changed

.github/workflows/release.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ jobs:
4343
# Runs a single command using the runners shell
4444
- name: install docfx
4545
run: |
46-
choco install docfx --version=2.59.3
47-
docfx init -q
46+
dotnet tool install -g docfx
4847
4948
- name: build _site
50-
run: docfx.exe
49+
run: docfx.exe build docfx.json
5150

5251
# Runs a set of commands using the runners shell
5352
#- name: commit to gh-pages

Plugins/TradosStudioDocsPlugin/TradosStudioDocsPlugin.sln

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.31112.23
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113 d17.12
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TradosStudioDocsPlugin", "TradosStudioDocsPlugin\TradosStudioDocsPlugin.csproj", "{69E2965B-3312-448E-8175-200C15929EFD}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{EBD4146B-4942-4745-A0F6-E15A2A9319F9}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{69E2965B-3312-448E-8175-200C15929EFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{69E2965B-3312-448E-8175-200C15929EFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{69E2965B-3312-448E-8175-200C15929EFD}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{EBD4146B-4942-4745-A0F6-E15A2A9319F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{EBD4146B-4942-4745-A0F6-E15A2A9319F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{EBD4146B-4942-4745-A0F6-E15A2A9319F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{EBD4146B-4942-4745-A0F6-E15A2A9319F9}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using Docfx.Common;
2+
using Docfx.Plugins;
3+
using System;
4+
using System.Collections.Immutable;
5+
using System.Composition;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Threading;
9+
10+
namespace TradosStudioDocsPlugin;
11+
12+
[Export(nameof(EnvironmentVariableProcessor), typeof(IPostProcessor))]
13+
public class EnvironmentVariableProcessor : IPostProcessor
14+
{
15+
public ImmutableDictionary<string, object> PrepareMetadata(ImmutableDictionary<string, object> metadata)
16+
{
17+
return metadata;
18+
}
19+
20+
public Manifest Process(Manifest manifest, string outputFolder, CancellationToken cancellationToken = default)
21+
{
22+
if (outputFolder == null)
23+
{
24+
throw new ArgumentNullException(nameof(outputFolder), "Base directory can not be null");
25+
}
26+
27+
foreach (var manifestItem in manifest.Files.Where(x => x.Type == "Conceptual"))
28+
{
29+
foreach (var manifestItemOutputFile in manifestItem.Output)
30+
{
31+
cancellationToken.ThrowIfCancellationRequested();
32+
33+
var outputPath = Path.Combine(outputFolder, manifestItemOutputFile.Value.RelativePath);
34+
35+
var content = File.ReadAllText(outputPath);
36+
37+
Logger.LogInfo($"Replacing environment variables in {outputPath}");
38+
39+
var newContent = EnvironmentVariableUtil.ReplaceEnvironmentVariables(content);
40+
41+
if (content == newContent)
42+
{
43+
continue;
44+
}
45+
46+
Logger.LogInfo($"Writing new content to {outputPath}");
47+
48+
File.WriteAllText(outputPath, newContent);
49+
}
50+
}
51+
return manifest;
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Docfx.Common;
2+
using System;
3+
using System.Text;
4+
using System.Text.RegularExpressions;
5+
6+
namespace TradosStudioDocsPlugin;
7+
8+
public partial class EnvironmentVariableUtil
9+
{
10+
[GeneratedRegex(@"Var\:(\w+)", RegexOptions.Compiled)]
11+
private static partial Regex EnvVarRegex();
12+
13+
public static string ReplaceEnvironmentVariables(string sourceText)
14+
{
15+
var matches = EnvVarRegex().Matches(sourceText);
16+
17+
if (matches.Count > 0)
18+
{
19+
var sb = new StringBuilder(sourceText.Length);
20+
21+
int lastMatchEnd = 0;
22+
23+
foreach (Match match in matches)
24+
{
25+
var envVar = match.Groups[1].Value;
26+
27+
// Append the prefix that didn't match the regex (or text since last match)
28+
sb.Append(sourceText.AsSpan(lastMatchEnd, match.Index - lastMatchEnd));
29+
30+
// Do the replacement of the regex match
31+
string envVarValue = Environment.GetEnvironmentVariable(envVar) ?? string.Empty;
32+
sb.Append(envVarValue);
33+
34+
Logger.LogInfo($"Replaced environment variable '{envVar}' with value '{envVarValue}' on match {match.Value}");
35+
lastMatchEnd = match.Index + match.Length;
36+
}
37+
38+
// Append the suffix that didn't match the regex
39+
sb.Append(sourceText.AsSpan(lastMatchEnd));
40+
41+
return sb.ToString();
42+
}
43+
44+
return sourceText;
45+
}
46+
}

Plugins/TradosStudioDocsPlugin/TradosStudioDocsPlugin/Properties/AssemblyInfo.cs

+2-24
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,13 @@
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
8-
[assembly: AssemblyTitle("TradosStudioDocsPlugin")]
9-
[assembly: AssemblyDescription("")]
10-
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("TradosStudioDocsPlugin")]
13-
[assembly: AssemblyCopyright("Copyright © 2021")]
14-
[assembly: AssemblyTrademark("")]
15-
[assembly: AssemblyCulture("")]
165

176
// Setting ComVisible to false makes the types in this assembly not visible
187
// to COM components. If you need to access a type in this assembly from
198
// COM, set the ComVisible attribute to true on that type.
209
[assembly: ComVisible(false)]
2110

2211
// The following GUID is for the ID of the typelib if this project is exposed to COM
23-
[assembly: Guid("69e2965b-3312-448e-8175-200c15929efd")]
12+
[assembly: Guid("692C89A0-3EF9-4FFD-9DB3-206D12C3AC54")]
13+
2414

25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]

Plugins/TradosStudioDocsPlugin/TradosStudioDocsPlugin/TradosStudioDocsDfmEngineCustomizer.cs

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,31 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4-
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{69E2965B-3312-448E-8175-200C15929EFD}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>TradosStudioDocsPlugin</RootNamespace>
11-
<AssemblyName>TradosStudioDocsPlugin</AssemblyName>
12-
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<Deterministic>true</Deterministic>
15-
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<DebugSymbols>true</DebugSymbols>
18-
<DebugType>full</DebugType>
19-
<Optimize>false</Optimize>
20-
<OutputPath>bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
22-
<ErrorReport>prompt</ErrorReport>
23-
<WarningLevel>4</WarningLevel>
24-
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<DebugType>pdbonly</DebugType>
27-
<Optimize>true</Optimize>
28-
<OutputPath>..\..\..\TradosStudioTemplate\Plugins\</OutputPath>
29-
<DefineConstants>TRACE</DefineConstants>
30-
<ErrorReport>prompt</ErrorReport>
31-
<WarningLevel>4</WarningLevel>
32-
</PropertyGroup>
33-
<ItemGroup>
34-
<Reference Include="System" />
35-
<Reference Include="System.Core" />
36-
<Reference Include="System.Xml.Linq" />
37-
<Reference Include="System.Data.DataSetExtensions" />
38-
<Reference Include="Microsoft.CSharp" />
39-
<Reference Include="System.Data" />
40-
<Reference Include="System.Net.Http" />
41-
<Reference Include="System.Xml" />
42-
</ItemGroup>
43-
<ItemGroup>
44-
<Compile Include="Properties\AssemblyInfo.cs" />
45-
<Compile Include="TradosStudioDocsDfmEngineCustomizer.cs" />
46-
<Compile Include="VariableInlineRule.cs" />
47-
</ItemGroup>
48-
<ItemGroup>
49-
<PackageReference Include="Microsoft.Composition">
50-
<Version>1.0.31</Version>
51-
</PackageReference>
52-
<PackageReference Include="Microsoft.DocAsCode.Dfm">
53-
<Version>2.58.0</Version>
54-
</PackageReference>
55-
<PackageReference Include="Microsoft.DocAsCode.MarkdownLite">
56-
<Version>2.58.0</Version>
57-
</PackageReference>
58-
<PackageReference Include="Microsoft.DocAsCode.Plugins">
59-
<Version>2.58.0</Version>
60-
</PackageReference>
61-
<PackageReference Include="System.Collections.Immutable">
62-
<Version>5.0.0</Version>
63-
</PackageReference>
64-
</ItemGroup>
65-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<AssemblyTitle>TradosStudioDocsPlugin</AssemblyTitle>
6+
<Product>TradosStudioDocsPlugin</Product>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<LangVersion>latest</LangVersion>
13+
</PropertyGroup>
14+
15+
<PropertyGroup Label="Version Info">
16+
<Version>1.0.0.0</Version>
17+
</PropertyGroup>
18+
19+
<PropertyGroup Label="Assembly Publishing">
20+
<IsPublishable>true</IsPublishable>
21+
<IsPublishable Condition="'$(TargetFramework)' != 'net9.0'">false</IsPublishable>
22+
</PropertyGroup>
23+
24+
25+
<ItemGroup>
26+
<PackageReference Include="Docfx.Plugins" Version="2.78.2" />
27+
<PackageReference Include="Docfx.Common" Version="2.78.0" />
28+
<PackageReference Include="System.Composition" Version="9.0.0" />
29+
</ItemGroup>
30+
6631
</Project>

Plugins/TradosStudioDocsPlugin/TradosStudioDocsPlugin/VariableInlineRule.cs

-57
This file was deleted.

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ In order for you to make a contribution directly please follow the next steps:
3333
- If you wish to test your changes locally you can follow the [DOCFX Installation guideline](https://dotnet.github.io/docfx/tutorial/docfx_getting_started.html) and [build the entire solution locally](https://dotnet.github.io/docfx/tutorial/walkthrough/walkthrough_create_a_docfx_project.html)
3434
- Our documentation automatically fills in the product name and other details so you don't have to make the changes manually if we decide to update the product name. Use the '<var:VariableName>' construct to tell our documentation engine to fill in the info for you. Here are the constructs available at this point:
3535

36-
<var:ProductName> - The product name, for example Trados Studio
37-
<var:ProductNameWithEdition> - The official product release name including the edition, for example 'Trados Studio 2021'
38-
<var:ProductVersion> - the official product version, for example Studio16
39-
<var:VersionNumber> - the official product version number, such as 16
40-
<var:VisualStudioEdition> - the most recent development compatible Microsoft Visual Studio edition
41-
<var:PluginPackedPath> - the location where plugins are deployed, for example '%AppData%\Roaming\SDL\SDL Trados Studio\16\Plugins\Packages\'
42-
<var:PluginUnpackedPath> - the location where plugins are unpacked, for example '%AppData%\Roaming\SDL\SDL Trados Studio\16\Plugins\Unpacked\'
43-
<var:InstallationFolder> - the current installation folder of our product, for example 'C:\Program Files\SDL\SDL Trados Studio\Studio16\'
36+
Var:ProductName - The product name, for example Trados Studio
37+
Var:ProductNameWithEdition - The official product release name including the edition, for example 'Trados Studio 2021'
38+
Var:ProductVersion - the official product version, for example Studio16
39+
Var:VersionNumber - the official product version number, such as 16
40+
Var:VisualStudioEdition - the most recent development compatible Microsoft Visual Studio edition
41+
Var:PluginPackedPath - the location where plugins are deployed, for example '%AppData%\Roaming\SDL\SDL Trados Studio\16\Plugins\Packages\'
42+
Var:PluginUnpackedPath - the location where plugins are unpacked, for example '%AppData%\Roaming\SDL\SDL Trados Studio\16\Plugins\Unpacked\'
43+
Var:InstallationFolder - the current installation folder of our product, for example 'C:\Program Files\SDL\SDL Trados Studio\Studio16\'
4444
4545
### Writing guidelines
46-
For consistency and ease of use we recommend you read [Writing Guidelines](writing_guidelines.md) before making any contribution. This helps keep a consistency across the reading material as well facilitate good writing and straightforward expression of concepts.
46+
For consistency and ease of use we recommend you read [Writing Guidelines](writing_guidelines.md) before making any contribution. This helps keep a consistency across the reading material as well facilitate good writing and straightforward expression of concepts.
132 KB
Binary file not shown.
47.7 KB
Binary file not shown.
Binary file not shown.
-132 KB
Binary file not shown.
-292 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-20.4 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-138 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)