Skip to content

Conversation

@SHKnudsen
Copy link
Contributor

@SHKnudsen SHKnudsen commented Jun 2, 2021

Purpose

This pr adds a new NodeDocumentationGenerator tool to automatically generate node documentation markdown files, the tool creates markdown files which (if specified) will have content from the DynamoDictionary added. The tool has two different verbs one that creates documentation from dlls in a directory, this can be used to create docs for Dynamo Core and Dynamo hosts, and another that generates docs from a package.

The PR also adds new APIs to ProtoCore.ProtoFFI.CLRDLLModule to enable scanning dlls in reflection mode, along with this new reflection extensions have been added to ProtoCore.Reflection.

The tool does not require Dynamo to be running but it uses the same APIs to scan dlls, main difference is that it dosent load anything into Dynamo but simply gives us back a list of all node types in the assembly being scanned

Dynamo loads documentation from Core and hosts by looking in a fallback_docs folder in the root directory of core or the host (TBD). By default when help is pressed on a node the DocumentationBrowser will look for the help doc associated with that node in the PackageDocumentationManager if no match is found it will first try and find a match in the host fallback_docs and secondly in Cores fallback_docs.

Besides that i made a slight modification to how the PackageDocumentationManager loads doc files, essentially i came across an issue where two packages was using the same namespace, this will cause an error on the manager. To address this i added the package name to the key of nodeDocumentationFileLookup.

Still need to add this to Dynamo.Mono, but lets touch base on that on our next call @mjkkirschner

Verbs

Verb Description
fromdirectory Generates documentation for all dlls (or only those specified in the filter) and all dyfs (if specified by the --includedyfs flag) in the input directory
frompackage Looks up node libraries in the pkg.json file and creates documentation for those dlls and creates documentation for all dyfs in the /dyf folder. All generated files gets saved in path/to/package/docs

fromdirectory - flags

Short name Long name Optional Description
-i --input Input binary file, containing nodes that documentaion should be generated for.
-o --output Location where markdown files should be generated
-r --references optional flag - Folder paths to dlls that are used as references in the nodes
-f --filter optional flag - Specifies which binary files documentation should be generated for
-c --includedyfs optional flag - Include custom dyf nodes
-d --dictionary optional flag - File path to DynamoDictionary json
-w --overwrite optional flag - When specified the tool will overwrite files in the output path
-y --recursive-scan optional flag - Input folder will be scanned recursively
-s --compress-images optional flag - When set, the tool will try to compress images from dictionary content
-x --layout-spec optional flag - Path to a LayoutSpecification json file

fromdirectory - samples

fromdirectory 
-i "C:\Users\....\Documents\GitHub\Dynamo\bin\AnyCPU\Debug\nodes" 
-f CoreNodeModels.dll 
-o "C:\Users\...\Desktop\TestMdOutput_CoreNodeModels" 
-d "C:\Users\...\Documents\GitHub\DynamoDictionary\public\data\Dynamo_Nodes_Documentation.json" 
-x "C:\Users\...\Documents\GitHub\Dynamo\src\LibraryViewExtension\web\library\layoutSpecs.json" 
-w -s

image

fromdirectory 
-i "C:\Users\...\Documents\GitHub\DynamoRevit\bin\AnyCPU\Release\Revit\nodes" 
-f DSRevitNodesUI.dll 
-o "C:\Users\...\Desktop\TestMdOutputRevitNodes - Compressed" 
-d "C:\Users\...\Documents\GitHub\DynamoDictionary\public\data\Dynamo_Nodes_Revit.json" 
-x "C:\Users\...\Documents\GitHub\DynamoRevit\src\DynamoRevit\Resources\LayoutSpecs.json" 
-r "C:\Users\...\Desktop\PathToFolderWithRevitAPI" "C:\...\DynamoRevit\bin\AnyCPU\Debug\Revit"
-w -s

image

frompackage - flags

Short name Long name Optional Description
-i --input Package folder path.
-r --references optional flag - Folder paths to dlls that are used as references in the nodes
-w --overwrite optional flag - When specified the tool will overwrite files in the output path

frompackage - samples

frompackage 
-i "C:\Users\...\source\repos\InspectionTest\InspectionTest\dist\InspectionTest" 
-r "C:\Users\...\Desktop\PathToFolderWithRevitAPI"
-w

Docs in Revit

DynamoDocs

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Reviewers

@mjkkirschner

FYIs

@Amoursol

@mjkkirschner
Copy link
Member

@SHKnudsen - this PR looks to need work before review:

  1. conflicts
  2. based on an old commit that is not building.

@mjkkirschner
Copy link
Member

@SHKnudsen was trying to build this and ran into the issue that -l no longer exists for loggerpath, can you update the PR description? Also there is a conflict on this branch stopping the build from completing.

@SHKnudsen
Copy link
Contributor Author

@SHKnudsen was trying to build this and ran into the issue that -l no longer exists for loggerpath, can you update the PR description? Also there is a conflict on this branch stopping the build from completing.

@mjkkirschner updated the description and solved the merge conflict. Also made the changes that we discussed, and everything seems to work nicely now.

@mjkkirschner
Copy link
Member

@SHKnudsen thats great to hear, I am currently looking into creating a custom importModuleHandler that will either:

  1. ignore import statements
  2. redirect import statements to your getFunctionDescriptorReflection methods.

I'll send a PR to your fork if that works for you?

@mjkkirschner
Copy link
Member

mjkkirschner commented Jul 11, 2021

@Amoursol can you please check in with legal again on the inclusion of imageMagik - with its custom license - we won't be able to finalize this without that approval - if needed we can back those changes out and add compression later I guess.

@SHKnudsen
Copy link
Contributor Author

I'll send a PR to your fork if that works for you?

Yep that sounds good, thanks!

@Amoursol
Copy link
Contributor

@Amoursol can you please check in with legal again on the inclusion of imageMagik - with its custom license - we won't be able to finalize this without that approval - if needed we can back those changes out and add compression later I guess.

Will chase on this now @mjkkirschner, may have slipped my mind. Sorry for that!

mjkkirschner and others added 3 commits July 13, 2021 15:08
put clr into reflection mode when importing DS files
fix classname for generated ds docs
fix issue with protogeometry format load error
@SHKnudsen
Copy link
Contributor Author

@mjkkirschner merged your DS file changes so think this is getting close to being ready. I took out the tests on this PR so we can add everything test-related in a new PR.

Copy link
Contributor

@aparajit-pratap aparajit-pratap left a comment

Choose a reason for hiding this comment

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

More comments to come ...

/// <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.

IsHidden = attributes.OfType<IsVisibleInDynamoLibraryAttribute>().Any(attr => !attr.Visible);

var attribs = attributes.OfType<NodeNameAttribute>();
if (attribs.Any() && !IsDeprecated && !IsMetaNode && IsDSCompatible && !IsHidden)
Copy link
Contributor

Choose a reason for hiding this comment

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

If an attribute is a NodeNameAttribute, how is there a possibility that any of the other flags, IsDeprecated, etc. will be true?

Copy link
Contributor Author

@SHKnudsen SHKnudsen Aug 12, 2021

Choose a reason for hiding this comment

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

Not sure i fully understand the question?

The type can have both NodeNameAttribute and NodeDeprecatedAttribute and so on. I dont know the exact reason for making this check, but am simply following the logic of the original TypeLoadData constructor
https://github.com/DynamoDS/Dynamo/blob/master/src/DynamoCore/Graph/Nodes/TypeLoadData.cs#L43

Copy link
Member

Choose a reason for hiding this comment

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

appears to me those other flags are checked above by checking other attributes.

Comment on lines 848 to 854
if ((retype.IsIndexable && mattrs.AllowRankReduction)
|| (typeof(object).Equals(method.ReturnType)))
{
retype.rank = Constants.kArbitraryRank;
}

func.Signature = ParseArgumentSignature(method);
Copy link
Contributor

Choose a reason for hiding this comment

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

Other than GetProtoCoreType and isPropertyAccessor is this code also expected to throw in reflection-only mode? If not, we could probably move this out of the try-catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess some of it might not be, but lots of its relying on the retype so if that fails i would say we dont want to execute this code either

try
{
// if overriding object
var baseType = methodInfo.DeclaringType.BaseType;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this method be recursive - base type of base type and so on until you find a matching methodInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just did a little test with 3 classes ParentType, MiddelType and NestedType
(inheritance like this NestedType -> MiddelType -> ParentType) where ParentType has a virtual RandomProp which NestedType implements. In that scenario doing GetBaseDefinitionReflectionContext on NestedType.RandomProp will return the correct methodInfo from ParentType

}
}

if (functionGroups.Count > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

if(functionGroups.Any()?

mjkkirschner and others added 8 commits August 16, 2021 13:42
Co-authored-by: michael kirschner <michael.kirschner@autodesk.com>
Co-authored-by: michael kirschner <michael.kirschner@autodesk.com>
add gif compression by quantization to 32k colors
in debug leave console open until readline for easy log reading
* Dyn 3817 exit tour window popup (DynamoDS#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 (DynamoDS#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 (DynamoDS#11925)

* update tests

* update xml summary
add some logging to failing tests

Co-authored-by: michael kirschner <michael.kirschner@autodesk.com>

* pkg load test log typo (DynamoDS#11926)

* update tests

* update xml summary
add some logging to failing tests

* typo

Co-authored-by: michael kirschner <michael.kirschner@autodesk.com>

* Update UI (DynamoDS#11932)

* Update searchMethod invocation in LibraryMSWebBrowserExtension (DynamoDS#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. (DynamoDS#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 <michael.kirschner@autodesk.com>

* check for null (DynamoDS#11930)

* Prevent port measure crash (DynamoDS#11935)

* CRASH: Delete node with right-click at the same time (DynamoDS#11927)

* null checks

* Add unit test

* Fix For Loading Json File (DynamoDS#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 <61755417+RobertGlobant20@users.noreply.github.com>
Co-authored-by: aparajit-pratap <aparajit.pratap@autodesk.com>
Co-authored-by: michael kirschner <michael.kirschner@autodesk.com>
Co-authored-by: Aaron (Qilong) <173288704@qq.com>
Co-authored-by: Ashish Aggarwal <ashish.aggarwal@autodesk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants