Skip to content

Commit c1e068d

Browse files
committed
Fix parsing of EmmyLua output
1 parent 358376f commit c1e068d

File tree

5 files changed

+11
-19
lines changed

5 files changed

+11
-19
lines changed

docs/source/autodoc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Autodoc directives
228228
.. rst:directive:option:: class-doc-from: class | ctor | both | separate
229229
230230
Specifies how to generate documentation for classes
231-
if :py:data:`class_default_function_name` is configured.
231+
if :py:data:`lua_ls_class_default_function_name` is configured.
232232
233233
Options are:
234234
@@ -245,7 +245,7 @@ Autodoc directives
245245
.. rst:directive:option:: class-signature: bases | ctor | both | minimal
246246
247247
Specifies how to generate signatures for classes
248-
if :py:data:`class_default_function_name` is configured.
248+
if :py:data:`lua_ls_class_default_function_name` is configured.
249249
250250
Options are:
251251

docs/source/settings.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Settings
8989
.. lua:autoobject:: foo
9090
:no-undoc-members:
9191
92-
.. py:data:: class_default_function_name
92+
.. py:data:: lua_ls_class_default_function_name
9393
:type: str
9494

9595
Allows specifying which class method represents a class constructor.
@@ -98,22 +98,16 @@ Settings
9898
:rst:dir:`lua:autoobject:class-doc-from`
9999
and :rst:dir:`lua:autoobject:class-signature` options.
100100

101-
If using EmmyLua as lua analyzer, this option will be inferred from ``.emmyrc.json``.
102-
103-
.. py:data:: class_default_force_non_colon
101+
.. py:data:: lua_ls_class_default_force_non_colon
104102
:type:
105103

106104
If ``True``, Sphinx-LuaLs will remove ``self`` from class constructor's signature.
107105

108-
If using EmmyLua as lua analyzer, this option will be inferred from ``.emmyrc.json``.
109-
110-
.. py:data:: class_default_force_return_self
106+
.. py:data:: lua_ls_class_default_force_return_self
111107
:type:
112108

113109
If ``True``, Sphinx-LuaLs will replace class constructor's return type with ``self``.
114110

115-
If using EmmyLua as lua analyzer, this option will be inferred from ``.emmyrc.json``.
116-
117111
.. py:data:: lua_ls_lua_version
118112
:type: str
119113

sphinx_lua_ls/objtree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,8 @@ class EmmyLuaParser(Parser):
962962
def parse(self, json, path: str | pathlib.Path):
963963
self.path = pathlib.Path(path).expanduser().resolve()
964964

965-
class_default_config = json["config"]["runtime"]["classDefaultCall"]
966-
if class_default_config["functionName"]:
965+
class_default_config = json["config"]["runtime"].get("classDefaultCall")
966+
if class_default_config and class_default_config.get("functionName"):
967967
self.class_default_function_name = class_default_config["functionName"]
968968
self.class_default_force_non_colon = class_default_config["forceNonColon"]
969969
self.class_default_force_return_self = class_default_config[

test/roots/test-autodoc-emmylua/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
extensions = ["sphinx_lua_ls"]
66
lua_ls_backend = "emmylua"
77
lua_ls_project_root = "lua"
8+
lua_ls_class_default_function_name = "__init"
9+
lua_ls_class_default_force_non_colon = True
10+
lua_ls_class_default_force_return_self = True

test/roots/test-autodoc-emmylua/lua/.emmyrc.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@
3434
"requireLikeFunction": [],
3535
"frameworkVersions": [],
3636
"extensions": [],
37-
"requirePattern": [],
38-
"classDefaultCall": {
39-
"functionName": "__init",
40-
"forceNonColon": true,
41-
"forceReturnSelf": true
42-
}
37+
"requirePattern": []
4338
},
4439
"workspace": {
4540
"ignoreDir": [],

0 commit comments

Comments
 (0)