PSFunctionExplorer icon indicating copy to clipboard operation
PSFunctionExplorer copied to clipboard

Add feature: Function name improvment

Open Lasio74 opened this issue 6 years ago • 5 comments

I implemented it today to generate documentation of function calls inside my module

I use the Find-FUFunction and Write-FUGraph function in the both case, the function name returned have the case of the name modified and it's more difficult to read

for exemple, 'Find-FUFunction' become 'Find-Fufunction' and , in my case, funcitons like 'Get-PhysicalLocationByName' become 'Get-Physicallocationbyname'

Maybe good to have a switch to preserve the original name ? and everything is based on the display of the first occurence

Lasio74 avatar Aug 14 '19 09:08 Lasio74

I have a workaround for Find-FUFunction, I use the .RawFunctionAST.Name in place of the .Name of the object


$FunctionList = Find-FUFunction $PSM1Path
Foreach ($Fction in $FunctionList) {
     $Fction.RawFunctionAST.Name
}

Lasio74 avatar Aug 14 '19 09:08 Lasio74

looking for the Write-FUGraph, I see 2 different approach:

  1. add a switch -> 1.1 change the 2 functions in class FUUtility::getFunction to have 1 more parameter to keep the original format 1.2 add switch to Find-FUFunction (like -KeepFunctionNameFormat) and change the call when creating the object to take it in count 1.3 add switch to write-fugraph (like -KeepFunctionNameFormat) and add it when calling find-function

OR

  1. add just a parameter to write-FUgraph to allow to pass to it the data if not present, just call the find-function if present, don't call find-function and use the array in parameter

it's fast and allow to do the trick, we call ourself the find-fufunction command, change the display name and send it to generate the graph

it allow also to be more logic with the name of the function, write-FUgraph generate a graphic and, normally, doesn't have to retrieve the data (but keep the data retrieval to avoid breaking change)

Lasio74 avatar Aug 14 '19 10:08 Lasio74

I think i normalize the name of the function because, if the for example you have two calls for the same function, and they are spelled differently ( for example get-something and Get-SomeThing) you'll have two different entries ..., but i can still implement the functionnality if you wish !

LxLeChat avatar Aug 14 '19 16:08 LxLeChat

ok @Lasio74 so, i'm going to make some changes. And as discussed in slack, you are right, write-fugraph should only output a graph... ! dont remember why i build it the way it is now.

Write-FUGraph should only accept [FuFunction[]] objects ... ! I'll also implement the requested feature !

LxLeChat avatar Aug 17 '19 19:08 LxLeChat

code available in the Issues Branch ! keep me informed :) -notitlecase switch for find-fufunction write-fufunction now accepts data from find-fufunction via the -inputobject parameter

LxLeChat avatar Aug 19 '19 20:08 LxLeChat