From 0ed7d54dfa70baea4446469d9f5a5a8ff762ff73 Mon Sep 17 00:00:00 2001 From: Hennadii Lutsyshyn Date: Sun, 24 Mar 2024 11:26:40 +0200 Subject: [PATCH] feat: The relative paths of xslt transformation files specified in fileMetadata are now starting from the docfx.json location. (BaseDirectory of docfx). --- .gitignore | 3 ++ .../Visualizers/attribcache140.bin | Bin 8431 -> 0 bytes .../XmlDocBuildStep.cs | 42 ++++++++++-------- .../XmlDocProcessor.cs | 5 +++ .../XmlDocProcessorTests.cs | 4 ++ 5 files changed, 36 insertions(+), 18 deletions(-) delete mode 100644 Visual Studio 2022/Visualizers/attribcache140.bin diff --git a/.gitignore b/.gitignore index da3b23b..667b1e8 100644 --- a/.gitignore +++ b/.gitignore @@ -324,5 +324,8 @@ ASALocalRun/ # MSBuild Binary and Structured Log *.binlog +# Visual Studio 2022 folders +Visual Studio 2022 + # Custom Hx_Artifacts/ diff --git a/Visual Studio 2022/Visualizers/attribcache140.bin b/Visual Studio 2022/Visualizers/attribcache140.bin deleted file mode 100644 index b9026c4f4bdc813f2fc665b63c5a65e0c65926ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8431 zcmeHMUz6iT5tpezU0niP?k<jR=b~gaq`f zRkKD+c#O8E?Wo6ud7#Js?vvsp{M%8>f$ay3>^mgznQ8B+?VxW{>oYR#y642%??3u@ z_;~naxVt-e{K)*+d<8c4>n$p)y8*MvFk5A@d!o|;*@p6WV#}xtXkbgqtHM~_>4YeS z_l#N7920e4<-c>a7TC6&k>mLs8I=!m%nUFdn|46jCS_mlDTRB+?28#p?l`}n@2E5W z4#&?!Q8$FB>Xk(%=rBs*HDfkw5YID5M6CA%K~$Pdz)&WV<5Nv zuabr950~6>HSa zXGMY-Yh=feHN*DFl~e2w#pVD!5weSmVa7I=Pv_eb9%2QI`qQE=2DwOmUvO23O-7~< z5$Lu7#~#g&F(@1XIx#>TRT1Co#4oQ4)Pimi3MJ=a=5(26dznPr zf`VZN=`X9f?d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ObI6I)_CJPRAbSYMarq$)-3j zhI6$-E~v%Z(>T3&5)fw_EUXpbs}BE)!s8UAO~y|JAI#ON!>e8R5t6d=pbj61e4ju# ztwR>Yhqmic{9uIYBqku7QuvGnp8)Zd9P?ScyokxzT{JsB$Q5J$1~m|$2l#~n&T?%JPDL_=w9Do4gJnlh`b7AW;_!ja)4xVie>=88G0c8E` zWSyNAk6$n=VngMxg>@a3*oV>anKxN_AE5_9|M-*n70MXOvrwMz5)LpYc(v`NYsFRWYufcB@TYYc+MFT`zTO ztxm(JR1bQGht&>zB5(E@)lTW4UJb=+pI1A7Sql^9O8Bl4gJ@~y;nK{Opt<@#K~pJp KOM11tfaSkht0UzA diff --git a/src/Heleonix.Docfx.Plugins.XmlDoc/XmlDocBuildStep.cs b/src/Heleonix.Docfx.Plugins.XmlDoc/XmlDocBuildStep.cs index 54e13e4..e9e8b8b 100644 --- a/src/Heleonix.Docfx.Plugins.XmlDoc/XmlDocBuildStep.cs +++ b/src/Heleonix.Docfx.Plugins.XmlDoc/XmlDocBuildStep.cs @@ -11,6 +11,7 @@ namespace Heleonix.Docfx.Plugins.XmlDoc; using System.Composition; using System.Diagnostics.CodeAnalysis; using System.IO; +using System.Linq; using System.Net; using System.Reflection; using System.Runtime.Loader; @@ -88,7 +89,7 @@ public IEnumerable Prebuild(ImmutableList models, IHostSer continue; } - var content = (IDictionary)model.Content; + var content = (Dictionary)model.Content; var metadata = FileMetadata.From(content); @@ -162,28 +163,33 @@ public IEnumerable Prebuild(ImmutableList models, IHostSer continue; } + var treeItem = new TreeItem(); + + treeItem.Metadata[Constants.PropertyName.Name] = content[Constants.PropertyName.Title]; + treeItem.Metadata[Constants.PropertyName.Href] = model.Key; + treeItem.Metadata[Constants.PropertyName.TopicHref] = model.Key; + + if (content.ContainsKey("_appName")) + { + treeItem.Metadata["_appName"] = content["_appName"]; + } + + if (content.ContainsKey("_appTitle")) + { + treeItem.Metadata["_appTitle"] = content["_appTitle"]; + } + + if (content.ContainsKey("_enableSearch")) + { + treeItem.Metadata["_enableSearch"] = content["_enableSearch"]; + } + tocRestructions.Add(new () { ActionType = metadata.Toc.Action, TypeOfKey = metadata.Toc.Key.StartsWith("~") ? TreeItemKeyType.TopicHref : TreeItemKeyType.TopicUid, Key = metadata.Toc.Key, - RestructuredItems = new List - { - new TreeItem - { - Metadata = new Dictionary - { - { "name", content[Constants.PropertyName.Title] as string }, - { Constants.PropertyName.Href, model.Key }, - { Constants.PropertyName.TopicHref, model.Key }, - - // { "memberLayout", "SamePage" }, - { "_appName", content["_appName"] }, - { "_appTitle", content["_appTitle"] }, - { "_enableSearch", content["_enableSearch"] }, - }, - }, - }.ToImmutableList(), + RestructuredItems = new List { treeItem }.ToImmutableList(), }); } diff --git a/src/Heleonix.Docfx.Plugins.XmlDoc/XmlDocProcessor.cs b/src/Heleonix.Docfx.Plugins.XmlDoc/XmlDocProcessor.cs index 32c9b70..de2a308 100644 --- a/src/Heleonix.Docfx.Plugins.XmlDoc/XmlDocProcessor.cs +++ b/src/Heleonix.Docfx.Plugins.XmlDoc/XmlDocProcessor.cs @@ -136,6 +136,11 @@ public FileModel Load(FileAndType file, ImmutableDictionary meta content[key] = value; } + if (PathUtility.IsRelativePath(fileMetadata.Xslt)) + { + content[FileMetadata.XsltKey] = Path.Combine(EnvironmentContext.BaseDirectory, fileMetadata.Xslt); + } + content[Constants.PropertyName.SystemKeys] = this.systemKeys; var localPathFromRoot = PathUtility.MakeRelativePath( diff --git a/test/Heleonix.Docfx.Plugins.XmlDoc.Tests/XmlDocProcessorTests.cs b/test/Heleonix.Docfx.Plugins.XmlDoc.Tests/XmlDocProcessorTests.cs index c56ce6e..2f5211b 100644 --- a/test/Heleonix.Docfx.Plugins.XmlDoc.Tests/XmlDocProcessorTests.cs +++ b/test/Heleonix.Docfx.Plugins.XmlDoc.Tests/XmlDocProcessorTests.cs @@ -201,6 +201,7 @@ public static void Load() { { "key1", 111 }, { "key2", 222 }, + { FileMetadata.XsltKey, "./relative/to/docfx-json/transform.xslt" }, }.ToImmutableDictionary(); }); @@ -217,6 +218,9 @@ public static void Load() Assert.That(content["key1"], Is.EqualTo(111)); Assert.That(content["key2"], Is.EqualTo(222)); + Assert.That( + content[FileMetadata.XsltKey], + Is.EqualTo(Path.Combine(EnvironmentContext.BaseDirectory, metadata[FileMetadata.XsltKey] as string))); Assert.That(content[Constants.PropertyName.SystemKeys], Has.Length.EqualTo(8));