Giter VIP home page Giter VIP logo

kazoo-ast's Introduction

Kazoo AST

This library is for parsing the Erlang AST (Abstract Syntax Tree) of various Kazoo Erlang modules, looking to automatically pull out information for use by developers or users of Kazoo.

Existing AST modules

cb_api_endpoints

This module primarily looks for what endpoint paths are exposed by each Crossbar endpoint module. This is done by parsing each module’s `allowed_methods` exported functions and using the function’s arguments and the returned list of HTTP verbs.

Additionally, this module can take a JSON schema (using the module’s name to determine the schema file name) and create a Markdown table.

This functionality is utilized in the `to_ref_doc/0` and `to_swagger_file/0` to create reference documentation files for each Crossbar endpoint and to populate/update a swagger.json file. The ref docs are then used as guides in creating/updating the Crossbar documentation.

The next step is to create an escript that will, on each PR, run the `to_ref_doc/0`; if there are changes to the ref doc files, there will be unstaged changes that should trigger the committer to fold those into the docs. These unstaged changes can also be detected in CI and fail the build so that committers will be alerted.

cf_data_usage

This module looks for callflow action modules and traces the usage of `Data` in the `handle/2` exported function. It then looks for where the call paths get values out of the `Data` JSON object. Once collected, the module attempts to create/update a `callflows.{ACTION}.json` JSON schema document. The module inserts the keys found, tries to guess the type permitted, and includes the default if applicable.

This functionality is utilized in the `to_schema_docs/0` (to process all callflow actions - that is, modules that implement the gen_cf_action Erlang behaviour) and the `to_schema_doc/1`, which takes the callflow action’s module name (eg cf_park, cf_user, cf_voicemail, etc).

Similar to `cb_api_endpoints`, the next step is to make this an escript that runs on each build, creates unstaged changes, and forces a committer to address the detected changes.

kapps_config_usage

This module looks in all Kazoo Erlang application modules for calls to kapps_config (docs in the `system_config` database) getters. Similar to `cf_data_usage`, `kapps_config_usage` will create schemas if missing, update existing schemas, guess types, and include defaults if appropriate.

It also builds schemas for account config documents (account-overrides of system_config parameters).

code_usage

This module looks across the project for function call usage. It counts M:F/A and M:F(Args) instances (counting the length of Args to get arity) in the AST. The printer then takes an optional argument to print the Top hits.

`code_usage:tabulate()`: print the top 25 M:F/A across the project
`code_usage:tabulate(50)`: print the top 50 M:F/A across the project
`code_usage:tabulate(crossbar)`: print the top 25 M:F/A in Crossbar
`code_usage:tabulate(crossbar, 50)`: print the top 50 M:F/A in Crossbar

kazoo-ast's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.