Skip to main content

py-lua-doc

travis Pypi Versions

A Lua documentation extraction tool written in Python that support emmy-lua and ldoc doc-comment.

It's both a development library and a command line tool.

Given a lua source file, it creates a documentation model.

Installation

The package can be installed through pip:

$ pip3 install luadoc

It will install the shell command 'luadoc'.

How to generate documentation ?

This project is part of a Sphinx documentation plugin: sphinx-lua

Node Structure

The node structure is for now only described in model.py

Command Line

The command line tool just serialize the tree to Json.

Given:

--- @class foo.Base
local Base = {}


--- @class foo.List: foo.Base
local List = {}

--- Apply a function to all elements.
--- Any extra arguments will be passed to the function.
--- @param fun fun(a:any):any a function of at least one argument
--- @vararg any @arbitrary extra arguments.
--- @return foo.List a new list: {f(x) for x in self}
function List:map(fun, ...) end

--- Split a string using a delim.
--- @param delim string the delim (default " ")
--- @overload fun()
function List:split(delim) end


return List
$ luadoc source.lua

The following output will be produced:

{
    "filename": "test.lua",
    "classes": [
        {
            "name": "foo.Base",
            "name_in_source": "Base",
            "methods": [],
            "desc": "",
            "usage": "",
            "inherits_from": [],
            "fields": []
        },
        {
            "name": "foo.List",
            "name_in_source": "List",
            "methods": [
                {
                    "name": "map",
                    "short_desc": "Apply a function to all elements.",
                    "desc": "Any extra arguments will be passed to the function.",
                    "params": [
                        {
                            "name": "fun",
                            "desc": "a function of at least one argument",
                            "type": {
                                "id": "callable",
                                "arg_types": [
                                    {
                                        "id": "any"
                                    }
                                ],
                                "return_types": [
                                    {
                                        "id": "any"
                                    }
                                ]
                            },
                            "is_opt": false,
                            "default_value": ""
                        },
                        {
                            "name": "...",
                            "desc": "arbitrary extra arguments.",
                            "type": {
                                "id": "any"
                            },
                            "is_opt": false,
                            "default_value": ""
                        }
                    ],
                    "returns": [
                        {
                            "desc": "a new list: {f(x) for x in self}",
                            "type": {
                                "id": "custom",
                                "name": "foo.List"
                            }
                        }
                    ],
                    "usage": "",
                    "is_virtual": false,
                    "is_abstract": false,
                    "is_deprecated": false,
                    "is_static": false,
                    "visibility": "public"
                },
                {
                    "name": "split",
                    "short_desc": "Split a string using a delim.",
                    "desc": "",
                    "params": [
                        {
                            "name": "delim",
                            "desc": "the delim (default \" \")",
                            "type": {
                                "id": "string"
                            },
                            "is_opt": false,
                            "default_value": ""
                        }
                    ],
                    "returns": [],
                    "usage": "",
                    "is_virtual": false,
                    "is_abstract": false,
                    "is_deprecated": false,
                    "is_static": false,
                    "visibility": "public"
                },
                {
                    "name": "split",
                    "short_desc": "Split a string using a delim.",
                    "desc": "",
                    "params": [],
                    "returns": [],
                    "usage": "",
                    "is_virtual": false,
                    "is_abstract": false,
                    "is_deprecated": false,
                    "is_static": false,
                    "visibility": "public"
                }
            ],
            "desc": "",
            "usage": "",
            "inherits_from": [
                "foo.Base"
            ],
            "fields": []
        }
    ],
    "functions": [],
    "data": [],
    "name": "unknown",
    "is_class_mod": false,
    "short_desc": "",
    "desc": "",
    "usage": ""
}

Many other examples can be seen in luadoc/tests/source.

Release files for luadoc 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for luadoc 1.3.2
File Size Uploaded
luadoc-1.3.2.tar.gz 31.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for luadoc 1.3.2
File Interpreter ABI Platform
luadoc-1.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 64.2 kB

Release files / luadoc-1.3.2.tar.gz

Download URL luadoc-1.3.2.tar.gz
Size 31.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2ec65258d58f6224f14300e8c19f4969c7a56994b3cf84e8d13e197b0e54b2b4
BLAKE2b-256 checksum
How to use checksums
5839d5e685f7c27e1c89a3ec086bcbe46e916b1102b5071380ae32d7414503b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / luadoc-1.3.2-py3-none-any.whl

Download URL luadoc-1.3.2-py3-none-any.whl
Size 32.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd073bdbd2f687116e60db9c6a09e78702274902d3aa6b90ec259e5f53e237b5
BLAKE2b-256 checksum
How to use checksums
625ff6f61b05e99cd5e00de9cd705cc498bcbd030d6376c9b85a405870a4823c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

1.4.1

2 release files

1.3.3

2 release files

This release

1.3.2 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page