Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 87 additions & 164 deletions docfx.sln

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions plugins/Directory.Build.props

This file was deleted.

7 changes: 2 additions & 5 deletions src/Docfx.App/Docfx.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<Content Include="templates/**" CopyToOutputDirectory="PreserveNewest" PackageCopyToOutput="true" PackagePath="contentFiles/any/any/templates"/>
<Content Include="templates/**" CopyToOutputDirectory="PreserveNewest" PackageCopyToOutput="true" PackagePath="contentFiles/any/any/templates" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,13 +20,10 @@

<ItemGroup>
<ProjectReference Include="..\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\Docfx.Build.ConceptualDocuments\Docfx.Build.ConceptualDocuments.csproj" />
<ProjectReference Include="..\Docfx.Build.Engine\Docfx.Build.Engine.csproj" />
<ProjectReference Include="..\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />
<ProjectReference Include="..\Docfx.Build.ResourceFiles\Docfx.Build.ResourceFiles.csproj" />
<ProjectReference Include="..\Docfx.Build.RestApi\Docfx.Build.RestApi.csproj" />
<ProjectReference Include="..\Docfx.Build.SchemaDriven\Docfx.Build.SchemaDriven.csproj" />
<ProjectReference Include="..\Docfx.Build.TableOfContents\Docfx.Build.TableOfContents.csproj" />
<ProjectReference Include="..\Docfx.Build.UniversalReference\Docfx.Build.UniversalReference.csproj" />
<ProjectReference Include="..\Docfx.Common\Docfx.Common.csproj" />
<ProjectReference Include="..\Docfx.HtmlToPdf\Docfx.HtmlToPdf.csproj" />
Expand Down

This file was deleted.

20 changes: 0 additions & 20 deletions src/Docfx.Build.Engine/Constants.cs

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text;
using Docfx.Build.SchemaDriven;
using Docfx.Common;
using Docfx.DataContracts.Common;
using Docfx.MarkdigEngine;
using Docfx.Plugins;
using Newtonsoft.Json;
Expand Down Expand Up @@ -232,7 +233,6 @@ private List<IDocumentProcessor> LoadSchemaDrivenDocumentProcessors(DocumentBuil
return result;
}

var siteHostName = TryGetPublishTargetSiteHostNameFromEnvironment();
var markdigMarkdownService = CreateMarkdigMarkdownService(parameter, resource);
foreach (var pair in resource.GetResources(@"^schemas/.*\.schema\.json"))
{
Expand All @@ -244,8 +244,7 @@ private List<IDocumentProcessor> LoadSchemaDrivenDocumentProcessors(DocumentBuil
var sdp = new SchemaDrivenDocumentProcessor(
schema,
new CompositionContainer(CompositionContainer.DefaultContainer),
markdigMarkdownService,
siteHostName);
markdigMarkdownService);
Logger.LogVerbose($"\t{sdp.Name} with build steps ({string.Join(", ", from bs in sdp.BuildSteps orderby bs.BuildOrder select bs.Name)})");
result.Add(sdp);
}
Expand Down Expand Up @@ -305,21 +304,6 @@ orderby assembly.FullName
return result;
}

private static string TryGetPublishTargetSiteHostNameFromEnvironment()
{
string metadataString = Environment.GetEnvironmentVariable(Constants.OPSEnvironmentVariable.SystemMetadata);

if (metadataString != null)
{
var metadata = JsonUtility.FromJsonString<Dictionary<string, object>>(metadataString)?.ToImmutableDictionary();
if (metadata.TryGetValue(Constants.OPSEnvironmentVariable.OpPublishTargetSiteHostName, out object publishTargetSiteHostName))
{
return (string)publishTargetSiteHostName;
}
}
return null;
}

public void Dispose()
{
_postProcessorsManager.Dispose();
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private void TransformXrefInHtml(IDocumentBuildContext context, string sourceFil
{
foreach (var xref in xrefNodes)
{
var (resolved, warn) = UpdateXref(xref, context, Constants.DefaultLanguage, out var xrefDetails);
var (resolved, warn) = UpdateXref(xref, context, "csharp", out var xrefDetails);
if (warn)
{
unresolvedXRefs.Add(xrefDetails);
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/Docfx.DataContracts.Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Docfx.DataContracts.Common;
public static class Constants
{
public const string ConfigFileName = "docfx.json";
public const string ManifestFileName = "manifest.json";
public const string YamlExtension = ".yml";
public const string ContentPlaceholder = "*content";
public const string PrefixSeparator = ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.Engine\Docfx.Build.Engine.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Common\Docfx.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.DataContracts.Common\Docfx.DataContracts.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Plugins\Docfx.Plugins.csproj" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Engine\Docfx.Build.Engine.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />
<ProjectReference Include="..\Docfx.Tests.Common\Docfx.Tests.Common.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProjectReference Include="..\..\src\Docfx.Plugins\Docfx.Plugins.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.RestApi\Docfx.Build.RestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.Engine\Docfx.Build.Engine.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />
<ProjectReference Include="..\..\src\Docfx.Common\Docfx.Common.csproj" />
<ProjectReference Include="..\Docfx.Tests.Common\Docfx.Tests.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\plugins\Docfx.Build.OperationLevelRestApi\Docfx.Build.OperationLevelRestApi.csproj" />
<ProjectReference Include="..\..\plugins\Docfx.Build.TagLevelRestApi\Docfx.Build.TagLevelRestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.OperationLevelRestApi\Docfx.Build.OperationLevelRestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.TagLevelRestApi\Docfx.Build.TagLevelRestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.Engine\Docfx.Build.Engine.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.RestApi\Docfx.Build.RestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.TableOfContents\Docfx.Build.TableOfContents.csproj" />
<ProjectReference Include="..\..\src\Docfx.DataContracts.Common\Docfx.DataContracts.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.DataContracts.RestApi\Docfx.DataContracts.RestApi.csproj" />
<ProjectReference Include="..\Docfx.Tests.Common\Docfx.Tests.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ private void BuildDocument(FileCollection files, bool enableTagLevel = false)
private static IEnumerable<System.Reflection.Assembly> LoadAssemblies(bool enableTagLevel)
{
yield return typeof(RestApiDocumentProcessor).Assembly;
yield return typeof(TocDocumentProcessor).Assembly;
yield return typeof(SplitRestApiToOperationLevel).Assembly;
if (enableTagLevel)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ private void BuildDocument(FileCollection files)
private static IEnumerable<System.Reflection.Assembly> LoadAssemblies()
{
yield return typeof(RestApiDocumentProcessor).Assembly;
yield return typeof(TocDocumentProcessor).Assembly;
yield return typeof(SplitRestApiToTagLevel).Assembly;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.Engine\Docfx.Build.Engine.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.TableOfContents\Docfx.Build.TableOfContents.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Common\Docfx.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.DataContracts.Common\Docfx.DataContracts.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Plugins\Docfx.Plugins.csproj" />
Expand Down
79 changes: 0 additions & 79 deletions test/Docfx.Build.SchemaDriven.Tests/SchemaDrivenProcessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,84 +47,6 @@ public SchemaDrivenProcessorTest()
_templateManager = new TemplateManager(new List<string> { "template" }, null, _templateFolder);
}

[Fact]
public void TestContextObjectSDP()
{
Environment.SetEnvironmentVariable("_op_systemMetadata",
JsonUtility.ToJsonString(new Dictionary<string, object> { { "_op_publishTargetSiteHostName", "ppe.docs.microsoft.com" } }));

using var listener = new TestListenerScope("TestContextObjectSDP");
var schemaFile = CreateFile("template/schemas/contextobject.schema.json", File.ReadAllText("TestData/schemas/contextobject.test.schema.json"), _templateFolder);
var tocTemplate = CreateFile("template/toc.json.tmpl", "toc template", _templateFolder);
// var coTemplate = CreateFile("template/contextobject.json.tmpl", "{{file_include2}}", _templateFolder);
var inputFileName = "co/active.yml";
var includeFile = CreateFile("a b/inc.md", @"[root](../co/active.yml)", _inputFolder);
var includeFile2 = CreateFile("c/d/inc.md", @"../../a b/toc.md", _inputFolder);
var inputFile = CreateFile(inputFileName, @"### YamlMime:ContextObject
breadcrumb_path: https://ppe.docs.microsoft.com/absolute/toc.json
toc_rel: ../a b/toc.md
file_include: ../a b/inc.md
file_include2: ../c/d/inc.md
uhfHeaderId: MSDocsHeader-DotNet
empty:
searchScope:
- .NET
", _inputFolder);

var inputFileName2 = "co/active2.yml";
var inputFile2 = CreateFile(inputFileName2, @"### YamlMime:ContextObject
breadcrumb_path: https://live.docs.microsoft.com/absolute/toc.json
", _inputFolder);

FileCollection files = new(_defaultFiles);
files.Add(DocumentType.Article, new[] { inputFile, inputFile2 }, _inputFolder);
BuildDocument(files);

Assert.Equal(5, listener.Items.Count);
Assert.Equal(2, listener.Items.Count(s => s.Message.StartsWith($"Invalid file link:(~/{_inputFolder}/a b/toc.md).")));
Assert.NotNull(listener.Items.FirstOrDefault(s => s.Message.StartsWith("There is no template processing document type(s): ContextObject")));
Assert.NotNull(listener.Items.FirstOrDefault(s => s.Message.StartsWith("Invalid file link")));
listener.Items.Clear();

var rawModelFilePath = GetRawModelFilePath(inputFileName);
Assert.True(File.Exists(rawModelFilePath));
var rawModel = JsonUtility.Deserialize<JObject>(rawModelFilePath);

Assert.Equal("Hello world!", rawModel["meta"].Value<string>());
Assert.Equal("/absolute/toc.json", rawModel["breadcrumb_path"].Value<string>());
Assert.Equal("../a b/toc.md", rawModel["toc_rel"].Value<string>());
Assert.Equal($"<p sourcefile=\"{includeFile}\" sourcestartlinenumber=\"1\" jsonPath=\"/file_include\"><a href=\"~/{inputFile}\" sourcefile=\"{includeFile}\" sourcestartlinenumber=\"1\">root</a></p>\n",
rawModel["file_include"].Value<string>());
Assert.Equal("../../a b/toc.md", rawModel["file_include2"].Value<string>());
Assert.Equal("MSDocsHeader-DotNet", rawModel["uhfHeaderId"].Value<string>());
Assert.Equal(".NET", rawModel["searchScope"][0].Value<string>());

var rawModelFilePath2 = GetRawModelFilePath(inputFileName2);
Assert.True(File.Exists(rawModelFilePath2));
var rawModel2 = JsonUtility.Deserialize<JObject>(rawModelFilePath2);
Assert.Equal("https://live.docs.microsoft.com/absolute/toc.json", rawModel2["breadcrumb_path"].Value<string>());

files = new FileCollection(_defaultFiles);
files.Add(DocumentType.Article, new[] { inputFile }, _inputFolder);
var tocFile = CreateFile("a b/toc.md", "### hello", _inputFolder);
files.Add(DocumentType.Article, new[] { tocFile }, _inputFolder);

BuildDocument(files);

Assert.Equal(2, listener.Items.Count);
Assert.NotNull(listener.Items.FirstOrDefault(s => s.Message.StartsWith("There is no template processing document type(s): ContextObject")));

Assert.True(File.Exists(rawModelFilePath));
rawModel = JsonUtility.Deserialize<JObject>(rawModelFilePath);

Assert.Equal("Hello world!", rawModel["meta"].Value<string>());
Assert.Equal("/absolute/toc.json", rawModel["breadcrumb_path"].Value<string>());
Assert.Equal("../a%20b/toc.json", rawModel["toc_rel"].Value<string>());
Assert.Equal("MSDocsHeader-DotNet", rawModel["uhfHeaderId"].Value<string>());
Assert.Equal(".NET", rawModel["searchScope"][0].Value<string>());
Assert.Equal("../a%20b/toc.json", rawModel["file_include2"].Value<string>());
}

[Fact]
public void TestRef()
{
Expand Down Expand Up @@ -488,7 +410,6 @@ private void BuildDocument(FileCollection files, DocumentBuildParameters dbp = n
private static IEnumerable<System.Reflection.Assembly> LoadAssemblies()
{
yield return typeof(SchemaDrivenDocumentProcessor).Assembly;
yield return typeof(TocDocumentProcessor).Assembly;
yield return typeof(SchemaDrivenProcessorTest).Assembly;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;
using System.Reflection;
using System.Web;
using Docfx.Build.ConceptualDocuments;
using Docfx.Build.Engine;
Expand Down Expand Up @@ -418,15 +419,10 @@ private void BuildDocument(FileCollection files, Dictionary<string, object> meta
TemplateManager = _templateManager
};

using var builder = new DocumentBuilder(LoadAssemblies(), ImmutableArray<string>.Empty);
using var builder = new DocumentBuilder(Array.Empty<Assembly>(), ImmutableArray<string>.Empty);
builder.Build(parameters);
}

private static IEnumerable<System.Reflection.Assembly> LoadAssemblies()
{
yield return typeof(ConceptualDocumentProcessor).Assembly;
}

private sealed class FileCreator
{
private readonly string _rootDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.ResourceFiles\Docfx.Build.ResourceFiles.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.RestApi\Docfx.Build.RestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.SchemaDriven\Docfx.Build.SchemaDriven.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.TableOfContents\Docfx.Build.TableOfContents.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.ConceptualDocuments\Docfx.Build.ConceptualDocuments.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.Engine\Docfx.Build.Engine.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Common\Docfx.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.DataContracts.Common\Docfx.DataContracts.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Plugins\Docfx.Plugins.csproj" />
Expand Down
Loading