Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f9093e4
initial commit
SHKnudsen Apr 14, 2021
354e682
Use CLRDLLModule
SHKnudsen Apr 27, 2021
3dd5ad4
Refactoring
SHKnudsen Apr 29, 2021
05f5984
add hosts flag and other additions to frompackage
SHKnudsen Apr 30, 2021
d7fab57
🧹🧹
SHKnudsen Apr 30, 2021
f3c2bd0
Update Program.cs
SHKnudsen Apr 30, 2021
bf971d0
clean up + handle overloads
SHKnudsen May 11, 2021
e5ea6c2
🧹
SHKnudsen May 11, 2021
70bf7c3
Update AssemblyHandler.cs
SHKnudsen May 11, 2021
67353b4
too many things 🤯
SHKnudsen May 24, 2021
999a0b5
Save images instead of embedding
SHKnudsen May 24, 2021
f8c13eb
comment updates
SHKnudsen May 25, 2021
7548c79
add support for .ds files
SHKnudsen May 26, 2021
97d29e4
comments + move to tools folder
SHKnudsen May 30, 2021
7599dfb
add reference to RestSharp - need to create PackageUploadRequestBody
SHKnudsen Jun 2, 2021
f1f5df5
Update FromPackageFolderCommand.cs
SHKnudsen Jun 2, 2021
a7b1542
Merge remote-tracking branch 'upstream/master' into Node-Markdown-gen…
SHKnudsen Jun 2, 2021
cc9705e
🧹
SHKnudsen Jun 2, 2021
3cc3667
Remove logger
SHKnudsen Jun 3, 2021
e372af6
remove unused using
SHKnudsen Jun 3, 2021
62009d5
Update FromDirectoryOptions.cs
SHKnudsen Jun 3, 2021
b3443ed
Update AssemblyHandler.cs
SHKnudsen Jun 7, 2021
f9a5627
Change project type + add test project
SHKnudsen Jun 7, 2021
6772242
remove old files
SHKnudsen Jun 7, 2021
6328716
use flag to specify ReflectionContext
SHKnudsen Jun 8, 2021
e2e3789
Merge remote-tracking branch 'upstream/master' into Node-Markdown-gen…
SHKnudsen Jun 8, 2021
9590d1a
few comment updates
SHKnudsen Jun 8, 2021
dbe0a36
Update DocumentationBrowserViewExtensionTests.cs
SHKnudsen Jun 9, 2021
87fc191
ds file fixes
SHKnudsen Jun 10, 2021
2742147
fix add isReflection flag FFIMethodAtribute
SHKnudsen Jun 10, 2021
f72a3ef
First pass at comments
SHKnudsen Jun 14, 2021
6c2d726
Update MarkdownHandler.cs
SHKnudsen Jun 14, 2021
1383b06
2nd pass on comments
SHKnudsen Jun 18, 2021
8002f35
Update MarkdownHandler.cs
SHKnudsen Jun 18, 2021
a427e28
help text updates
SHKnudsen Jun 22, 2021
4a10ed3
update licence
SHKnudsen Jun 28, 2021
26b00dd
comments
SHKnudsen Jun 28, 2021
aa38bcd
add reflection context object type check to CLRDLLModule
SHKnudsen Jul 1, 2021
bd8112a
Use IconName to get the type FullName from a NodeModelSearchElement +…
SHKnudsen Jul 1, 2021
a7bd10c
get baseType with overloads
SHKnudsen Jul 5, 2021
b65a2fd
Load dynamo dlls from main bin folder + fix overload lookup
SHKnudsen Jul 11, 2021
a0c1eb2
Merge remote-tracking branch 'upstream/master' into Node-Markdown-gen…
SHKnudsen Jul 11, 2021
5559e8b
Update DocumentationBrowserViewExtensionTests.cs
SHKnudsen Jul 11, 2021
1138c92
fix issue with protogeometry format load error
mjkkirschner Jul 13, 2021
d9b74e1
remove unused
mjkkirschner Jul 13, 2021
259f870
Merge pull request #25 from mjkkirschner/nmgt_mjk
SHKnudsen Jul 19, 2021
2b24e18
remove test project
SHKnudsen Jul 19, 2021
18aa5b9
Merge branch 'master' into Node-Markdown-generator-tool
mjkkirschner Aug 9, 2021
2cec9a2
comment cleanups
SHKnudsen Aug 12, 2021
0131c59
merge license (#31)
mjkkirschner Aug 16, 2021
c0c0632
move LayoutSpecification types to DynamoCore with type forward (#30)
mjkkirschner Aug 16, 2021
c76af1c
add new flag -g to compress gifs
mjkkirschner Aug 16, 2021
35ef80d
typo
mjkkirschner Aug 16, 2021
b2929ff
try to resolve merge conflicts with dynamo master (#33)
mjkkirschner Aug 17, 2021
2a223fb
Merge branch 'master' into Node-Markdown-generator-tool
mjkkirschner Aug 17, 2021
9d88dd2
Merge pull request #32 from mjkkirschner/nmdg-imagecompgif
SHKnudsen Aug 18, 2021
15cb6e6
add dyf folder exists check
SHKnudsen Aug 18, 2021
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
4 changes: 4 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ https://opensource.org/licenses/lgpl-2.1.php
### CEFSharp
https://github.com/cefsharp/CefSharp/blob/master/LICENSE

### Command Line Parser
https://github.com/commandlineparser/commandline
(MIT license)

### CSharpAnalytics
https://github.com/AttackPattern/CSharpAnalytics
http://www.apache.org/licenses/LICENSE-2.0
Expand Down
362 changes: 188 additions & 174 deletions doc/distrib/License.rtf

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ internal void OnMessageLogged(ILogMessage msg)
public override void Startup(ViewStartupParams viewStartupParams)
{
pmExtension = viewStartupParams.ExtensionManager.Extensions.OfType<PackageManagerExtension>().FirstOrDefault();
PackageDocumentationManager.Instance.AddDynamoPaths(viewStartupParams.PathManager);
}

public override void Loaded(ViewLoadedParams viewLoadedParams)
{
if (viewLoadedParams == null) throw new ArgumentNullException(nameof(viewLoadedParams));

this.ViewModel.MessageLogged += OnViewModelMessageLogged;
PackageDocumentationManager.Instance.MessageLogged += OnMessageLogged;

this.viewLoadedParamsReference = viewLoadedParams;

Expand All @@ -84,19 +86,19 @@ public override void Loaded(ViewLoadedParams viewLoadedParams)

// subscribe to package loaded so we can add the package documentation
// to the Package documentation manager when a package is loaded
pmExtension.PackageLoader.PackgeLoaded += OnPackgeLoaded;
pmExtension.PackageLoader.PackgeLoaded += OnPackageLoaded;

// add packages already loaded to the PackageDocumentationManager
foreach (var pkg in pmExtension.PackageLoader.LocalPackages)
{
OnPackgeLoaded(pkg);
OnPackageLoaded(pkg);
}
}

private void OnPackgeLoaded(Package pkg)
private void OnPackageLoaded(Package pkg)
{
// Add documentation files from the package to the DocManager
PackageDocumentationManager.Instance.AddPackageDocumentation(pkg.NodeDocumentaionDirectory);
PackageDocumentationManager.Instance.AddPackageDocumentation(pkg.NodeDocumentaionDirectory, pkg.Name);
}

private void MenuItemUnCheckedHandler(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -139,7 +141,7 @@ protected virtual void Dispose(bool disposing)

if (this.pmExtension != null)
{
this.pmExtension.PackageLoader.PackgeLoaded -= OnPackgeLoaded;
this.pmExtension.PackageLoader.PackgeLoaded -= OnPackageLoaded;
}
PackageDocumentationManager.Instance.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ private void HandleLocalResource(OpenDocumentationLinkEventArgs e)
switch (e)
{
case OpenNodeAnnotationEventArgs openNodeAnnotationEventArgs:
var mdLink = packageManagerDoc.GetAnnotationDoc(openNodeAnnotationEventArgs.MinimumQualifiedName);
var mdLink = packageManagerDoc.GetAnnotationDoc(
openNodeAnnotationEventArgs.MinimumQualifiedName,
openNodeAnnotationEventArgs.PackageName);

link = string.IsNullOrEmpty(mdLink) ? new Uri(String.Empty, UriKind.Relative) : new Uri(mdLink);
targetContent = CreateNodeAnnotationContent(openNodeAnnotationEventArgs);

break;

case OpenDocumentationLinkEventArgs openDocumentationLink:
Expand Down Expand Up @@ -254,7 +256,7 @@ private string CreateNodeAnnotationContent(OpenNodeAnnotationEventArgs e)
writer.WriteLine(nodeDocumentation);

// Convert the markdown file to html
MarkdownHandlerInstance.ParseToHtml(ref writer, e.MinimumQualifiedName);
MarkdownHandlerInstance.ParseToHtml(ref writer, e.MinimumQualifiedName, e.PackageName);

writer.Flush();
var output = writer.ToString();
Expand Down
4 changes: 2 additions & 2 deletions src/DocumentationBrowserViewExtension/MarkdownHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public void Dispose()
/// </summary>
/// <param name="writer"></param>
/// <param name="nodeNamespace"></param>
internal void ParseToHtml(ref StringWriter writer, string nodeNamespace)
internal void ParseToHtml(ref StringWriter writer, string nodeNamespace, string packageName)
{
if (writer is null)
throw new ArgumentNullException(nameof(writer));

var mdFilePath = PackageDocumentationManager.Instance.GetAnnotationDoc(nodeNamespace);
var mdFilePath = PackageDocumentationManager.Instance.GetAnnotationDoc(nodeNamespace, packageName);

string mdString;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Dynamo.Interfaces;
using Dynamo.Logging;

namespace Dynamo.DocumentationBrowser
{
Expand All @@ -18,14 +21,18 @@ public class PackageDocumentationManager : IDisposable
/// key: node namespace - value: file path to markdown file.
/// </summary>
private Dictionary<string, string> nodeDocumentationFileLookup = new Dictionary<string, string>();

/// <summary>
/// Dictionary to keep track of each FileSystemWatcher created for the package node annotation directory path
/// key: directory path - value: FileSystemWatcher
/// </summary>
private Dictionary<string, FileSystemWatcher> markdownFileWatchers = new Dictionary<string, FileSystemWatcher>();

private const string fileExtension = "*.md";
private const string VALID_DOC_FILEEXTENSION = "*.md";
private const string FALLBACK_DOC_DIRECTORY_NAME = "fallback_docs";
private static PackageDocumentationManager instance;
private DirectoryInfo dynamoCoreFallbackDocPath;
private DirectoryInfo hostDynamoFallbackDocPath;

/// <summary>
/// PackageDocManager singleton instance.
Expand All @@ -39,17 +46,64 @@ public static PackageDocumentationManager Instance
}
}

internal Action<ILogMessage> MessageLogged;

/// <summary>
/// Uses the path manager to set the fallback_doc path for DynamoCore and any Host running
/// </summary>
/// <param name="pathManager"></param>
internal void AddDynamoPaths(IPathManager pathManager)
{
if (pathManager is null)
{
return;
}

if (!string.IsNullOrEmpty(pathManager.DynamoCoreDirectory))
{
var coreDir = new DirectoryInfo(Path.Combine(pathManager.DynamoCoreDirectory, FALLBACK_DOC_DIRECTORY_NAME));
dynamoCoreFallbackDocPath = coreDir.Exists ? coreDir : null;
}

if (!string.IsNullOrEmpty(pathManager.HostApplicationDirectory))
{
var hostDir = new DirectoryInfo(Path.Combine(pathManager.HostApplicationDirectory, FALLBACK_DOC_DIRECTORY_NAME));
hostDynamoFallbackDocPath = hostDir.Exists ? hostDir : null;
}
}

private PackageDocumentationManager() { }

/// <summary>
/// Retrieves the markdown node documentation file associated with the input node namespace
/// </summary>
/// <param name="nodeNamespace">Namespace of the node to lookup documentation for</param>
/// <returns></returns>
public string GetAnnotationDoc(string nodeNamespace)
public string GetAnnotationDoc(string nodeNamespace, string packageName)
{
nodeDocumentationFileLookup.TryGetValue(nodeNamespace, out string output);
return output;
if(nodeDocumentationFileLookup
.TryGetValue(Path.Combine(packageName, nodeNamespace),
out string output))
{
return output;
}

FileInfo matchingDoc = null;
if (hostDynamoFallbackDocPath != null)
{
matchingDoc = hostDynamoFallbackDocPath.GetFiles($"{nodeNamespace}.md").FirstOrDefault();
if (matchingDoc != null)
{
return matchingDoc.FullName;
}
}

if (dynamoCoreFallbackDocPath != null)
{
matchingDoc = dynamoCoreFallbackDocPath.GetFiles($"{nodeNamespace}.md").FirstOrDefault();
}

return matchingDoc is null ? string.Empty : matchingDoc.FullName;
}

/// <summary>
Expand All @@ -67,7 +121,7 @@ public bool ContainsAnnotationDoc(string nodeNamespace)
/// Note this only works for Markdown files.
/// </summary>
/// <param name="package"></param>
internal void AddPackageDocumentation(string packageDocumentationPath)
internal void AddPackageDocumentation(string packageDocumentationPath, string packageName)
{
if (string.IsNullOrWhiteSpace(packageDocumentationPath))
return;
Expand All @@ -77,27 +131,34 @@ internal void AddPackageDocumentation(string packageDocumentationPath)
return;

MonitorDirectory(directoryInfo);
var files = directoryInfo.GetFiles(fileExtension, SearchOption.AllDirectories);
TrackDocumentationFiles(files);
var files = directoryInfo.GetFiles(VALID_DOC_FILEEXTENSION, SearchOption.AllDirectories);
TrackDocumentationFiles(files, packageName);
}

private void MonitorDirectory(DirectoryInfo directoryInfo)
{
if (markdownFileWatchers.ContainsKey(directoryInfo.FullName))
return;

var watcher = new FileSystemWatcher(directoryInfo.FullName, fileExtension) { EnableRaisingEvents = true };
var watcher = new FileSystemWatcher(directoryInfo.FullName, VALID_DOC_FILEEXTENSION) { EnableRaisingEvents = true };
watcher.Renamed += OnFileRenamed;
watcher.Deleted += OnFileDeleted;
watcher.Created += OnFileCreated;
markdownFileWatchers.Add(watcher.Path, watcher);
}

private void TrackDocumentationFiles(FileInfo[] files)
private void TrackDocumentationFiles(FileInfo[] files, string packageName)
{
foreach (var file in files)
{
nodeDocumentationFileLookup.Add(Path.GetFileNameWithoutExtension(file.Name), file.FullName);
try
{
nodeDocumentationFileLookup.Add(Path.Combine(packageName,Path.GetFileNameWithoutExtension(file.Name)), file.FullName);
}
catch (Exception e)
{
LogWarning(e.Message, WarningLevel.Error);
}
}
}

Expand All @@ -110,20 +171,28 @@ private void OnFileDeleted(object sender, FileSystemEventArgs e)
{
var fileName = Path.GetFileNameWithoutExtension(e.Name);
if (nodeDocumentationFileLookup.ContainsKey(fileName))
{
nodeDocumentationFileLookup.Remove(fileName);
}
}

private void OnFileRenamed(object sender, RenamedEventArgs e)
{
var oldFileName = Path.GetFileNameWithoutExtension(e.OldName);
if (nodeDocumentationFileLookup.ContainsKey(oldFileName))
{
nodeDocumentationFileLookup.Remove(oldFileName);
}

var newFileName = Path.GetFileNameWithoutExtension(e.Name);
if (!nodeDocumentationFileLookup.ContainsKey(newFileName))
{
nodeDocumentationFileLookup.Add(newFileName, e.FullPath);
}
}

private void LogWarning(string msg, WarningLevel level) => this.MessageLogged?.Invoke(LogMessage.Warning(msg, level));

public void Dispose()
{
foreach (var watcher in markdownFileWatchers.Values)
Expand Down
11 changes: 11 additions & 0 deletions src/Dynamo.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphMetadataViewExtension"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LintingViewExtension", "LintingViewExtension\LintingViewExtension.csproj", "{C86F9058-229D-40A9-95D5-D6F081AA9230}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodeDocumentationMarkdownGenerator", "Tools\NodeDocumentationMarkdownGenerator\NodeDocumentationMarkdownGenerator.csproj", "{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -889,6 +891,14 @@ Global
{C86F9058-229D-40A9-95D5-D6F081AA9230}.Release|Any CPU.Build.0 = Release|Any CPU
{C86F9058-229D-40A9-95D5-D6F081AA9230}.Release|x64.ActiveCfg = Release|x64
{C86F9058-229D-40A9-95D5-D6F081AA9230}.Release|x64.Build.0 = Release|x64
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Debug|x64.ActiveCfg = Debug|Any CPU
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Debug|x64.Build.0 = Debug|Any CPU
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Release|Any CPU.Build.0 = Release|Any CPU
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Release|x64.ActiveCfg = Release|Any CPU
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -968,6 +978,7 @@ Global
{0893F745-CB1A-427A-8E87-CA927273039A} = {D114C59C-CF66-4CC2-980F-9301FB4EA4E1}
{A42563F1-2B8B-4C4D-BFAD-2CA981524E00} = {88D45B00-E564-41DB-B57C-9509646CAA49}
{C86F9058-229D-40A9-95D5-D6F081AA9230} = {88D45B00-E564-41DB-B57C-9509646CAA49}
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B} = {D114C59C-CF66-4CC2-980F-9301FB4EA4E1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {89CB19C6-BF0A-4E6A-BFDA-79D143EAB59D}
Expand Down
1 change: 0 additions & 1 deletion src/DynamoCLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ static internal void Main(string[] args)
}
var runner = new CommandLineRunner(model);
runner.Run(cmdLineArgs);

}
catch (Exception e)
{
Expand Down
33 changes: 33 additions & 0 deletions src/DynamoCore/Core/NodeModelAssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,39 @@ internal static IEnumerable<Type> GetCustomizationTypesUsingReflection(Assembly
return output;
}

internal static bool ContainsNodeModelSubTypeReflectionLoaded(Assembly assem, Type nodeModelType = null)
{
if(nodeModelType is null)
return assem.GetTypes().Any(x => IsNodeSubType(x));

return assem.GetTypes().Any(x => IsNodeSubTypeReflectionLoaded(x, nodeModelType));
}

/// <summary>
/// Similar to IsNodeSubType this will determine if a Type is a node.
/// This implementation is meant to be used when scanning types in ReflectionContext.
/// </summary>
/// <param name="t">Type to check</param>
/// <param name="nodeModelType">Type of NodeModel, this is needed to be sure we are comparing the same NodeModel type reference</param>
/// <returns></returns>
internal static bool IsNodeSubTypeReflectionLoaded(Type t, Type nodeModelType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the name of this method mean? Can we rename it to have a simpler meaning?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this method is truly necessary, looks like there could be room to get rid of some code duplication between this and the IsNodeSubType method.

{
bool isNodeSubType = false;
try
{
isNodeSubType = !t.IsAbstract &&
t.IsSubclassOf(nodeModelType) &&
t.GetConstructor(Type.EmptyTypes) != null;
}
catch(Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}

return isNodeSubType;
}

/// <summary>
/// Enumerate the types in an assembly and add them to DynamoController's
/// dictionaries and the search view model. Internally catches exceptions and sends the error
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCore/DynamoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ limitations under the License.
<Compile Include="Graph\Workspaces\SerializationExtensions.cs" />
<Compile Include="Graph\Workspaces\UndoRedo.cs" />
<Compile Include="Extensions\IServiceManager.cs" />
<Compile Include="Interfaces\LayoutSpecification.cs" />
<Compile Include="Linting\Interfaces\RuleEvaluationStatusEnum.cs" />
<Compile Include="Linting\Interfaces\IRuleEvaluationResult.cs" />
<Compile Include="Linting\Interfaces\SeverityCodesEnum.cs" />
Expand Down
Loading