DocZ is the documentation generator used by FrameworkZ. It parses special comment tags to generate HTML documentation automatically. FrameworkZ uses DocZ comments extensively to document its API, modules, classes, functions, and more.
FrameworkZ API - Documentation
📋 On This Page
- Overview
- Writing Documentation for FrameworkZ
- Comment Prefixes
- Basic Structure
- @brief or \brief
- @class or \class
- @module or \module
- @library or \library
- @core or \core
- @param or \param
- @return or \return
- @field or \field
- @note or \note
- @see or \see
- @page or \page
- @section or \section
- @code or \code
- Type Annotations
- Complete Example
- Best Practices
- Generating Documentation
Documentation
This is a complete guide to documenting FrameworkZ code with DocZ tags. Here you'll learn about the various comment tags, type annotations, and best practices for writing clear, comprehensive documentation.
Writing Documentation for FrameworkZ
Comment Prefixes
DocZ recognizes two comment styles for documentation:
--! This is a DocZ comment (recommended)
--- This is also a DocZ comment (alternative)
Use --! for documentation comments. Regular -- comments are ignored by DocZ (notice how there is one less dash compared to the alternative DocZ comment).
Basic Structure
--! \brief Short one-line description of the function
--! Detailed description that can span
--! multiple lines and provide more context.
--! \param paramName \type Description of parameter
--! \return \type Description of return value
function MyModule:DoSomething(paramName)
-- implementation
end
@brief or \brief
Creates a brief description for what's being documented.
Tag: @brief or \brief [short description (one line)]
--! \brief Gets the player's character by username
@class or \class
Defines a class. Classes are objects that are used in instantiation.
Tag: @class or \class [class name]
--! \brief Player class for managing player data
--! \class PLAYER
local PLAYER = {}
PLAYER.__index = PLAYER
@module or \module
Defines a module. Modules are framework extensions that provide specific functionality that are intended for core systems.
Tag: @module or \module [module scope/name]
--! \brief Characters module for FrameworkZ
--! \module FrameworkZ.Characters
FrameworkZ.Characters = {}
@library or \library
Defines a library. Libraries are collections of utility functions that are meant for general use or code reuse.
Tag: @library or \library [library scope/name]
--! \brief Utility functions for common operations
--! \library FrameworkZ.Utilities
FrameworkZ.Utilities = {}
@core or \core
Defines a core system. Core systems are essential framework components that provide foundational functionality.
Tag: @core or \core [core system scope/name]
--! \brief Core FrameworkZ foundational systems.
--! \core FrameworkZ.Foundation
FrameworkZ.Foundation = {}
@param or \param
Short for parameter. Documents function parameters that are passed in when called.
Tag: @param or \param [paramName] \[paramType] [description]
--! \param username \string The player's username
--! \param level \integer The new level to set (1-100)
--! \param callback \function Optional callback when complete
function SetPlayerLevel(username, level, callback)
-- implementation
end
@return or \return
Documents return values from functions when called.
Tag: @return or \return [returnType] [description]
--! \return \boolean It will always return true.
--! \return \string Success message.
function TrySomething()
return true, "Success!"
end
@field or \field
Documents table fields at specific indexes.
Tag: @field or \field [fieldName] \[fieldType] [description]
FrameworkZ = {}
--! \field NetworkName \string Unique identifier for the network system used internally.
FrameworkZ.NetworkName = "FZ_NETWORK"
@note or \note
Tag: @note or \note [note text]
Important notes or warnings messages about the documented item. These will be displayed prominently in the generated documentation.
-- [e.g. standard function documentation here]
--! \note This function only works on the server side. Call this before initializing the character.
@see or \see
Cross-references to related documentation(s).
Tag: @see or \see [related item]
--! \see FrameworkZ.Players
--! \see CHARACTER:GetName
--! \see Getting Started
@page or \page
Creates a documentation page (like this one).
Tag: @page or \page [page name]
--! \page Getting Started
--! \brief Quick start guide for new developers
--!
--! \section Installation Installation
--! Follow these steps...
@section or \section
Creates a section within a page. The anchor ID must be unique and without spaces to allow navigation on the right side menu's quick navigation menu, search results, or cross-reference links.
Tag: @section or \section [section anchor ID] [section title]
--! \section Installation Installation
--! Download and install the framework...
@code or \code
Code blocks with syntax highlighting.
Tag: @code and @endcode or \code and \endcode
--! Example usage:
--! \code lua
--! local player = FrameworkZ.Players:GetPlayerByID("username")
--! if player then
--! print(player:GetName())
--! end
--! \endcode
Type Annotations
DocZ supports comprehensive type annotations:
Basic Types:
- \string - Text string
- \integer or \number - Numeric values
- \boolean or \bool - True or false
- \function - Function reference
- \table - Lua table
- \object - General object
- \any - Any type
- \nil - Nil value
Union Types (multiple possible types):
--! \return \string|\boolean Returns string on success, false on failure
--! \param data \table|\nil Optional data table
Optional Types:
--! \param callback \function? Optional callback function
--! \return \table|\nil Returns table or nil if not found
Complete Example
--! \brief Gets a character by their unique ID
--! Searches all active characters and returns the matching character object.
--! If no character is found, returns nil.
--! \param characterID \string The unique character ID to search for
--! \param includeOffline \boolean? Optional - include offline characters
--! \return \CHARACTER|\nil The character object if found, nil otherwise
--! \note This function searches all online players by default
--! \see FrameworkZ.Characters
--! \see CHARACTER:GetID
function FrameworkZ.Characters:GetCharacterByID(characterID, includeOffline)
-- implementation
end
Best Practices
DO:
- Document all public functions and methods
- Use clear, concise descriptions
- Specify exact types for parameters and returns
- Include usage examples for complex functions
- Cross-reference related documentation
- Note side effects and special conditions
- Document all table fields
DO NOT:
- Leave functions undocumented
- Use vague descriptions like "does stuff"
- Forget to document return values
- Use inconsistent type naming
- Document private/internal helpers unless they are part of a public API
- Duplicate documentation or leave TODOs unresolved
Generating Documentation
To generate documentation, run:
lua DocZ.lua -i ./FrameworkZ/media/lua -o ./docs -t "FrameworkZ API"
Command Line Options:
-i <path> - Input directory with Lua files
-o <path> - Output directory for HTML docs
-t <title> - Documentation title
-h - Show help