sphinx-lua-ls 1.0.0__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. sphinx_lua_ls-2.0.0/CHANGELOG.md +46 -0
  2. {sphinx_lua_ls-1.0.0/sphinx_lua_ls.egg-info → sphinx_lua_ls-2.0.0}/PKG-INFO +3 -2
  3. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/docs/example/logging.lua +2 -1
  4. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/docs/source/conf.py +4 -16
  5. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/docs/source/index.rst +250 -42
  6. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/pyproject.toml +3 -2
  7. sphinx_lua_ls-2.0.0/sphinx_lua_ls/__init__.py +321 -0
  8. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/sphinx_lua_ls/_version.py +2 -2
  9. sphinx_lua_ls-2.0.0/sphinx_lua_ls/apidoc.py +151 -0
  10. sphinx_lua_ls-2.0.0/sphinx_lua_ls/autodoc.py +686 -0
  11. sphinx_lua_ls-2.0.0/sphinx_lua_ls/autoindex.py +137 -0
  12. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/sphinx_lua_ls/domain.py +225 -188
  13. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/sphinx_lua_ls/intersphinx.py +1 -1
  14. sphinx_lua_ls-1.0.0/sphinx_lua_ls/doctree.py → sphinx_lua_ls-2.0.0/sphinx_lua_ls/objtree.py +259 -53
  15. sphinx_lua_ls-2.0.0/sphinx_lua_ls/static/lua.css +7 -0
  16. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0/sphinx_lua_ls.egg-info}/PKG-INFO +3 -2
  17. sphinx_lua_ls-2.0.0/sphinx_lua_ls.egg-info/SOURCES.txt +101 -0
  18. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/sphinx_lua_ls.egg-info/requires.txt +1 -1
  19. sphinx_lua_ls-2.0.0/test/conftest.py +63 -0
  20. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/Makefile +20 -0
  21. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/conf.py +5 -0
  22. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/index.rst +14 -0
  23. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/lua/annotations.lua +44 -0
  24. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/lua/member_ordering.lua +24 -0
  25. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/lua/module_title.lua +9 -0
  26. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/lua/nested_modules.lua +14 -0
  27. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/lua/nesting.lua +57 -0
  28. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/lua/object_types.lua +139 -0
  29. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/lua/relative_resolve.lua +20 -0
  30. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/make.bat +35 -0
  31. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/annotations.rst +26 -0
  32. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/autoindex.rst +12 -0
  33. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/member_ordering.rst +40 -0
  34. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/module_title.rst +28 -0
  35. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/nested_modules.rst +8 -0
  36. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/nesting.rst +77 -0
  37. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/nesting_recursive.rst +78 -0
  38. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/object_types.rst +8 -0
  39. sphinx_lua_ls-2.0.0/test/roots/test-autodoc/src/relative_resolve.rst +6 -0
  40. {sphinx_lua_ls-1.0.0/test/roots/test-doc → sphinx_lua_ls-2.0.0/test/roots/test-autodoc-roots}/Makefile +1 -1
  41. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-roots/conf.py +5 -0
  42. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-roots/index.rst +7 -0
  43. {sphinx_lua_ls-1.0.0/test/roots/test-doc → sphinx_lua_ls-2.0.0/test/roots/test-autodoc-roots}/make.bat +1 -1
  44. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-roots/root_1/autodoc.lua +7 -0
  45. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-roots/root_2/autodoc.lua +7 -0
  46. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-settings/Makefile +20 -0
  47. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-settings/conf.py +5 -0
  48. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-settings/index.rst +6 -0
  49. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-settings/lua/autodoc.lua +11 -0
  50. sphinx_lua_ls-2.0.0/test/roots/test-autodoc-settings/make.bat +35 -0
  51. sphinx_lua_ls-2.0.0/test/roots/test-doc/Makefile +20 -0
  52. sphinx_lua_ls-2.0.0/test/roots/test-doc/conf.py +6 -0
  53. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/test/roots/test-doc/index.rst +2 -3
  54. sphinx_lua_ls-2.0.0/test/roots/test-doc/make.bat +35 -0
  55. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/test/roots/test-doc/mod.lua +11 -2
  56. sphinx_lua_ls-2.0.0/test/roots/test-doc/src/annotations.rst +18 -0
  57. sphinx_lua_ls-2.0.0/test/roots/test-doc/src/autoindex.rst +37 -0
  58. sphinx_lua_ls-2.0.0/test/roots/test-doc/src/directives.rst +178 -0
  59. sphinx_lua_ls-2.0.0/test/roots/test-doc/src/intersphinx.rst +6 -0
  60. sphinx_lua_ls-2.0.0/test/roots/test-doc/src/modules.rst +28 -0
  61. sphinx_lua_ls-2.0.0/test/roots/test-doc/src/refs.rst +78 -0
  62. sphinx_lua_ls-2.0.0/test/roots/test-intersphinx/Makefile +20 -0
  63. sphinx_lua_ls-2.0.0/test/roots/test-intersphinx/conf.py +6 -0
  64. sphinx_lua_ls-2.0.0/test/roots/test-intersphinx/index.rst +6 -0
  65. sphinx_lua_ls-2.0.0/test/roots/test-intersphinx/make.bat +35 -0
  66. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-annotations.html +381 -0
  67. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-autoindex.html +960 -0
  68. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-member_ordering.html +614 -0
  69. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-module_title.html +105 -0
  70. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-nested_modules.html +66 -0
  71. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-nesting.html +474 -0
  72. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-nesting_recursive.html +958 -0
  73. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-object_types.html +1918 -0
  74. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-relative_resolve.html +65 -0
  75. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-roots-default.html.html +65 -0
  76. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-roots-no-roots.html.html +2 -0
  77. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-roots-single-root.html.html +35 -0
  78. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-settings-annotation.html.html +84 -0
  79. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-settings-no-recursion.html.html +36 -0
  80. sphinx_lua_ls-2.0.0/test/test_regression/autodoc-settings-simple.html.html +70 -0
  81. sphinx_lua_ls-2.0.0/test/test_regression/doc-annotations.html +96 -0
  82. sphinx_lua_ls-2.0.0/test/test_regression/doc-autoindex.html +178 -0
  83. sphinx_lua_ls-2.0.0/test/test_regression/doc-directives.html +2117 -0
  84. sphinx_lua_ls-2.0.0/test/test_regression/doc-modules.html +120 -0
  85. sphinx_lua_ls-2.0.0/test/test_regression/doc-refs.html +375 -0
  86. sphinx_lua_ls-2.0.0/test/test_regression.py +153 -0
  87. sphinx_lua_ls-1.0.0/sphinx_lua_ls/__init__.py +0 -166
  88. sphinx_lua_ls-1.0.0/sphinx_lua_ls/autodoc.py +0 -632
  89. sphinx_lua_ls-1.0.0/sphinx_lua_ls.egg-info/SOURCES.txt +0 -85
  90. sphinx_lua_ls-1.0.0/test/conftest.py +0 -18
  91. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/doctrees/environment.pickle +0 -0
  92. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/doctrees/index.doctree +0 -0
  93. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/doctrees/src/annotations.doctree +0 -0
  94. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/doctrees/src/autodoc.doctree +0 -0
  95. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/doctrees/src/directives.doctree +0 -0
  96. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/doctrees/src/modules.doctree +0 -0
  97. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/doctrees/src/refs.doctree +0 -0
  98. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/.buildinfo +0 -4
  99. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_sources/index.rst.txt +0 -12
  100. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_sources/src/annotations.rst.txt +0 -16
  101. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_sources/src/autodoc.rst.txt +0 -7
  102. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_sources/src/directives.rst.txt +0 -132
  103. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_sources/src/modules.rst.txt +0 -22
  104. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_sources/src/refs.rst.txt +0 -68
  105. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/alabaster.css +0 -663
  106. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/basic.css +0 -906
  107. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/custom.css +0 -1
  108. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/doctools.js +0 -149
  109. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/documentation_options.js +0 -13
  110. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/file.png +0 -0
  111. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/github-banner.svg +0 -5
  112. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/language_data.js +0 -191
  113. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/minus.png +0 -0
  114. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/plus.png +0 -0
  115. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/pygments.css +0 -84
  116. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/searchtools.js +0 -635
  117. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/_static/sphinx_highlight.js +0 -154
  118. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/genindex.html +0 -356
  119. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/index.html +0 -127
  120. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/lua-modindex.html +0 -148
  121. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/objects.inv +0 -0
  122. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/py-modindex.html +0 -125
  123. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/search.html +0 -125
  124. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/searchindex.js +0 -1
  125. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/src/annotations.html +0 -123
  126. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/src/autodoc.html +0 -228
  127. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/src/directives.html +0 -333
  128. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/src/modules.html +0 -142
  129. sphinx_lua_ls-1.0.0/test/roots/test-doc/_build/html/src/refs.html +0 -190
  130. sphinx_lua_ls-1.0.0/test/roots/test-doc/conf.py +0 -5
  131. sphinx_lua_ls-1.0.0/test/roots/test-doc/src/annotations.rst +0 -16
  132. sphinx_lua_ls-1.0.0/test/roots/test-doc/src/autodoc.rst +0 -7
  133. sphinx_lua_ls-1.0.0/test/roots/test-doc/src/directives.rst +0 -132
  134. sphinx_lua_ls-1.0.0/test/roots/test-doc/src/modules.rst +0 -22
  135. sphinx_lua_ls-1.0.0/test/roots/test-doc/src/refs.rst +0 -68
  136. sphinx_lua_ls-1.0.0/test/test_regression/annotations.html +0 -106
  137. sphinx_lua_ls-1.0.0/test/test_regression/autodoc.html +0 -850
  138. sphinx_lua_ls-1.0.0/test/test_regression/directives.html +0 -1519
  139. sphinx_lua_ls-1.0.0/test/test_regression/modules.html +0 -111
  140. sphinx_lua_ls-1.0.0/test/test_regression/refs.html +0 -503
  141. sphinx_lua_ls-1.0.0/test/test_regression.py +0 -30
  142. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/.github/workflows/ci.yaml +0 -0
  143. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/.gitignore +0 -0
  144. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/.pre-commit-config.yaml +0 -0
  145. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/.vscode/settings.json +0 -0
  146. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/CONTRIBUTING.md +0 -0
  147. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/LICENSE +0 -0
  148. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/README.md +0 -0
  149. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/conftest.py +0 -0
  150. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/docs/Makefile +0 -0
  151. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/docs/make.bat +0 -0
  152. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/docs/source/_extra/robots.txt +0 -0
  153. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/setup.cfg +0 -0
  154. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/sphinx_lua_ls/lua_ls.py +0 -0
  155. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/sphinx_lua_ls/py.typed +0 -0
  156. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/sphinx_lua_ls.egg-info/dependency_links.txt +0 -0
  157. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/sphinx_lua_ls.egg-info/top_level.txt +0 -0
  158. {sphinx_lua_ls-1.0.0 → sphinx_lua_ls-2.0.0}/test/test_parse.py +0 -0
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ ## v2.0.0
4
+
5
+ - Breaking change: don't implicitly convert classes that're derived from `table`
6
+ to modules. Users should use a `!doctype` comment instead.
7
+ - Breaking change: disallow nesting modules inside classes.
8
+ - Added `autoindex` directive.
9
+ - Added `apidoc` functionality.
10
+ - Improved test coverage and fixed found bugs.
11
+
12
+ **Migrating to 2.0.0:**
13
+
14
+ In your Lua code base, perform global replace by regexp:
15
+
16
+ ```
17
+ ^(\s*)---\s*@class\s*(.+): table$
18
+ ```
19
+
20
+ to
21
+
22
+ ```
23
+ $1--- !doctype module
24
+ $1--- @class $2
25
+ ```
26
+
27
+ Make sure that you only use `!doctype module` on the top-level
28
+ tables that can be imported via `require`. On other objects,
29
+ use `!doctype table` instead, otherwise you'll get errors that modules are not allowed within other objects.
30
+
31
+ ## v1.1.0
32
+
33
+ - Added support for `!doc` and `!doctype` comments.
34
+ - Added `:include-protected:` and `:include-package:` options for `lua:autoobject`.
35
+ - Allowed referring `lua:const` objects from `lua:attr` role.
36
+ - Fixed a bug when default options would not properly propagate
37
+ when using `lua:autoobject` with `:recurse:`.
38
+ - Fixed a bug when `lua:autoobject` would deduce incorrect module paths
39
+ when applied to non-toplevel modules.
40
+ - Fixed a bug when docstring for a class would be used for undocumented function
41
+ parameters that have this class as their type.
42
+ - Fixed types when `lua:autoobject` would infer incorrect types for `data`.
43
+
44
+ ## v1.0.0
45
+
46
+ Initial release.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: sphinx-lua-ls
3
- Version: 1.0.0
3
+ Version: 2.0.0
4
4
  Summary: Automatic documentation generation via LuaLS
5
5
  Author-email: Tamika Nomara <taminomara@gmail.com>
6
6
  License: MIT License
@@ -28,6 +28,7 @@ License: MIT License
28
28
  Project-URL: Documentation, https://taminomara.github.io/sphinx-lua-ls/
29
29
  Project-URL: Issues, https://github.com/taminomara/sphinx-lua-ls/issues
30
30
  Project-URL: Source, https://github.com/taminomara/sphinx-lua-ls/
31
+ Project-URL: Changelog, https://github.com/taminomara/sphinx-lua-ls/blob/main/CHANGELOG.md
31
32
  Classifier: Development Status :: 5 - Production/Stable
32
33
  Classifier: Programming Language :: Python :: 3 :: Only
33
34
  Classifier: Programming Language :: Python :: 3
@@ -63,7 +64,7 @@ Requires-Dist: pytest-regressions~=2.7; extra == "test"
63
64
  Requires-Dist: beautifulsoup4~=4.13; extra == "test"
64
65
  Provides-Extra: doc
65
66
  Requires-Dist: sybil~=6.1; extra == "doc"
66
- Requires-Dist: pydata-sphinx-theme>=0.15; extra == "doc"
67
+ Requires-Dist: furo>=2024; extra == "doc"
67
68
  Requires-Dist: sphinx_design>=0.6; extra == "doc"
68
69
 
69
70
  # Sphinx plugin for Lua and Lua Language Server
@@ -3,7 +3,8 @@
3
3
  --- .. lua:autoobject:: LOG_LEVEL
4
4
  --- :global:
5
5
  ---
6
- --- @class logging: table
6
+ --- !doctype module
7
+ --- @class logging
7
8
  logging = {}
8
9
 
9
10
  --- Represents message severity.
@@ -27,22 +27,10 @@ lua_ls_project_root = "../example"
27
27
  # -- Options for HTML output -------------------------------------------------
28
28
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
29
29
 
30
- html_theme = "pydata_sphinx_theme"
30
+ html_theme = "furo"
31
31
  html_extra_path = ["_extra/robots.txt"]
32
32
  html_theme_options = {
33
- "use_edit_page_button": True,
34
- "icon_links": [
35
- {
36
- "name": "GitHub",
37
- "url": "https://github.com/taminomara/sphinx-lua-ls",
38
- "icon": "fa-brands fa-square-github",
39
- "type": "fontawesome",
40
- }
41
- ]
42
- }
43
- html_context = {
44
- "github_user": "taminomara",
45
- "github_repo": "sphinx-lua-ls",
46
- "github_version": "main",
47
- "doc_path": "docs/source",
33
+ "source_repository": "https://github.com/taminomara/sphinx-lua-ls",
34
+ "source_branch": "main",
35
+ "source_directory": "docs/source",
48
36
  }
@@ -127,6 +127,10 @@ and specify the location of your Lua project:
127
127
  # relative to the directory with `conf.py`.
128
128
  lua_ls_project_root = "../"
129
129
 
130
+ If you plan to use Markdown in code comments, install the `MySt`_ plugin for Sphinx.
131
+
132
+ .. _MySt: https://myst-parser.readthedocs.io/en/latest/index.html
133
+
130
134
  Quickstart
131
135
  ----------
132
136
 
@@ -220,6 +224,11 @@ Declaring objects
220
224
 
221
225
  Person's name.
222
226
 
227
+ .. rst:directive:: .. lua:table:: name
228
+
229
+ Directive for documenting tables that serve as namespaces.
230
+ It works like :rst:dir:`data`, but can contain nested members.
231
+
223
232
  .. rst:directive:: .. lua:function:: name(param: type) -> type
224
233
  .. lua:method:: name(param: type) -> type
225
234
  .. lua:classmethod:: name(param: type) -> type
@@ -283,6 +292,9 @@ Declaring objects
283
292
 
284
293
  This directive doesn't accept any content, it just creates an anchor.
285
294
 
295
+ Modules are something you can `require`. If you need to document a namespace
296
+ inside of a module, use a :rst:dir:`lua:table` instead.
297
+
286
298
  .. rst:directive:: .. lua:currentmodule:: name
287
299
 
288
300
  Switches current module without making an index entry or an anchor.
@@ -365,6 +377,11 @@ All directives that document Lua objects accept the standard parameters:
365
377
 
366
378
  Use ``name`` and ``surname`` instead.
367
379
 
380
+ .. rst:directive:option:: synopsis
381
+
382
+ Allows adding a small description that's reflected
383
+ in the :rst:dir:`lua:autoindex` output.
384
+
368
385
  .. rst:directive:option:: module
369
386
 
370
387
  Allows overriding current module for a single object. This is useful
@@ -439,44 +456,63 @@ Cross-referencing objects
439
456
 
440
457
  Reference to a `logging.Logger.info`.
441
458
 
442
- Autodoc directive
443
- -----------------
459
+ Autodoc directives
460
+ ------------------
444
461
 
445
462
  .. rst:directive:: .. lua:autoobject:: name
446
463
 
447
464
  You can automatically generate documentation for any object by invoking
448
465
  the :rst:dir:`lua:autoobject` directive.
449
466
 
450
- .. note::
467
+ Tables are exported as :rst:dir:`data` by default, meaning that their contents
468
+ are not documented.
451
469
 
452
- Autodoc will parse object comments as ReStructured Text, not as MarkDown.
470
+ To enable documentation within a table, annotate is as a class.
471
+ You can change how autodoc infers its type by adding a ``!doctype`` comment.
453
472
 
454
- .. note::
473
+ Thus, a typical Lua module will look like this:
455
474
 
456
- Tables are exported as :rst:dir:`data` by default, meaning that their contents
457
- are not documented.
475
+ .. code-block:: lua
458
476
 
459
- To enable documentation within a table, document is as a class.
460
- If you inherit it from `table`, autodoc will treat it as a module.
461
- Thus, a typical Lua module will look like this:
477
+ --- This is a module. Notice that we've declared it as a class
478
+ --- and added a `doctype`.
479
+ ---
480
+ --- !doctype module
481
+ --- @class library
482
+ local library = {}
462
483
 
463
- .. code-block:: lua
484
+ --- Nested namespaces should also be declared as classes.
485
+ ---
486
+ --- !doctype table
487
+ --- @class library.namespace
488
+ library.namespace = {}
489
+
490
+ --- Other objects are documented as usual.
491
+ function library.foo() end
492
+
493
+ --- And so on...
494
+ function library.namespace.bar() end
495
+
496
+ return library
497
+
498
+ .. note::
499
+
500
+ By default, autodoc will parse object comments as ReStructured Text,
501
+ not as MarkDown. If you plan to use Markdown in code comments,
502
+ install the `MySt`_ plugin for Sphinx and invoke include
503
+ :rst:dir:`lua:autoobject` from a markdown file.
464
504
 
465
- --- This is a module. Notice that we've declared it as a class
466
- --- inherited from `table`.
467
- ---
468
- --- @class library: table
469
- local library = {}
505
+ Make sure to separate comment markers from documentation with a space.
506
+ Otherwise, autodoc will not be able to tell your comments apart from content
507
+ automatically generated by Lua Language Server:
470
508
 
471
- --- Submodules should also be declared as classes.
472
- ---
473
- --- @class library.submodule: table
474
- library.submodule = {}
509
+ .. code-block:: lua
475
510
 
476
- --- Other objects are documented as usual.
477
- function library.foo() end
511
+ --- This is OK: separated by a space.
512
+ local x = 0;
478
513
 
479
- return library
514
+ ---This is NOT OK: no separation.
515
+ local x = 0;
480
516
 
481
517
  .. warning::
482
518
 
@@ -487,7 +523,7 @@ Autodoc directive
487
523
 
488
524
  2. ``@deprecated`` markers do not add any note to the documentation.
489
525
  We recommend providing an explicit message
490
- with the :rst:dir:`deprecated` directive.
526
+ with the ``deprecated`` directive.
491
527
 
492
528
  3. ``@nodiscard`` and ``@operator`` markers are not exported.
493
529
 
@@ -498,13 +534,17 @@ Autodoc directive
498
534
 
499
535
  --- Instead of enums, we use aliases.
500
536
  ---
501
- --- @alias LogLevel integer
502
- LogLevel = {}
503
-
504
- --- Alias members are declared as usual.
505
- LogLevel.Debug = 1
506
-
537
+ --- .. lua:data:: Debug
538
+ ---
539
+ --- Document alias members in its body.
540
+ ---
507
541
  --- And so on...
542
+ ---
543
+ --- @alias LogLevel integer
544
+ LogLevel = {
545
+ Debug = 1,
546
+ -- ...
547
+ }
508
548
 
509
549
  :rst:dir:`lua:autoobject` supports same settings as other lua directives,
510
550
  as well as some additional ones:
@@ -512,7 +552,7 @@ Autodoc directive
512
552
  .. rst:directive:option:: members
513
553
 
514
554
  If enabled, autodoc will also document object's members. You can pass a list
515
- of coma-separated names to specify which members should be documented.
555
+ of comma-separated names to specify which members should be documented.
516
556
  Otherwise, this option will document all public non-special members
517
557
  which have a description.
518
558
 
@@ -521,22 +561,36 @@ Autodoc directive
521
561
  Include undocumented members to the object's description. By default,
522
562
  they are skipped even if :rst:dir:`members` is passed.
523
563
 
564
+ Accepts a comma-separated list of names; if list is empty,
565
+ adds all undoc members.
566
+
524
567
  .. rst:directive:option:: private-members
568
+ protected-members
569
+ package-members
525
570
 
526
571
  Include non-public members to the object's description.
527
572
 
573
+ Accepts a comma-separated list of names; if list is empty,
574
+ adds all non-public members.
575
+
528
576
  .. rst:directive:option:: special-members
529
577
 
530
578
  Include special members to the object's description. That is, generate
531
579
  documentation for members whose names start with double underscore.
532
580
 
581
+ Accepts a comma-separated list of names; if list is empty,
582
+ adds all special members.
583
+
533
584
  .. rst:directive:option:: inherited-members
534
585
 
535
586
  For classes, includes members inherited from base classes.
536
587
 
588
+ Accepts a comma-separated list of names; if list is empty,
589
+ adds all inherited members.
590
+
537
591
  .. rst:directive:option:: exclude-members
538
592
 
539
- A coma-separated list of members that should not be documented.
593
+ A comma-separated list of members that should not be documented.
540
594
 
541
595
  .. rst:directive:option:: recursive
542
596
 
@@ -544,13 +598,20 @@ Autodoc directive
544
598
  for all objects nested within the root. That is, object's members,
545
599
  their members, and so on.
546
600
 
547
- Settings for :rst:dir:undoc-members, :rst:dir:private-members,
548
- :rst:dir:special-members, and :rst:dir:inherited-members are applied
549
- to all documented objects.
601
+ If :rst:dir:`lua:autoobject:undoc-members`,
602
+ :rst:dir:`lua:autoobject:private-members`,
603
+ :rst:dir:`lua:autoobject:special-members`,
604
+ or :rst:dir:`lua:autoobject:inherited-members`
605
+ are given as flags, they are propagated to all documented objects.
606
+
607
+ If they're given as list, they are not propagated.
608
+
609
+ Options from :py:data:`lua_ls_default_options` are applied to all recursively
610
+ documented objects.
550
611
 
551
612
  .. rst:directive:option:: member-order
552
613
 
553
- Controls how items are sorted. There are three options available:
614
+ Controls how members are sorted. There are three options available:
554
615
 
555
616
  - ``alphabetical``: members are sorted in lexicographical order of their names;
556
617
 
@@ -566,6 +627,98 @@ Autodoc directive
566
627
  for enums (``@enum``). If ordering by source, enums will be placed
567
628
  at the end of the documentation.
568
629
 
630
+ .. rst:directive:option:: module-member-order
631
+
632
+ Overrides :rst:dir:`lua:autoobject:member-order` for modules.
633
+
634
+ .. rst:directive:option:: title
635
+
636
+ For modules, controls whether a title is inserted between module description
637
+ and documentation of its members.
638
+
639
+ .. rst:directive:option:: index-table
640
+
641
+ Adds :rst:dir:`lua:autoindex` to the toplevel module.
642
+
643
+ .. rst:directive:option:: index-title
644
+
645
+ Allows overriding title of the :rst:dir:`lua:autoindex` section.
646
+
647
+ .. rst:directive:: .. lua:autoindex:: name
648
+
649
+ Creates a table that references all documented objects in the module ``name``.
650
+ This is useful for creating module's table of contents.
651
+
652
+ Module name must be absolute, even if this directive appears after
653
+ :rst:dir:`lua:module`.
654
+
655
+ Controlling generation from code comments
656
+ -----------------------------------------
657
+
658
+ When using :rst:dir:`lua:autoobject` in recursive mode, it is sometimes necessary
659
+ to override its options for some objects. To do this, you can include specially
660
+ formatted comments to your documentation.
661
+
662
+ To override any :rst:dir:`lua:autoobject` setting for a particular object,
663
+ use ``!doc`` comments. For example, here we enable :rst:dir:`lua:autoobject:special-members`
664
+ and exclude ``__tostring`` for class ``Foo``:
665
+
666
+ .. code-block:: lua
667
+
668
+ --- Some class documentation...
669
+ ---
670
+ --- !doc special-members
671
+ --- !doc exclude-members: __tostring
672
+ --- @class Foo
673
+
674
+ You can also specify which type of object is being documented by using
675
+ a ``!doctype`` comment. For example, here we use ``!doctype const`` to indicate
676
+ that a certain variable should be documented as :rst:dir:`lua:const`:
677
+
678
+ .. code-block:: lua
679
+
680
+ --- Some const documentation...
681
+ ---
682
+ --- !doctype const
683
+ --- @type string
684
+ foo = "bar!"
685
+
686
+ .. _apidoc:
687
+
688
+ Automatic API reference generation
689
+ ----------------------------------
690
+
691
+ :rst:dir:`lua:autoobject` allows recursively generating documentation,
692
+ however it all ends up on a single page. If you want to give a separate page
693
+ for every module, you'll need to create multiple ``.rst`` files.
694
+ Fortunately, Lua autodoc can do this for you.
695
+
696
+ Add :py:data:`lua_ls_apidoc_roots` option to the ``conf.py``, and provide a mapping
697
+ from module names to directories (relative to the location of ``conf.py``)
698
+ where generated ``.rst`` files should be placed.
699
+
700
+ For example, to generate API reference for module ``moduleName``
701
+ in directory ``moduleDirectory``, add the following:
702
+
703
+ .. code-block:: python
704
+
705
+ lua_ls_apidoc_roots = {
706
+ "moduleName": "moduleDirectory",
707
+ }
708
+
709
+ Upon start, autodoc will recursively create ``.rst`` files in ``moduleDirectory``.
710
+ ``moduleDirectory/index.rst`` will contain reference for ``moduleName``.
711
+ Then, for every submodule of ``moduleName``, there will be another ``.rst`` generated.
712
+
713
+ .. warning::
714
+
715
+ Do not add any other files to ``moduleDirectory``, otherwise they will be deleted.
716
+
717
+ It is best to add ``moduleDirectory`` to your ``.gitignore`` file.
718
+
719
+ Don't forget to include ``moduleDirectory/index.rst`` into a table of contents
720
+ in your main ``index.rst``.
721
+
569
722
  Settings
570
723
  --------
571
724
 
@@ -606,12 +759,12 @@ Settings
606
759
  .. code-block:: python
607
760
 
608
761
  lua_ls_default_options = {
609
- # Enable documentation for object's members.
610
- # Empty string means documenting all members with non-empty description.
611
- "members": "",
612
- # Set ordering of automatically generated content to alphabetical.
613
- "member-order": "alphabetical",
614
- # And so on...
762
+ # Enable documentation for object's members.
763
+ # Empty string means documenting all members with non-empty description.
764
+ "members": "",
765
+ # Set ordering of automatically generated content to alphabetical.
766
+ "member-order": "alphabetical",
767
+ # And so on...
615
768
  }
616
769
 
617
770
  .. py:data:: lua_ls_lua_version: str
@@ -619,6 +772,61 @@ Settings
619
772
  Controls which documentation version is used when linking
620
773
  to standard library functions. Does not otherwise affect parsing or generation.
621
774
 
775
+ .. py:data:: lua_ls_apidoc_roots: dict[str, str | dict[str, Any]]
776
+
777
+ Roots for `apidoc <automatic generation of API files>`_. Keys are full module names
778
+ that should be generated, and values are directories (relative to the location
779
+ of ``conf.py``) where ``.rst`` files are placed.
780
+
781
+ Additionally, you can override other apidoc settings for each root. For this,
782
+ make root's value a dictionary with keys ``path``,
783
+ :py:data:`max_depth <lua_ls_apidoc_max_depth>`,
784
+ :py:data:`options <lua_ls_apidoc_default_options>`,
785
+ and :py:data:`ignored_modules <lua_ls_apidoc_ignored_modules>`:
786
+
787
+ .. code-block:: python
788
+
789
+ lua_ls_apidoc_roots = {
790
+ "moduleName": {
791
+ "path": "moduleDirectory",
792
+ "max_depth": 2,
793
+ "options": {
794
+ "undoc-members": "",
795
+ }
796
+ },
797
+ }
798
+
799
+ .. py:data:: lua_ls_apidoc_default_options: dict[str, str]
800
+
801
+ Default options for objects documented via apidoc. Override
802
+ :py:data:`lua_ls_default_options`.
803
+
804
+ .. py:data:: lua_ls_apidoc_max_depth: int
805
+
806
+ Maximum nesting level for files. Submodules that are deeper than this level
807
+ will not get their own file, and instead will be generated inline.
808
+
809
+ Default value is ``4``.
810
+
811
+ .. py:data:: lua_ls_apidoc_ignored_modules: list[str]
812
+
813
+ List of full submodule names that should be ignored while generating APIs.
814
+ Submodules can contain :py:mod:`fnmatch` style globs.
815
+
816
+ For example, the following setting
817
+
818
+ .. code-block:: python
819
+
820
+ lua_ls_apidoc_roots = {
821
+ "moduleName": "moduleDirectory",
822
+ }
823
+
824
+ lua_ls_apidoc_ignored_modules = [
825
+ "moduleName.submoduleName"
826
+ ]
827
+
828
+ will generate API for module ``moduleName``, but will not include
829
+ ``moduleName.submoduleName``.
622
830
 
623
831
  Example output
624
832
  --------------
@@ -47,7 +47,7 @@ test = [
47
47
  ]
48
48
  doc = [
49
49
  "sybil~=6.1",
50
- "pydata-sphinx-theme>=0.15",
50
+ "furo>=2024",
51
51
  "sphinx_design>=0.6"
52
52
  ]
53
53
 
@@ -55,9 +55,10 @@ doc = [
55
55
  Documentation = "https://taminomara.github.io/sphinx-lua-ls/"
56
56
  Issues = "https://github.com/taminomara/sphinx-lua-ls/issues"
57
57
  Source = "https://github.com/taminomara/sphinx-lua-ls/"
58
+ Changelog = "https://github.com/taminomara/sphinx-lua-ls/blob/main/CHANGELOG.md"
58
59
 
59
60
  [build-system]
60
- requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel>=0.40"]
61
+ requires = ["setuptools>=60", "setuptools_scm[toml]>=8", "wheel>=0.40"]
61
62
 
62
63
  [tool.setuptools_scm]
63
64
  write_to = "sphinx_lua_ls/_version.py"