AngularTools
AngularTools is a Visual Studio Code extension with a collection of tools for exploring an Angular project, help you with documenting, reverse engineering a project or help when refactoring. Some of the tools may seem very basic, but can be a powerful help when you have them right at your fingertips. Find it on the Visual Studio Code marketplace. Features
Below is a detailed description of each feature. Show the module hierarchy #The 'Show module hierarchy' command is used for visualizing the hierarchy of the modules in an Angular application. The command scans all the *.ts files in the project to identify classes decorated with the When you click a node the file it is associated with will be opened in the editor. In the visualization the classes will be colored depending on the class decorator of each class:
Show the dependency injection graph #The 'Show a graph representing the components and the injected dependencies' command generates a directed graph representing the components and the services injected into the components of an Angular application. The command scans all *.ts files of the application and for each class decorated with the @Component decorator, it analyses the constructor and each field in the class to identify all injected classes and to identify all the fields decorated with the Input, Output, ViewChild, ViewChildren, ContentChild and ContentChildren decorators. When you click a node the file it is associated with will be opened in the editor. In the visualization the components will by default be colored dark blue and the injected classes will be colored light blue. Show the component hierarchy #The 'Show the component hierarchy' command is used for visualizing the component hierarchy and Angular application. It analyses all the *.component.ts files and all the corresponding *.component.html template files to determine how the component use each other and then generates a directed graph showing the component hierarchy. When you click a node the file it is associated with will be opened in the editor. The command uses a vscode webview extension component to render the hierarchy using html, javascript and the Vis.js javascript library. This has the downside that copying the generated graph to the clipboard is not yet possible due to limitations in the vscode extension api. So to overcome this limitation the generated graph can be saved as a Png file to the root of the project you are analyzing. You can also save the graph in the Dgml format or in the GraphViz Dot format. Save as GraphViz dot format and generate a graph from the dot file: You can also choose to save a selection from the graph as shown in the example below. By default the component hierarchy graph is rendered using a random layout. You can change the layout method to use a hierarchical layout to line up the nodes in the graph in different ways and also change how the layout engine sorts the nodes in the graph. This is all done by checking the 'Change layout' checkbox to show the drop down boxes with the available options. Generate a markdown file with the component hierarchy in Mermaid format #This command will generate the component hierarchy in markdown format using Mermaid notation. Please notice that some online tools and sites do not support Mermaid markdown format yet, like GitHub and Visual Studio Code. To preview markdown files using the mermaid notation in Visual Studio Code i'm using the Markdown Preview Mermaid Support extension. Generate a markdown file that summarizes all the Angular modules #This command will scan all *.ts files in the workspace folders and find those classes that are decorated with the '@NgModule' class decorator and parse the module definition and then summarize each module into a markdown file. The summarization will consist of two parts: First a table listing how many imports, exports, declarations and so on each module contains. The second part shows what each module contain. Show the directory structure of the project #This command lists the entire directory structure of the currently open project. Sometimes this can be a quick way to get an overview of the project if you are new to the project before og maybe need to document it. The directory structure will be listed in the output window for the AngularTools extension for easy copy/pasting. Generate list of packages used in the project #Sometimes your boss or a customer requires documentation of which packages is used in the project. This command can save you a lot of tedious manual work by analyzing the package.json file and for each referenced package queries the npmjs.com website to fetch the description for the package and from that generates a Markdown file with a table of the packages with their descriptions. The license information is retrieved from the package.json file for each package in the node_modules folder in the root of the workspace, this mean that the license will show 'N/A' if you have not run the 'npm install' yet. List all imports #This command will analyse all Angular components in the project and collect all the imports of the components together with the number of times the imported component is used. This can be useful when refactoring or identifying frequently used modules. Usually frequently used modules needs extra attention or care before being changed during refactoring. You can also use the command to identify modules that are not referenced in a consistent way where some components are using relative path and some components using path-aliases. SettingsProject settingsYou can place a file named ".vscodeangulartools" in the workspace root folder where you can specify folders to exclude or include in json format. Only the two parameters "includeFolders" and "excludeFolders" are used at the moment. They are both semicolon separated list of folder names. If you add a includeFolders parameter, then only child folders of the folders in the list will be included. If you add a folder to the excludeFolders parameter then no files from the folder or its child-folders will be included. Notice that the filename comparison from v1.13.0 is case-sensitive. This may affect Windows user because the Windows filesystem is not case sensitive and if you previously added a path then it may not work anymore. So if you experience that your graph is no longer rendered as it used to be, then it may be because your includeFolders paths have the wrong casing in the settings file. Example:
Global settingsIn the Visual Studio Code settings you find under File --> Preferences --> Settings, under Extensions, there is a section with all the settings for AngularTools. It is possible to change the default filenames used when the extension saves a file to the workspace folder. You can change how the component hierarchy graph nodes are rendered, the edge endings, the color of the root nodes and a lot more. See the full list of settings below the screenshot.
Third party components and resources
|