Added ldoc comments for all lua modules and generated docs in documentation index.html

This commit is contained in:
SkylarHew
2022-01-20 11:04:44 -07:00
parent 5085d87f68
commit da7b996a8b
41 changed files with 4307 additions and 35 deletions

View File

@ -1,6 +1,6 @@
--- @module add_child_org_consent
-- Adds a child org
--- Adds a child org.
-- Depends on `consent`
-- @module add_child_org_consent
local add_child_org_consent = {
name = "Add child org (consent)",
@ -14,7 +14,9 @@ add_child_org_consent.data = {
add_child_org_consent.config = {
}
-- @function initiate
--- Initiate consent for new child org
-- @function add_child_org_consent:initiate(result)
-- @param result
function add_child_org_consent:initiate(result)
modpol.interactions.text_query(
self.initiator,"Child org name: ",
@ -61,6 +63,8 @@ function add_child_org_consent:initiate(result)
)
end
--- Create a new child orgg
-- @function add_child_org_consent:create_child_org
function add_child_org_consent:create_child_org()
self.org:add_org(self.data.child_name, self.initiator)
modpol.interactions.message_org(
@ -71,5 +75,4 @@ function add_child_org_consent:create_child_org()
self.org:delete_process(self.id)
end
--- (Required) Add to module table
modpol.modules.add_child_org_consent = add_child_org_consent

View File

@ -1,6 +1,6 @@
--- change_modules
-- @module change_modules
-- Depends on consent
-- @module change_modules
local change_modules = {
name = "Change modules (consent)",
@ -16,6 +16,9 @@ change_modules.data = {
change_modules.config = {
}
--- Initiate change in modules.
-- Either adds or removes module depending on user input
-- @function change_modules:initiate
function change_modules:initiate(result)
self.data.result = result
-- Step 1: add or remove?
@ -167,5 +170,4 @@ function change_modules:propose_change(type, mod_text)
self.org:delete_process(self.id)
end
--- (Required) Add to module table
modpol.modules.change_modules = change_modules

View File

@ -1,5 +1,5 @@
--- @module consent
-- A utility module for checking consent
--- A utility module for checking consent
-- @module consent
local consent = {
name = "Consent process utility",
@ -17,6 +17,9 @@ consent.config = {
votes_required = 1
}
--- Initiate consent
-- @function consent:initiate
-- @param result
function consent:initiate(result)
self.data.result = result
-- if org is empty, consent is given automatically
@ -32,6 +35,9 @@ function consent:initiate(result)
end
end
--- Callback
-- @function consent:callback
-- @param member
function consent:callback(member)
modpol.interactions.binary_poll_user(
member,

View File

@ -1,3 +1,5 @@
--- Adds a user to org
-- @module join_org
join_org = {}
@ -7,6 +9,9 @@ join_org.setup = {
desc = "If consent process is passed, initiator joins this org."
}
--- Adds the user to the org
-- @function join_org.initiate
-- @param result
function join_org.initiate(result)
modpol.interactions.binary_poll_user(
initiator,

View File

@ -1,6 +1,7 @@
--- Join org (consent)
--- Join org (consent).
-- A simple module that calls a consent process on an org to add a member.
-- Depends on the Consent module.
-- @module join_org_consent
local join_org_consent = {
name = "Join this org (consent)",
@ -15,6 +16,9 @@ join_org_consent.data = {
join_org_consent.config = {
}
--- Initiate join org with consent
-- @function join_org_consent:initiate
-- @param result
function join_org_consent:initiate(result)
if self.org:has_member(self.initiator) then
modpol.interactions.message(
@ -38,6 +42,8 @@ function join_org_consent:initiate(result)
end
end
--- Adds member to org, notifies org, and deletes process
-- @function join_org_consent:complete
function join_org_consent:complete()
self.org:add_member(self.initiator)
modpol.interactions.message_org(

View File

@ -1,4 +1,4 @@
--- leave_org
--- Removes initiator from org
-- @module leave_org
local leave_org = {
@ -13,10 +13,9 @@ leave_org.data = {
leave_org.config = {
}
--- (Required): initiate function
-- Modules have access to the following instance variables:
-- @param result (optional) Callback if this module is embedded in other modules
-- @function initiate
--- Removes user from org
-- @function leave_org:initiate
-- @param result
function leave_org:initiate(result)
if self.org == modpol.instance then
modpol.interactions.message(
@ -35,5 +34,4 @@ function leave_org:initiate(result)
self.org:delete_process(self.id)
end
--- (Required) Add to module table
modpol.modules.leave_org = leave_org

View File

@ -1,4 +1,4 @@
--- message_org
--- Messages all org members
-- @module message_org
local message_org = {
@ -14,7 +14,9 @@ message_org.data = {
message_org.config = {
}
--- Allows user to send input message to all org members
-- @function initiate
-- @param result
function message_org:initiate(result)
modpol.interactions.text_query(
self.initiator, "Message to all org members: ",
@ -34,5 +36,4 @@ function message_org:initiate(result)
self.org:delete_process(self.id)
end
--- (Required) Add to module table
modpol.modules.message_org = message_org

View File

@ -1,6 +1,7 @@
--- Remove child (consent)
-- A simple module that calls a consent process on an org to remove its child
-- Depends on the Consent module.
-- @module remove_child_consent
local remove_child_consent = {
name = "Remove child (consent)",
@ -16,6 +17,9 @@ remove_child_consent.data = {
remove_child_consent.config = {
}
--- Removes a child org with consent
-- @function remove_child_consent:initiate
-- @param result
function remove_child_consent:initiate(result)
local children = {}
for i,v in ipairs(self.org.children) do

View File

@ -1,4 +1,4 @@
--- remove_member_consent
--- Calls consent to remove member from org
-- @module remove_member_consent
local remove_member_consent = {
@ -15,6 +15,9 @@ remove_member_consent.data = {
remove_member_consent.config = {
}
--- Removes given member from org
-- @function remove_member_consent:initiate
-- @param result
function remove_member_consent:initiate(result)
-- Abort if in root org
if self.org == modpol.instance then
@ -60,5 +63,4 @@ function remove_member_consent:complete()
if self.data.result then self.data.result() end
end
--- (Required) Add to module table
modpol.modules.remove_member_consent = remove_member_consent

View File

@ -1,8 +1,6 @@
--- @module Remove Org
-- A simple module that removes an org.
--- A simple module that removes an org.
-- @module remove_org
--- Main module table
remove_org = {
name = "Remove this org",
slug = "remove_org",
@ -12,8 +10,9 @@ remove_org = {
remove_org.config = {}
remove_org.data = {}
--- Initiate function
-- @function initiate
--- Removes org
-- @function remove_org:initiate
-- @param result
function remove_org:initiate(result)
if self.org == modpol.instance then
modpol.interactions.message(

View File

@ -1,6 +1,7 @@
--- Remove org (consent)
-- A simple module that calls a consent process on an org to remove it.
-- Depends on the Consent module.
-- @module remove_org_consent
local remove_org_consent = {
name = "Remove this org (consent)",
@ -15,6 +16,9 @@ remove_org_consent.data = {
remove_org_consent.config = {
}
--- Remove org if all members consent
-- @function remove_org_consent:initiate
-- @param result
function remove_org_consent:initiate(result)
if self.org == modpol.instance then
modpol.interactions.message(

View File

@ -1,6 +1,7 @@
--- Rename org (consent)
-- A simple module that calls a consent process on an org to rename it.
-- Depends on the Consent module.
-- @module rename_org_consent
local rename_org_consent = {
name = "Rename this org (consent)",
@ -16,6 +17,9 @@ rename_org_consent.data = {
rename_org_consent.config = {
}
--- Renames the org after consent is reached
-- @function rename_org_consent:initiate
-- @param result
function rename_org_consent:initiate(result)
modpol.interactions.text_query(
self.initiator,"New org name: ",
@ -63,6 +67,8 @@ function rename_org_consent:initiate(result)
)
end
--- Changes the name of the org after consent is reached
-- @funciton rename_org_consent
function rename_org_consent:complete()
modpol.interactions.message_org(
self.initiator,

View File

@ -38,7 +38,7 @@ module_template.config = {
-- <li><code>self.initiator</code> (the user that callced the module),</li>
-- <li><code>self.id</code> (the process id of the module instance)</li>
-- @param result (optional) Callback if this module is embedded in other modules
-- @function initiate
-- @function module_template:initiate
function module_template:initiate(result)
-- call interaction functions here!

View File

@ -1,7 +1,12 @@
--- Miscellaneous functions
-- @module modpol.util.misc
modpol.util = {}
--- @function modpol.copy_table
-- Returns a copy of the table inputted
--- Returns a copy of the table inputted
-- @function modpol.util.copy_table
-- @param t table to copy
-- @return copy of table
function modpol.util.copy_table(t)
local t2 = {}
for k,v in pairs(t) do
@ -10,8 +15,10 @@ function modpol.util.copy_table(t)
return t2
end
--- @function modpol.copy_table
-- Returns the number of elements in a pairs table
--- Returns the number of elements in a pairs table
-- @function modpol.util.num_pairs
-- @param t pairs table
-- @return number of elements in pairs table
function modpol.util.num_pairs(t)
local i = 0
for k,v in pairs(t) do