Generating a graph visualization by parsing a PowerShell project.

This topic contains 3 replies, has 2 voices, and was last updated by  Lars Bengtsson 2 months, 4 weeks ago.

  • Author
    Posts
  • #79012

    Lars Bengtsson
    Participant

    Hi...

    I'm trying to parse the PowerShell code in a PowerShell project, in order to generate a graph visualization over the 'function hierarchy / call-graph hierarchy' of the PowerShell code. This would be of great help in documenting and understanding the code in a PowerShell project.
    I've considered various ways to go at the problem. Where I'm currently at is: I'm going to parse PowerShell code with PowerShell code that looks at the AST and then generate the graph visualization with graphviz. The challenge is how to avoid endless loops and other similar issues when parsing the code. I'm thinking of using the theory of 'directed acyclic graph' (https://en.wikipedia.org/wiki/Directed_acyclic_graph). Thinking that implementing this in code will make it possible to stop parsing 'x' code if it would result in a cyclic loop.....

    So, I'm seeking your guidance on if this is a proper approach. Also, if someone here has experience in doing this, or something similar, advice would be greatly appreciated 🙂

    I hope I have made myself understandable and I'm looking forward to read your comments and ideas.

    Thank you very much.

  • #79019

    Max Kozlov
    Participant
  • #79226

    Lars Bengtsson
    Participant

    Hi @max-kozlov (Max Kozlov) and others,

    Thank you very much for replying. That module will definitely help. I can use that to parse the AST, so I don't have to code that part myself. However, I still need to continue traversing each function call inside a module file while ensuring/holding it up against the overall gathered data, in order to ensure, that I don't get into cyclic endless cases.

    Any ideas on that?

    Thank you.

  • #79943

    Lars Bengtsson
    Participant

    Anyone else with a suggestion? Thank you.

You must be logged in to reply to this topic.