Skip to content

zhu-rengong/EmmyLuaDocxgen

Repository files navigation

English | 简体中文

EmmyLua Doc Generator

This tool loads C# assemblies and converts their types into EmmyLua documentation following the standards of xLua and the LuaLS.

Features

  • Loads DLL assemblies based on .NET reflection
  • Includes type annotations
    • @enum name: Enums, mapped as table
    • @class name : base, interface, ...: Classes, supports base classes and interfaces
  • Includes members
    • field: Fields
    • property: Properties
    • indexer: Indexers
    • method: Methods, supports overloads, async, generics automatically interpreted by xLua, optional parameters, and variable parameters
    • constructor: Constructors, with the same level of support as above
    • @operator: Operator overloads, supports add, sub, mul, div, unm
  • Member access modifiers
    • @private: Private members
    • @protected: Protected members
    • @package: Internal members within the assembly
  • Composite Type Mapping
    • TValue this[TKey idx]: { [TKey]: TValue }
    • IEnumerable<T>, IEnumerator<T>: { [nil]: T }
    • Nullable<T>: T|nil
  • Delegate types are automatically converted to function types
  • Unrecognized userdata is mapped as composite types to provide more precise code hints

Usage

1. Create a configuration file

Create a JSON configuration file (refer to config.json):

{
  "assemblies": [
    {
      "path": "path/to/assembly.dll",
      "types": [
        "Namespace.Type1",
        "Namespace.Type2",
        "*"
      ]
    }
  ],
  "outputDir": "output"
}

Configuration Explanation

  • assemblies - List of assemblies to load
    • path - Path to the DLL file (supports relative or absolute paths)
    • types - List of types to generate documentation for (generics are not supported)
      • "NS1.NS2.ClassName" - Specify the full type name
      • "NS1.NS2.ClassName+NestedClass" - Nested types
  • outputDir - Output directory (defaults to "output")

2. Run the generator

dotnet run -- config.json

3. Generated Example

Dependencies

  • .NET 8.0 or higher

Notes

  • Generated documentation uses the CS. prefix for namespaces, consistent with xLua
  • Lua keywords are automatically escaped (e.g., and becomes __and__)
  • Except for the key generics, other types are mapped as userdata
  • Compiler-generated members are automatically filtered out
  • The first parameter type for operator overloads must be the same as the declaring class
  • Multidimensional indexers are not supported

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages