Giter Site home page Giter Site logo

brittyazel / devtool Goto Github PK

View Code? Open in Web Editor NEW
53.0 8.0 4.0 376 KB

A multipurpose tool to assist with World of Warcraft addon development

License: MIT License

Lua 100.00%
development-tools inspection lua world-of-warcraft world-of-warcraft-addon wow wow-addon

devtool's Introduction

DevTool

DevTool is a multipurpose tool to assist with World of Warcraft addon development. The core functionality is similar to a debugger, and it is capable of visualizing and inspecting tables, events, and function calls at runtime.

This addon can help new and veteran developers alike by providing a visual representation of their tables and structures. Examining the WoW API or your addon's variables in a table-like, columnar interface is much easier than using print(), /dump, or other chat debugging methods.


How To Use

While DevTool is fully capable of being used solely from its graphical interface, it also provides a simple API for incorporation into your codebase directly. Use of this API will result in adding elements directly into the DevTool interface for inspection.

Using AddData():

The main (and only) public function provided by DevTool is AddData(data, <some string name>)

  • This function adds data to the list so that you can explore its values in interface list.
  • The 1st parameter is the object you wish to inspect.
    • Note, the default behavior is to shallow copy.
  • The 2nd parameter is the name string to show in interface to identify your object.
    • Note, if no name is provided, we will auto-generate one for you.

Let's suppose you have the following code in your addon...

local var = {}
--<some code here that adds data to 'var'>
DevTool:AddData(var, "My local var")

...this code will add var as a new row in the DevTool user interface with the label "My local var".

Example of a very common use case:

Here is a simple implementation that wraps DevTool:AddData() and checks for the DEBUG flag to be set:

function ExampleAddon:AddToInspector(data, strName)
	if DevTool and self.DEBUG then
		DevTool:AddData(data, strName)
	end
end

Using the above code as an example, we can then apply our new function all over the addon codebase wherever inspection is needed:

ExampleAddon:AddToInspector(ExampleObject, "ExampleObjectName")

How to use the sidebar:

There are three tabs in sidebar, and the text field has different behaviors for each.

  • History tab:
    • This text field takes the fully qualified name of a table, relative to _G. Likewise, entering <fully_qualified_name> into the DevTool text field is the same as typing /dev <name> <parent> in the chat window.
  • Events tab:
    • This text field can only use <event> or <event> <unit>. Likewise, the same can be done in the chat window by typing /dev eventadd <event> or /dev eventadd <event> <unit>, where <event> is a Blizzard API event string and <unit> is the cooresponding unit string.
  • Fn Call Log tab:
    • You can enter <function> <parent> into the text field, and it will try to find _G.<parent>.<function>. Likewise, the same can be done in the chat window by typeing /dev logfn <function> <parent>

How to use function arguments:

You can specify coma separated arguments that will be passed to any function DevTool attempts to execute. The values can be in the form of a string, number, nil, boolean, and/or table.

  • Note, to pass a value with type table you have to specify prefix t=.
  • Note, to pass the parent table, specify t=self.
  • Note, DevTool will automatically try passing self as first arg, if the function throws an error.

Example passing arguments to a function SomeFunction:

  • FN Call Args: t=MyObject, 12, a12 becomes SomeFunction(_G.MyObject, 12, a12)
  • FN Call Args: t=self, 12, a12 becomes SomeObject:SomeFunction(12, a12)
  • FN Call Args: t=MyObject.Frame1.Frame2 becomes SomeFunction(_G.MyObject.Frame1.Frame2)

Chat commands:

  • /dev - toggles the main UI window
  • /dev help - Lists help actions in the chat window
  • /dev <command> - Will execute one of the commands listed in the help menu

Other functionality:

  • Clicking on a table name will expand and show its children.
  • Clicking on a function name will try to execute the function. WARNING: BE CAREFUL.
    • Note: This will make use of any function arguments set, as described above.
  • If a table has WoW API GetObjectType() then its type will be visible in the value column.
  • DevTool can monitor WoW API events similar to that of /etrace, we also include a button to launch /etrace if you would rather use the built in tool instead.
  • DevTool can log function calls, their input args, and return values.
    • Note: Strings in the 'value' column have no line breaks

Want to contribute?


Want to Donate?

Making add-ons is a lot of work! Your help goes a huge way to making my add-on work possible. If you would like to Donate, GitHub Sponsors is the preferred method.


Credits:

DevTool is a continuation of the amazing ViragDevTool addon started by Varren/Virag for World of Warcraft: Battle for Azeroth and prior. All credit for the idea and the work done prior to 2021 should go to him, accordingly.

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.