Advertisement
oli414

Notepad++ PythonScript - JS Class Creator

Dec 30th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. #***   IMPORTS   ***
  2. import os
  3. from Npp import *
  4.  
  5. def addBlock(title, tabs):
  6.     editor.addText(tabs + "// " + title + " //\n" + tabs + "\n" + tabs + "\n" + tabs + "\n")
  7.  
  8. input = notepad.prompt("Specify a class name.", "Class Wizzard")
  9.  
  10. input = input.split()
  11.  
  12. className = input[0]
  13.  
  14. input.pop(0)
  15.  
  16. classExtends = input
  17.  
  18. notepad.new()
  19.  
  20. notepad.menuCommand(MENUCOMMAND.LANG_JS)
  21.  
  22. editor.addText("\nfunction " + className + " () {\n")
  23. for inheritedClassName in classExtends:
  24.     editor.addText("\t" + inheritedClassName + ".call(this);\n")
  25. addBlock("Constructor", "\t")
  26. editor.addText("}\n")
  27. for inheritedClassName in classExtends:
  28.     editor.addText("Object.assign(" + className + ".prototype, " + inheritedClassName + ".prototype);\n")
  29. editor.addText("\n")
  30. addBlock("Functions", "")
  31. addBlock("Statics", "")
  32.    
  33. notepad.save()
  34.  
  35. # Supports inheritance. When creating a class simply enter the class name. All names that follow seperated by a space will be used to extend this class.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement