Skip to content

Commit

Permalink
Update api definitions for docgen and DCL, significantly improved DCL…
Browse files Browse the repository at this point in the history
… itself, modified docgen to generate api set for dcl as well
  • Loading branch information
loukamb committed Oct 24, 2019
1 parent 49aad59 commit 54fffc4
Show file tree
Hide file tree
Showing 8 changed files with 481 additions and 177 deletions.
2 changes: 1 addition & 1 deletion base_entry.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="%s" class="CodeEntry">
<p class="CodeDefinition">
<p class="%s">
<span class="CodeTypename">%s</span> <a class="Anchor" href="%s">%s</a>(%s)
</p>
<p class="CodeDescription">
Expand Down
1 change: 1 addition & 0 deletions base_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</div>
</div>
<div id="BodyContainer">
<h3>Definitions with a violet background are proprietary extensions, which are exclusive to <b>Synapse X</b>. Otherwise, definitions without a colored background are from the <a href="https://github.com/LoukaMB/SynapseX/blob/master/script/compatibility_layer.lua" target="_blank">DCL standard</a>.</h3>
%s
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion build_docs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if errorlevel 0 (
rem cd docs
rem del /s /q "*.*" >nul
rem cd ..
lua51 docgenx.lua docapi.lua
lua51 docgenx.lua docapi.lua syn_
) else (
echo build_docs - please install lua51 into your path before using build_docs
)
115 changes: 69 additions & 46 deletions docapi.lua
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@

-- Synapse X API dictionary, formatted for Lua scripts
-- Last update: October 19, 2019
-- DCL API dictionary, formatted for Lua scripts
-- Last update: October 24, 2019

return
{
["Environment Library"] =
{
{ "table", "syn_getgenv", "", "Returns the environment that will be applied to each script ran by Synapse." };
{ "table", "syn_getrenv", "", "Returns the global Roblox environment for the LocalScript context." };
{ "variant<table/nil>", "syn_getsenv", "object<LocalScript/ModuleScript> Script", "Returns Script's environments. Returns nil if Script isn't running."};
{ "table", "syn_getreg", "", "Returns the Lua registry." };
{ "table", "syn_getgc", "", "Returns the Lua GC list. This can very easily leak memory if not used correctly." };
{ "table", "syn_getinstances", "", "Returns a list of all instances within the game." };
{ "table", "syn_getnilinstances", "", "Returns a list of all instances parented to nil within the game." };
{ "table", "syn_getscripts", "", "Returns a list of all scripts within the game." };
{ "table", "syn_getloadedmodules", "", "Returns a list of all ModuleScripts within the game." };
{ "table", "syn_getconnections", "", "Returns a list of all connections within the game." };
{ "variant<LocalScript/ModuleScript/nil>", "syn_getcallingscript", "", "Returns the script calling the current function." };
{ "table", "*_getgenv", "", "Returns the environment that will be applied to each script ran by Synapse." };
{ "table", "*_getrenv", "", "Returns the global thread environment for the LocalScript context." };
{ "variant<table/nil>", "*_getsenv", "object<LocalScript/ModuleScript> Script", "Returns Script's environments. Returns nil if Script isn't running."};
{ "table", "*_getreg", "", "Returns the Lua registry." };
{ "table", "*_getgc", "", "Returns the Lua GC list. This can very easily leak memory if not used correctly." };
{ "table<object>", "*_getinstances", "", "Returns a list of all instances within the game." };
{ "table<BaseScript>", "*_getnilinstances", "", "Returns a list of all instances parented to nil within the game." };
{ "table<BaseScript>", "*_getscripts", "", "Returns a list of all scripts within the game." };
{ "table<BaseScript>", "*_getrunningscripts", "", "Returns a list of all running scripts." };
{ "table<ModuleScript>", "*_getloadedmodules", "", "Returns a list of all ModuleScripts within the game." };
{ "variant<LocalScript/ModuleScript/nil>", "*_getcallingscript", "", "Returns the script calling the current function." };
};

["Signal Library"] =
{
{ "table", "*_getconnections", "", "Returns a list of all connections within the game." };
{ "void", "*_fireclickdetector", "object<ClickDetector> ClickDetector, <number/nil> Distance", "Fires the designated ClickDetector with distance provided. If distance isn't provided, it will default to 0." };
{ "void", "*_firetouchinterest", "object<Part> Part, object<TouchTransmitter> Transmitter, number Toggle", "Fires the designated TouchTransmitter with Part. The Toggle argument is used to tell whether the Part is currently being touched." };
};

["Context Library"] =
{
{ "void", "syn_context_set", "int Context", "Sets the current thread context to Context." };
{ "int", "syn_context_get", "", "Returns the current thread context as an integer." };
{ "void", "*_context_set", "int Context", "Sets the current thread context to Context." };
{ "int", "*_context_get", "", "Returns the current thread context as an integer." };
};

["Table Extensions"] =
Expand All @@ -35,56 +42,72 @@ return

["Keyboard/Mouse Library"] =
{
{ "bool", "syn_isactive", "", "Returns true if the user is focused on the game window." };
{ "void", "syn_keypress", "int Keycode", 'Simulates a keypress for the specified keycode. For more information, <a href="https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes" target="_blank">click here.</a>'};
{ "void", "syn_keyrelease", "int Keycode", "Simulates a key release for the specified keycode." };
{ "void", "syn_mouse1click", "", "Simulates a full left mouse button press and release." };
{ "void", "syn_mouse1press", "", "Simulates a left mouse button press." };
{ "void", "syn_mouse1release", "", "Simulates a left mouse button release." };
{ "void", "syn_mouse2click", "", "Simulates a full right mouse button press and release." };
{ "void", "syn_mouse2press", "", "Simulates a right mouse button press." };
{ "void", "syn_mouse2release", "", "Simulates a right mouse button release." };
{ "void", "syn_mousescroll", "int Pixels", "Scrolls the mouse wheel virtually by Pixels pixels." };
{ "void", "syn_mousemoverel", "int X, int Y", "Moves the mouse cursor relatively by the specified coordinates." };
{ "bool", "*_isactive", "", "Returns true if the user is focused on the game window." };
{ "void", "*_keypress", "int Keycode", 'Simulates a keypress for the specified keycode. For more information, <a href="https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes" target="_blank">click here.</a>'};
{ "void", "*_keyrelease", "int Keycode", "Simulates a key release for the specified keycode." };
{ "void", "*_mouse1click", "", "Simulates a full left mouse button press and release." };
{ "void", "*_mouse1press", "", "Simulates a left mouse button press." };
{ "void", "*_mouse1release", "", "Simulates a left mouse button release." };
{ "void", "*_mouse2click", "", "Simulates a full right mouse button press and release." };
{ "void", "*_mouse2press", "", "Simulates a right mouse button press." };
{ "void", "*_mouse2release", "", "Simulates a right mouse button release." };
{ "void", "*_mousescroll", "int Pixels", "Scrolls the mouse wheel virtually by Pixels pixels." };
{ "void", "*_mousemoverel", "int X, int Y", "Moves the mouse cursor relatively by the specified coordinates." };
};

["Clipboard Library"] =
{
{ "void", "syn_clipboard_set", "string Content", "Set the system's clipboard to Content" };
{ "string", "syn_clipboard_get", "", "Return the clipboard's content" };
{ "void", "*_clipboard_set", "string Content", "Set the system's clipboard to Content" };
{ "string", "*_clipboard_get", "", "Return the clipboard's content" };
};

["Hooking Library"] =
{
{ "function", "syn_hookfunction", "function Target, function Hook", "Hooks Target and replaces it with Hook. Returns the unhooked function." };
{ "function", "syn_newcclosure", "function Fn", "Pushes a CClosure that invokes Fn. Used for metatable hooks." };
{ "function", "*_hookfunction", "function Target, function Hook", "Hooks Target and replaces it with Hook. Returns the unhooked function." };
{ "function", "*_newcclosure", "function Fn", "Pushes a CClosure that invokes Fn. Used for metatable hooks." };
};

["IO Library"] =
{
{ "string", "syn_io_read", "string Filepath", "Reads the contents at filepath Filepath and returns it as an ASCII string." };
{ "void", "syn_io_write", "string Filepath, string Data", "Writes Data at Filepath and creates the file if it doesn't exist." };
{ "void", "syn_io_append", "string Filepath, string Data", "Appends Data to the file located at Filepath." };
{ "string", "*_io_read", "string Filepath", "Reads the contents at filepath Filepath and returns it as an ASCII string." };
{ "void", "*_io_write", "string Filepath, string Data", "Writes Data at Filepath and creates the file if it doesn't exist." };
{ "void", "*_io_append", "string Filepath, string Data", "Appends Data to the file located at Filepath." };
{ "table<string>", "*_io_listdir", "string Filedir", "Returns a table containing a directory's files." };
{ "bool", "*prp *_io_isfile", "string Filepath", "Returns whether the file at Filepath is a file." };
{ "bool", "*prp *_io_isfolder", "string Filepath", "Returns whether the file at Filepath is a directory." };
{ "void", "*prp *_io_delfile", "string Filepath", "Deletes the file at Filepath." };
{ "void", "*prp *_io_delfolder", "string Filepath", "Deletes the directory at Filepath." };
};

["Console Library"] =
{
{ "void", "*prp *_console_name", "string Name", "Set the currently allocated console's title to Name." };
{ "string", "*prp *_console_input", "", "Yields the Engine and returns the user's input." };
{ "string", "*prp *_console_input_async", "", "Yields the current thread and returns the user's input." };
{ "void", "*prp *_console_print", "string Arg", "Prints Arg to the allocated console." };
{ "void", "*prp *_console_iprint", "string Arg", "Akin to *_console_print but prefixes Arg with [INFO]. Mainly used by internal scripts for debugging purposes." };
{ "void", "*prp *_console_wprint", "string Arg", "Akin to *_console_print but prefixes Arg with [WARN]. Mainly used by internal scripts for debugging purposes." };
{ "void", "*prp *_console_eprint", "string Arg", "Akin to *_console_print but prefixes Arg with [ERR]. Mainly used by internal scripts for debugging purposes." };
};

["Reflection and Engine Library"] =
{
{ "bool", "syn_checkcaller", "", "Returns true if the current thread is owned by Synapse X. " };
{ "bool", "syn_islclosure", "function Fn", "Returns true if Fn is a Lua function." };
{ "string", "syn_dumpstring", "string Script", "Dumps the bytecode for the Script chunk." };
{ "string", "syn_decompile", "variant<function, LocalScript, ModuleScript> Script, bool Bytecode", "Decompiles Script and returns the decompiled script, or its bytecode if Bytecode is true." };
{ "void", "syn_obj_override", "object Object, string PropertyName, any Value", "Overrides field PropertyName in Object to Value and prevents its replication." };
{ "table", "syn_obj_specialinfo", "object Object", "Returns a list of special properties for certain instances, such as MeshParts, UnionOperations or Terrain." };
{ "void", "syn_obj_save", "table Flags", "Saves the current game to your workspace folder. Flags is a table containing two fields: noscripts, a boolean specifying whether scripts are to be decompiled automatically, and mode, which is a string that sets the serialization mode." };
{ "object<WebSocket>", "syn_net_websocket", "string Name", "Opens the Synapse Websocket with channel Name. This function will be absent if WebSocket support is disabled in theme.json" };
{ "bool", "*_checkcaller", "", "Returns true if the current thread is owned by Synapse X. " };
{ "bool", "*_islclosure", "function Fn", "Returns true if Fn is a Lua function." };
{ "string", "*prp *_dumpstring", "string Script", "Dumps the bytecode for the Script chunk." };
{ "string", "*prp *_decompile", "variant<function, LocalScript, ModuleScript> Script, bool Bytecode", "Decompiles Script and returns the decompiled script, or its bytecode if Bytecode is true." };
{ "void", "*prp *_obj_override", "object Object, string PropertyName, any Value", "Overrides field PropertyName in Object to Value and prevents its replication." };
{ "table", "*prp *_obj_specialinfo", "object Object", "Returns a list of special properties for certain instances, such as MeshParts, UnionOperations or Terrain." };
{ "void", "*_obj_save", "table Flags", "Saves the current game to your workspace folder. Flags is a table containing two fields: noscripts, a boolean specifying whether scripts are to be decompiled automatically, and mode, which is a string that sets the serialization mode." };
{ "object<WebSocket>", "*prp *_net_websocket", "string Name", "Opens the Synapse Websocket with channel Name. This function will be absent if WebSocket support is disabled in theme.json" };
};

["Encryption Library"] =
{
{ "string", "syn_crypt_encrypt", "string Data, string Key", "Encrypts Data with Key and returns it." };
{ "string", "syn_crypt_decrypt", "string Data, string Key", "Decrypts Data with Key and returns it." };
{ "string", "syn_crypt_b64_encode", "string Data", "Encodes Data in base64." };
{ "string", "syn_crypt_b64_decode", "string Data", "Decodes Data from base64." };
{ "string", "syn_crypt_hash", "string Data", "Returns Data's hash." };
{ "string", "*prp *_crypt_encrypt", "string Data, string Key", "Encrypts Data with Key and returns it." };
{ "string", "*prp *_crypt_decrypt", "string Data, string Key", "Decrypts Data with Key and returns it." };
{ "string", "*prp *_crypt_b64_encode", "string Data", "Encodes Data in base64." };
{ "string", "*prp *_crypt_b64_decode", "string Data", "Decodes Data from base64." };
{ "string", "*prp *_crypt_hash", "string Data", "Returns Data's hash." };
};
}
20 changes: 13 additions & 7 deletions docgenx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ end

function docgen.method(f_return, f_name, f_arguments, f_description, f_example)
local method = {}
method.name = f_name
method.retn = f_return
method.exam = f_example
method.args = f_arguments
method.desc = f_description
method.name = f_name:gsub("%*prp%s*", "")
method.proprietary = f_name:find("%*prp") and true
return method
end

Expand All @@ -40,7 +41,7 @@ function docgen.typename(str)
return str:gsub("<", "<span class=\"CodeTypenameVariant\">&lt;"):gsub(">", "&gt;</span>")
end

function docgen.build(tree)
function docgen.build(tree, prefix)
local document = docgen.header
local css = docgen.filestr("docstyle.css")
local body = ""
Expand All @@ -61,9 +62,13 @@ function docgen.build(tree)
-- void argument list
methodargs = "<span class=\"CodeTypename\">void</span>"
end

bodyentry = bodyentry:format(mval.name, docgen.typename(mval.retn), '#' .. mval.name, mval.name, methodargs, mval.desc, mval.exam)
body = body .. bodyentry
if mval.proprietary then
bodyentry = bodyentry:format(mval.name:gsub("%*_", prefix), "CodeDefinitionProprietary", docgen.typename(mval.retn), '#' .. mval.name:gsub("%*_", prefix), mval.name:gsub("%*_", prefix), methodargs, mval.desc:gsub("%*_", prefix), mval.exam)
body = body .. bodyentry
else
bodyentry = bodyentry:format(mval.name:gsub("%*_", prefix), "CodeDefinition", docgen.typename(mval.retn), '#' .. mval.name:gsub("%*_", prefix), mval.name:gsub("%*_", prefix), methodargs, mval.desc:gsub("%*_", prefix), mval.exam)
body = body .. bodyentry
end
end
end

Expand All @@ -84,8 +89,9 @@ function docgen.loadapidef(path)
end
end

function docgen.main(path)
function docgen.main(path, prefix)
assert(path, "path to api definition is missing")
local prefix = prefix or "api."
local api = docgen.loadapidef(path)
local tree = docgen.tree()
for k1, v1 in pairs(api) do
Expand All @@ -98,7 +104,7 @@ function docgen.main(path)

docgen.header = docgen.filestr("base_index.html")
docgen.entry = docgen.filestr("base_entry.html")
local document_string = docgen.build(tree)
local document_string = docgen.build(tree, prefix)
local out = io.open("docs/index.html", "w")
out:write(document_string)
out:close()
Expand Down
Loading

0 comments on commit 54fffc4

Please sign in to comment.