Skip to content

Commit 5e0337b

Browse files
mjkkirschnerSHKnudsenRobertGlobant20aparajit-pratapQilongTang
authored
Add tests for Node Docs Generator (#11960)
* initial commit * Use CLRDLLModule * Refactoring * add hosts flag and other additions to frompackage * 🧹🧹 * Update Program.cs * clean up + handle overloads * 🧹 * Update AssemblyHandler.cs * too many things 🤯 * Save images instead of embedding * comment updates * add support for .ds files * comments + move to tools folder * add reference to RestSharp - need to create PackageUploadRequestBody * Update FromPackageFolderCommand.cs * 🧹 * Remove logger * remove unused using * Update FromDirectoryOptions.cs * Update AssemblyHandler.cs * Change project type + add test project * remove old files * use flag to specify ReflectionContext * few comment updates * Update DocumentationBrowserViewExtensionTests.cs * ds file fixes * fix add isReflection flag FFIMethodAtribute * First pass at comments * Update MarkdownHandler.cs * 2nd pass on comments * Update MarkdownHandler.cs * help text updates * update licence * comments * add reflection context object type check to CLRDLLModule * Use IconName to get the type FullName from a NodeModelSearchElement + other clean ups * get baseType with overloads * Load dynamo dlls from main bin folder + fix overload lookup * Update DocumentationBrowserViewExtensionTests.cs * fix issue with protogeometry format load error put clr into reflection mode when importing DS files fix classname for generated ds docs * remove unused * remove test project * unit tests first commit * Update Program.cs * comment cleanups * merge license (#31) Co-authored-by: michael kirschner <[email protected]> * move LayoutSpecification types to DynamoCore with type forward (#30) Co-authored-by: michael kirschner <[email protected]> * add new flag -g to compress gifs add gif compression by quantization to 32k colors in debug leave console open until readline for easy log reading * typo * try to resolve merge conflicts with dynamo master (#33) * Dyn 3817 exit tour window popup (#11918) * DYN-3817-ExitTourWindow Popup I added the UI for the Exit Tour Window, but still having some issues in the layout * DYN-3817-ExitTourWindow-Popup I created the view for the Exit Tour Window and also the functionality of showing the ExitTour ( this is shown only when one of the steps is closed so the tour is not finished - this doesn't apply for the Survey popup). A resource string was added and is related to the ExitTour content so it can be localized later. * DYN-3817-ExitTourWindow-Popup Removing code not needed in DynamoView.xaml.cs * DYN-3817-ExitTourWindow-Popup Code Review The ExitTourWindow was renamed to RealTimeInfoWindow. I reorganized the RealTimeInfoWindow so doesn't depend of a Step (then it can be used in a more generic way). I created the properties Width, Height and TextContent inside the RealTimeInfoWindow so they can be set up from outside. The TextContent property contains the text that will be shown in the popup and it can be updated on runtime. * DYN-3817-ExitTourWindow-Popup Code Issues Fixing issues produced after merging the latest changes in master branch * DYN-3817-ExitTourWindow-Popup Code Review 2 The offset hardcoded values were changed to const double, also I reorganized the way the RealTimeInfoWindow object is created. Also I added some comments in the xaml file * Dyn-3640 - Recover execution after clearing cyclic dependency from graph (#11896) * cleanup * minor cleanup * clear cycles from dependency graph nodes for graph runs * cleanup * update failing test * clear node warnings for cleared cycles * do not include cyclic graph node as a redefined node of another graph node * add unit tests * fix one more case * review comments * add logging to intermittent pkgloader tests (#11925) * update tests * update xml summary add some logging to failing tests Co-authored-by: michael kirschner <[email protected]> * pkg load test log typo (#11926) * update tests * update xml summary add some logging to failing tests * typo Co-authored-by: michael kirschner <[email protected]> * Update UI (#11932) * Update searchMethod invocation in LibraryMSWebBrowserExtension (#11931) * Update searchMethod invocation Update searchMethod invocation to use correct number of parameters * Update SearchDictionary.cs * Add adsk fonts to extern folder with license terms. (#11890) * small adjustment * align titles * add names to buttons for ui automation tests * missing button name * new font folder for use in Dynamo only * Update readme.md * add font links to about box Co-authored-by: michael kirschner <[email protected]> * check for null (#11930) * Prevent port measure crash (#11935) * CRASH: Delete node with right-click at the same time (#11927) * null checks * Add unit test * Fix For Loading Json File (#11934) * Fix For Loading Json File During the testing of the task https://jira.autodesk.com/browse/DYN-3817 Aabishkar reported that when trying to open the "Get Started" tour a message appear saying Could not find a part of the path 'C:\Windows\system32\UI\GuidedTour\dynamo_guides.json' Then I modified the code that is loading the json,file, in the past was a relative path and now we are using an absolute path. * Fix For Loading Json File Instead to have the json file path in the GuidesManager constructor I created two public properties that will contains the assembly path execution and the JSON files guides path, so we can verify in the unit testing that this paths exists and if the Guide will be created correctly. Also I added a unit test that will validate that the json guides file exists and that the Guides can be created. * Handle crash due to save path being too long Co-authored-by: Roberto T <[email protected]> Co-authored-by: aparajit-pratap <[email protected]> Co-authored-by: michael kirschner <[email protected]> Co-authored-by: Aaron (Qilong) <[email protected]> Co-authored-by: Ashish Aggarwal <[email protected]> * revert changes to clrdllmodule * this builds * remove reflection extensions * Update NodeConstructionTests.cs * add dyf folder exists check * update tests * Update NodeDocumentationMarkdownGeneratorTests.csproj * clean up * Update NodeConstructionTests.cs * resolve all reference paths remove metadata references * comments * add image magick to license files * change package in test * add readme * add known issues section * more readme tweaks * add verbose mode and some logging when scanning dlls add console colors for dictionary related errors update readme * add findings to known issues * merge fix * review comments move ilibraryviewcustomization as well to dynamocore * fix bug if package is missing bin folder fix bug naming custom node .md files with only category name add test dictionary and extract layout spec remove if node and add refactored if node to test files tests should resolve assemblies from tools bin folder and look for other dlls in core dynam bin output tests to bin folder, but not tool * set function type correcty for global functions set classname on generated .md files correctly on global functions add test for ds files * review comments * add image compression tests fix gif compression if resulting gif is larger than original. * add ref flag test ref flag should be optional * add tests for loading from fallback paths * generate more docs for assemblies in nodes folder * revert version * use mslib assembly instead of libview * try to cleanup hanging dialog from linter test Co-authored-by: SHKnudsen <[email protected]> Co-authored-by: michael kirschner <[email protected]> Co-authored-by: Roberto T <[email protected]> Co-authored-by: aparajit-pratap <[email protected]> Co-authored-by: Aaron (Qilong) <[email protected]> Co-authored-by: Ashish Aggarwal <[email protected]>
1 parent 50a24de commit 5e0337b

File tree

62 files changed

+5371
-41
lines changed

Some content is hidden

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

62 files changed

+5371
-41
lines changed

src/DocumentationBrowserViewExtension/PackageDocumentationManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ public class PackageDocumentationManager : IDisposable
2828
private const string VALID_DOC_FILEEXTENSION = "*.md";
2929
private const string FALLBACK_DOC_DIRECTORY_NAME = "fallback_docs";
3030
private static PackageDocumentationManager instance;
31-
private DirectoryInfo dynamoCoreFallbackDocPath;
32-
private DirectoryInfo hostDynamoFallbackDocPath;
31+
//these fields should only be directly set by tests.
32+
internal DirectoryInfo dynamoCoreFallbackDocPath;
33+
internal DirectoryInfo hostDynamoFallbackDocPath;
3334

3435
/// <summary>
3536
/// PackageDocManager singleton instance.

src/Dynamo.All.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LintingViewExtension", "Lin
243243
EndProject
244244
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodeDocumentationMarkdownGenerator", "Tools\NodeDocumentationMarkdownGenerator\NodeDocumentationMarkdownGenerator.csproj", "{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}"
245245
EndProject
246+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{C963F7A9-E210-41E0-80D5-E5A95C048ED2}"
247+
EndProject
248+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodeDocumentationMarkdownGeneratorTests", "..\test\Tools\NodeDocumentationMarkdownGeneratorTests\NodeDocumentationMarkdownGeneratorTests.csproj", "{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}"
249+
EndProject
246250
Global
247251
GlobalSection(SolutionConfigurationPlatforms) = preSolution
248252
Debug|Any CPU = Debug|Any CPU
@@ -899,6 +903,14 @@ Global
899903
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Release|Any CPU.Build.0 = Release|Any CPU
900904
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Release|x64.ActiveCfg = Release|Any CPU
901905
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Release|x64.Build.0 = Release|Any CPU
906+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
907+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}.Debug|Any CPU.Build.0 = Debug|Any CPU
908+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}.Debug|x64.ActiveCfg = Debug|Any CPU
909+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}.Debug|x64.Build.0 = Debug|Any CPU
910+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}.Release|Any CPU.ActiveCfg = Release|Any CPU
911+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}.Release|Any CPU.Build.0 = Release|Any CPU
912+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}.Release|x64.ActiveCfg = Release|Any CPU
913+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F}.Release|x64.Build.0 = Release|Any CPU
902914
EndGlobalSection
903915
GlobalSection(SolutionProperties) = preSolution
904916
HideSolutionNode = FALSE
@@ -979,6 +991,8 @@ Global
979991
{A42563F1-2B8B-4C4D-BFAD-2CA981524E00} = {88D45B00-E564-41DB-B57C-9509646CAA49}
980992
{C86F9058-229D-40A9-95D5-D6F081AA9230} = {88D45B00-E564-41DB-B57C-9509646CAA49}
981993
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B} = {D114C59C-CF66-4CC2-980F-9301FB4EA4E1}
994+
{C963F7A9-E210-41E0-80D5-E5A95C048ED2} = {F4D44BC0-32CF-4E58-AD2A-F19CE1450B00}
995+
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F} = {C963F7A9-E210-41E0-80D5-E5A95C048ED2}
982996
EndGlobalSection
983997
GlobalSection(ExtensibilityGlobals) = postSolution
984998
SolutionGuid = {89CB19C6-BF0A-4E6A-BFDA-79D143EAB59D}

src/Tools/NodeDocumentationMarkdownGenerator/AssemblyHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private static bool TryGetFunctionDescriptor(
342342

343343
private static FunctionDescriptorParams FunctionParamsFromFunction(FunctionDefinitionNode funcDefinitionNode, string location, string className)
344344
{
345-
FunctionType type;
345+
FunctionType type = FunctionType.GenericFunction;
346346
var name = funcDefinitionNode.Name;
347347

348348
if (CoreUtils.IsGetter(name))
@@ -363,13 +363,14 @@ private static FunctionDescriptorParams FunctionParamsFromFunction(FunctionDefin
363363
{
364364
type = FunctionType.StaticMethod;
365365
}
366-
else
366+
else if (!string.IsNullOrEmpty(className))
367367
{
368368
type = FunctionType.InstanceMethod;
369369
}
370370
}
371371

372372

373+
373374
var functionParams = new FunctionDescriptorParams
374375
{
375376
Assembly = location,

src/Tools/NodeDocumentationMarkdownGenerator/Commands/FromDirectoryCommand.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ private static List<MdFileInfo> ScanFolderForAssemblies(string inputFolderPath,
4949
.Select(x => x.FirstOrDefault());
5050

5151

52-
var referenceDllPaths = referencePaths
52+
var referenceDllPaths = new List<string>();
53+
if(referencePaths != null)
54+
{
55+
referenceDllPaths = referencePaths
5356
.SelectMany(p => new DirectoryInfo(p)
5457
.EnumerateFiles("*.dll", SearchOption.AllDirectories)
5558
.Select(d => d.FullName)
56-
.Distinct());
57-
59+
.Distinct()).ToList();
60+
}
5861

5962
if (filter.Any())
6063
{

src/Tools/NodeDocumentationMarkdownGenerator/Commands/FromPackageFolderCommand.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,30 @@ internal static void HandlePackageDocumentation(FromPackageOptions opts)
3333

3434
private static List<MdFileInfo> ScanNodeLibraries(Package pkg, IEnumerable<string> hostPaths)
3535
{
36+
var addtionalPathsToLoad = new List<string>();
37+
var nodeLibraryPaths = new List<string>();
38+
var hostDllPaths = new List<string>();
39+
if (Directory.Exists(pkg.BinaryDirectory))
40+
{
3641
var binDlls = new DirectoryInfo(pkg.BinaryDirectory)
3742
.EnumerateFiles("*.dll")
3843
.ToList();
3944

40-
var nodeLibraryPaths = binDlls
45+
nodeLibraryPaths = binDlls
4146
.Where(x => pkg.Header.node_libraries.Contains(AssemblyName.GetAssemblyName(x.FullName).FullName))
4247
.Select(x => x.FullName)
4348
.ToList();
4449

45-
var addtionalPathsToLoad = binDlls.Select(x => x.FullName).Except(nodeLibraryPaths).ToList();
46-
47-
var hostDllPaths = hostPaths
50+
addtionalPathsToLoad = binDlls.Select(x => x.FullName).Except(nodeLibraryPaths).ToList();
51+
}
52+
if (hostPaths != null)
53+
{
54+
hostDllPaths = hostPaths
4855
.SelectMany(p => new DirectoryInfo(p)
4956
.EnumerateFiles("*.dll", SearchOption.AllDirectories)
50-
.Select(d => d.FullName)
51-
.ToList());
57+
.Select(d => d.FullName)).ToList();
58+
}
59+
5260

5361
addtionalPathsToLoad.AddRange(hostDllPaths);
5462

src/Tools/NodeDocumentationMarkdownGenerator/MarkdownHandler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ private static bool TrySaveImage(
215215
m.Position = 0;
216216
m.SetLength(0);
217217
images.Write(m);
218+
//in the case where gif compression fails to create a gif that is smaller
219+
//fallback to the old image stream.
220+
if(m.Length > oldSize){
221+
m.Position = 0;
222+
m.SetLength(0);
223+
image.Save(m, image.RawFormat);
224+
}
218225
}
219226
}
220227

src/Tools/NodeDocumentationMarkdownGenerator/MdFileInfo.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ internal static MdFileInfo FromCustomNode(string path)
8888
var nodeName = header.Name;
8989
var nodeNamspace = header.Category;
9090
var fullCategory = $"{header.Category}.{header.Name}";
91-
return new MdFileInfo(nodeName, nodeNamspace, fullCategory, header.Category, nodeNamspace);
91+
return new MdFileInfo(nodeName, nodeNamspace, fullCategory, header.Category, fullCategory);
9292
}
9393

9494
internal static bool TryGetMdFileInfoFromSearchEntry(NodeSearchElement entry, out MdFileInfo info)
@@ -113,7 +113,11 @@ internal static bool TryGetMdFileInfoFromSearchEntry(NodeSearchElement entry, ou
113113
// Create the filename from the nodes className + nodeName
114114
// We need the filename to be structured like this as this is
115115
// how Dynamo matches the file with the correct node.
116-
fileName = $"{searchElement.Descriptor.ClassName}.{nodeName}";
116+
117+
//if this type is really a global ds function - classname will be null.
118+
var classNameEmpty = string.IsNullOrEmpty(searchElement.Descriptor.ClassName);
119+
var seperator = classNameEmpty ? string.Empty : ".";
120+
fileName = $"{searchElement.Descriptor.ClassName}{seperator}{nodeName}";
117121
}
118122
else
119123
{

src/Tools/NodeDocumentationMarkdownGenerator/Program.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,40 @@ namespace NodeDocumentationMarkdownGenerator
1111
{
1212
class Program
1313
{
14-
internal static IEnumerable<FileInfo> DynamoDirectoryAssemblyPaths;
1514
internal static List<String> ReferenceAssemblyPaths = new List<string>();
1615
internal static bool VerboseMode { get; set; }
17-
static void Main(string[] args)
16+
private static IEnumerable<FileInfo> dynamoDirectoryAssemblyPaths;
17+
internal static IEnumerable<FileInfo> DynamoDirectoryAssemblyPaths
1818
{
19+
get
20+
{
21+
22+
if (dynamoDirectoryAssemblyPaths is null)
23+
{
1924
#if DEBUG
2025
var config = "Debug";
2126
#else
2227
var config = "Release";
2328
#endif
2429
var relativePathToDynamo = $@"..\..\..\..\..\bin\AnyCPU\{config}";
2530
Console.WriteLine($"looking for dynamo core assemblies in {relativePathToDynamo}");
26-
27-
var sw = new Stopwatch();
28-
sw.Start();
29-
Program.DynamoDirectoryAssemblyPaths = new DirectoryInfo(
31+
dynamoDirectoryAssemblyPaths = new DirectoryInfo(
3032
Path.GetFullPath(
3133
Path.Combine(
3234
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), relativePathToDynamo)))
3335
.EnumerateFiles("*.dll", SearchOption.AllDirectories);
36+
}
37+
38+
return dynamoDirectoryAssemblyPaths;
39+
}
40+
}
41+
42+
internal static void Main(string[] args)
43+
{
44+
var sw = new Stopwatch();
45+
sw.Start();
46+
47+
3448

3549
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
3650

@@ -48,7 +62,7 @@ static void Main(string[] args)
4862
#endif
4963
}
5064

51-
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
65+
internal static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
5266
{
5367
var requestedAssembly = new AssemblyName(args.Name);
5468
//concat both dynamocore paths and any reference paths the user added.

test/DynamoCoreWpfTests/CoreUITests.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -910,12 +910,10 @@ public void WarningShowsWhenSavingWithLinterWarningsOrErrors()
910910
// Arrange
911911
var expectedWindowTitle = WpfResources.GraphIssuesOnSave_Title;
912912
var recivedEvents = new List<string>();
913-
914-
ViewModel.SaveWarningOnUnresolvedIssuesShows += delegate (SaveWarningOnUnresolvedIssuesArgs e)
915-
{
916-
recivedEvents.Add(e.TaskDialog.Title);
917-
};
918-
913+
var savewarnHandler = new Action<SaveWarningOnUnresolvedIssuesArgs>((e) => { recivedEvents.Add(e.TaskDialog.Title); e.TaskDialog.Close(); });
914+
ViewModel.SaveWarningOnUnresolvedIssuesShows += savewarnHandler;
915+
916+
919917
Mock<LinterExtensionBase> mockLinter = new Mock<LinterExtensionBase>() { CallBase = true };
920918
SetupMockLinter(mockLinter);
921919

@@ -944,9 +942,13 @@ public void WarningShowsWhenSavingWithLinterWarningsOrErrors()
944942

945943
// Assert
946944
Assert.That(recivedEvents.Count == 1);
947-
Assert.That(recivedEvents.First() == expectedWindowTitle);
945+
Assert.That(recivedEvents.First() == expectedWindowTitle);
946+
ViewModel.SaveWarningOnUnresolvedIssuesShows -= savewarnHandler;
947+
948948
}
949949

950+
951+
950952
private void SetupMockLinter(Mock<LinterExtensionBase> mockLinter)
951953
{
952954
const string MOCK_LINTER_GUID = "358321af-2633-4697-b475-81632582eba0";

test/DynamoCoreWpfTests/ViewExtensions/DocumentationBrowserViewExtensionTests.cs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ protected override DynamoModel.IStartConfiguration CreateStartConfiguration(IPat
4747
Preferences = new PreferenceSettings() { CustomPackageFolders = new List<string>() { this.PackagesDirectory } }
4848
};
4949
}
50+
protected override void GetLibrariesToPreload(List<string> libraries)
51+
{
52+
libraries.Add("VMDataBridge.dll");
53+
libraries.Add("Builtin.ds");
54+
libraries.Add("FunctionObject.ds");
55+
libraries.Add("DSCoreNodes.dll");
56+
base.GetLibrariesToPreload(libraries);
57+
}
5058

5159
[Test]
5260
public void DocsExtensionAddsMenuItem()
@@ -540,6 +548,118 @@ public void CanGetNodeDocumentationMarkdownFromPackageDocumentationManager()
540548
Assert.That(!PackageDocumentationManager.Instance.ContainsAnnotationDoc(Path.Combine(packageName, nodeWithoutDocumentation)));
541549
}
542550

551+
[Test]
552+
public void DocsCanBeLoadedForDSNonPackageNodesFrom_FallBackPath()
553+
{
554+
//setup the docs browser to point to our fake fallback folder.
555+
var testFallbackDocsPath = Path.Combine(GetTestDirectory(this.ExecutingDirectory), "Tools", "docGeneratorTestFiles", "fallback_docs");
556+
PackageDocumentationManager.Instance.dynamoCoreFallbackDocPath = new DirectoryInfo(testFallbackDocsPath);
557+
558+
//make a request for a node we've generated docs for
559+
RaiseLoadedEvent(this.View);
560+
561+
var nodeName = "List.Rank";
562+
this.ViewModel.ExecuteCommand(
563+
new DynamoModel.CreateNodeCommand(
564+
Guid.NewGuid().ToString(), nodeName, 0, 0, false, false)
565+
);
566+
var node = this.ViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault();
567+
var htmlContent = RequestNodeDocs(node);
568+
569+
Assert.IsTrue(htmlContent.Contains("list.rank sample docs"));
570+
571+
ViewModel.Model.CurrentWorkspace.RemoveAndDisposeNode(node);
572+
573+
//next node
574+
nodeName = "LoopWhile";
575+
this.ViewModel.ExecuteCommand(
576+
new DynamoModel.CreateNodeCommand(
577+
Guid.NewGuid().ToString(), nodeName, 0, 0, false, false)
578+
);
579+
node = this.ViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault();
580+
htmlContent = RequestNodeDocs(node);
581+
582+
Assert.IsTrue(htmlContent.Contains("loopwhile sample docs"));
583+
}
584+
[Test]
585+
public void DocsAreLoadedFromHostPathBeforeCorePath()
586+
{
587+
//setup the docs browser to point to our fake fallback folder.
588+
var testFallbackDocsPath = Path.Combine(GetTestDirectory(this.ExecutingDirectory), "Tools", "docGeneratorTestFiles", "fallback_docs");
589+
var testHostFallbackDocsPath = Path.Combine(GetTestDirectory(this.ExecutingDirectory), "Tools", "docGeneratorTestFiles", "host_fallback_docs");
590+
591+
PackageDocumentationManager.Instance.dynamoCoreFallbackDocPath = new DirectoryInfo(testFallbackDocsPath);
592+
PackageDocumentationManager.Instance.hostDynamoFallbackDocPath = new DirectoryInfo(testHostFallbackDocsPath);
593+
594+
//make a request for a node we've generated docs for
595+
RaiseLoadedEvent(this.View);
596+
597+
var nodeName = "List.Rank";
598+
this.ViewModel.ExecuteCommand(
599+
new DynamoModel.CreateNodeCommand(
600+
Guid.NewGuid().ToString(), nodeName, 0, 0, false, false)
601+
);
602+
var node = this.ViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault();
603+
var htmlContent = RequestNodeDocs(node);
604+
605+
Assert.IsTrue(htmlContent.Contains("list.rank sample docs from host path"));
606+
}
607+
608+
[Test]
609+
public void DocsCanBeLoadedForCoreNodeModelNodesFrom_FallBackPath()
610+
{
611+
//setup the docs browser to point to our fake fallback folder.
612+
var testFallbackDocsPath = Path.Combine(GetTestDirectory(this.ExecutingDirectory), "Tools", "docGeneratorTestFiles", "fallback_docs");
613+
PackageDocumentationManager.Instance.dynamoCoreFallbackDocPath = new DirectoryInfo(testFallbackDocsPath);
614+
615+
//make a request for a node we've generated docs for
616+
RaiseLoadedEvent(this.View);
617+
618+
var nodeName = "CoreNodeModels.Watch";
619+
this.ViewModel.ExecuteCommand(
620+
new DynamoModel.CreateNodeCommand(
621+
Guid.NewGuid().ToString(), nodeName, 0, 0, false, false)
622+
);
623+
var node = this.ViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault();
624+
var htmlContent = RequestNodeDocs(node);
625+
626+
Assert.IsTrue(htmlContent.Contains("corenodemodels.watch sample docs"));
627+
628+
ViewModel.Model.CurrentWorkspace.RemoveAndDisposeNode(node);
629+
630+
//next node
631+
nodeName = "CoreNodeModels.Logic.RefactoredIf";
632+
this.ViewModel.ExecuteCommand(
633+
new DynamoModel.CreateNodeCommand(
634+
Guid.NewGuid().ToString(), nodeName, 0, 0, false, false)
635+
);
636+
node = this.ViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault();
637+
htmlContent = RequestNodeDocs(node);
638+
639+
Assert.IsTrue(htmlContent.Contains("corenodemodels.logic.refactoredif sample docs"));
640+
641+
ViewModel.Model.CurrentWorkspace.RemoveAndDisposeNode(node);
642+
643+
//next node
644+
nodeName = "CoreNodeModels.HigherOrder.Map";
645+
this.ViewModel.ExecuteCommand(
646+
new DynamoModel.CreateNodeCommand(
647+
Guid.NewGuid().ToString(), nodeName, 0, 0, false, false)
648+
);
649+
node = this.ViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault();
650+
htmlContent = RequestNodeDocs(node);
651+
652+
Assert.IsTrue(htmlContent.Contains("corenodemodels.higherorder.map sample docs"));
653+
}
654+
655+
private string RequestNodeDocs(Dynamo.Graph.Nodes.NodeModel node)
656+
{
657+
var docBrowserviewExtension = this.View.viewExtensionManager.ViewExtensions.OfType<DocumentationBrowserViewExtension>().FirstOrDefault();
658+
var nodeAnnotationEventArgs = new OpenNodeAnnotationEventArgs(node, this.ViewModel);
659+
docBrowserviewExtension.HandleRequestOpenDocumentationLink(nodeAnnotationEventArgs);
660+
return GetSidebarDocsBrowserContents();
661+
}
662+
543663
#region Helpers
544664

545665
private DocumentationBrowserViewExtension SetupNewViewExtension(bool runLoadedMethod = false)

0 commit comments

Comments
 (0)