How to write docs

To add documentation to a function, it's actually really easy.

You should add annotations on any function that is intended to be used elsewhere. You can also mark functions as internal, however, you can also just not document them if they're not meant to be used.

You simply add comments above the function, for example:

--- Gets an interaction by entity and id
-- @realm server
-- @param string The entity class to get the interaction from
-- @param id The id of the interaction
-- @return table The interaction
function cityrp.interaction.Get(class, id)
    return cityrp.interaction.registered[class][id]

If the file you're working on is a class, you can add special annotations to the top of the file alongside a description, this will show up at the start of the page. For example:

--- Interactions are a configurable menu that can appear on any entity when a user holds use on it.
-- If an entity has normal use functionality, behaviour will be modified to the following:
-- Hold E: Show interaction menu
-- Tap E: Regular entity use functionality
-- Don't register interactions in this file, do it in some plugin or something.
-- Data structure for an interaction looks like the following, everything is required unless otherwise stated:
--  data = {
--     id = "Interaction ID", -- The id of the interaction, must be unique for the given class
--     name = "Interaction Name", -- The name of the interaction
--     description = "Interaction Description", -- The description of the interaction
--     condition = function(client, ent) -- The condition to check if the interaction should be shown, do context dependent checks here
--         return true -- True if the interaction should be shown, false if not
--     end,
--     action = function(client, ent) -- The action to perform when the interaction is clicked
--         print("Clicked!")
--     end
-- }
-- @realm server
-- @module cityrp.interaction
-- @alias contextmenu
-- @warns Access, EyeTrace or other limiting checks MUST be put in conditions. interaction.Use does NOT check internally. It only checks distance and condition for an interaction.

I've also been working on a VSCode plugin that'll parse lua files and give autocomplete suggestions and intellisense based on EmmyLua annotations, so please do add them where you can!

Documentation topics such as this one are added into /docs/manual, it uses markdown for formatting.