API icon indicating copy to clipboard operation
API copied to clipboard

Dump generation

Open MNoya opened this issue 8 years ago • 1 comments

  • cl_panorama_script_help_2 (Crashes the game currently)
  • script_help2
  • cl_script_help2
  • dump_panorama_css_properties
  • dump_panorama_events
function DumpObjectIndented(obj, indent)
{
  var result = "";
  if (indent == null) indent = "";

  for (var property in obj)
  {
    var value = obj[property];
    if (typeof value == 'string')
      value = "'" + value + "'";
    else if (typeof value == 'object')
    {
      if (value instanceof Array)
      {
        // Just let JS convert the Array to a string!
        value = "[ " + value + " ]";
      }
      else
      {
        // Recursive dump
        // (replace "  " by "\t" or something else if you prefer)
        var od = DumpObjectIndented(value, indent + "  ");
        // If you like { on the same line as the key
        //value = "{\n" + od + "\n" + indent + "}";
        // If you prefer { and } to be aligned
        value = "\n" + indent + "{\n" + od + "\n" + indent + "}";
      }
    }
    result += indent + "'" + property + "' : " + value + ",\n";
  }
  return result.replace(/,\n$/, "");
}

MNoya avatar Aug 27 '16 17:08 MNoya

Pushed enumdump.ts and DefinitionGenerator.py from ModDota/DotaUI to this repo.

  • enumdump.ts generates dota_enum.d.ts and for all intents and purposes is a refined version of OP's function, but it will only spit out constants, and also adds the file header at the top.
  • DefinitionGenerator.py accepts input from cl_panorama_script_help $TYPE and spits out vaguely typescript declaration that a human needs to go through later and clean up (Valves documentation is very vague on a lot of types)

Calling all @ModDota/panorama to inspect

SinZ163 avatar Aug 29 '16 13:08 SinZ163