Skip to content

Commit 358376f

Browse files
committed
Fix #34: parsing of @see annotations with LuaLs
1 parent 99e76c0 commit 358376f

File tree

5 files changed

+69
-3
lines changed

5 files changed

+69
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
- Fixed parsing of `@see` annotations with LuaLs backend.
6+
57
## [3.6.0] - 2025-10-17
68

79
- Adjusted styles for links in object signatures to match those produced by python domain.

sphinx_lua_ls/objtree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _parse_docstring(self):
153153
else:
154154
rejected_see_lines.append(see_line)
155155
else:
156-
if match := re.match(
156+
if match := re.search(
157157
r"""
158158
^
159159
See:[ ]
@@ -169,6 +169,7 @@ def _parse_docstring(self):
169169
):
170170
typ = match.group("type") or match.group("rejected_type")
171171
doc = match.group("doc") or match.group("rejected_doc") or ""
172+
doc = doc.strip()
172173
if doc:
173174
doc = ": " + doc
174175
see_lines.append(f":lua:obj:`{typ}`{doc}")

test/roots/test-autodoc/lua/annotations.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,27 @@ function annotations.annotation_async() end
2525
--- @deprecated
2626
function annotations.annotation_deprecated() end
2727

28+
--- Description.
2829
--- @see annotations text
2930
--- @deprecated
3031
function annotations.see_one() end
3132

33+
--- Description.
3234
--- @see xyz text
3335
--- @deprecated
3436
function annotations.see_one_broken() end
3537

38+
--- Description.
3639
--- @see annotations.annotation_private text 1
3740
--- @see annotations.annotation_protected text 2
3841
--- @deprecated
3942
function annotations.see_many() end
4043

44+
--- Description.
4145
--- @see xyz text 1
4246
--- @see abc text 2
4347
--- @deprecated
4448
function annotations.see_many_broken() end
49+
50+
--- @see load
51+
function annotations.see_no_text() end

test/roots/test-autodoc/src/annotations.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ Annotations
2323
2424
.. lua:autoobject:: see_many_broken
2525
26+
.. lua:autoobject:: see_no_text
27+
2628
Ref: :lua:obj:`annotation_deprecated`.

test/test_regression/autodoc-annotations.html

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@
238238
<br/>
239239
</dt>
240240
<dd>
241+
<p>
242+
Description.
243+
</p>
241244
<p>
242245
See
243246
<a class="reference internal" href="#lua-annotations" title="annotations">
@@ -247,7 +250,7 @@
247250
</span>
248251
</code>
249252
</a>
250-
: text
253+
: text
251254
</p>
252255
<dl class="field-list simple">
253256
</dl>
@@ -281,14 +284,17 @@
281284
<br/>
282285
</dt>
283286
<dd>
287+
<p>
288+
Description.
289+
</p>
284290
<p>
285291
See
286292
<code class="xref lua lua-obj docutils literal notranslate">
287293
<span class="pre">
288294
xyz
289295
</span>
290296
</code>
291-
: text
297+
: text
292298
</p>
293299
<dl class="field-list simple">
294300
</dl>
@@ -322,6 +328,9 @@
322328
<br/>
323329
</dt>
324330
<dd>
331+
<p>
332+
Description.
333+
</p>
325334
<p>
326335
See:
327336
</p>
@@ -383,6 +392,9 @@
383392
<br/>
384393
</dt>
385394
<dd>
395+
<p>
396+
Description.
397+
</p>
386398
<p>
387399
See:
388400
</p>
@@ -412,6 +424,48 @@
412424
</dl>
413425
</dd>
414426
</dl>
427+
<dl class="lua function">
428+
<dt class="sig sig-object lua" id="lua-annotations.see_no_text">
429+
<span class="sig-prename descclassname">
430+
<span class="pre">
431+
annotations.
432+
</span>
433+
</span>
434+
<span class="sig-name descname">
435+
<span class="pre">
436+
see_no_text
437+
</span>
438+
</span>
439+
<span class="p">
440+
<span class="pre">
441+
(
442+
</span>
443+
</span>
444+
<span class="p">
445+
<span class="pre">
446+
)
447+
</span>
448+
</span>
449+
<a class="headerlink" href="#lua-annotations.see_no_text" title="Link to this definition">
450+
451+
</a>
452+
<br/>
453+
</dt>
454+
<dd>
455+
<p>
456+
See
457+
<a class="reference external" href="https://www.lua.org/manual/5.4/manual.html#pdf-load">
458+
<code class="xref lua lua-obj docutils literal notranslate">
459+
<span class="pre">
460+
load
461+
</span>
462+
</code>
463+
</a>
464+
</p>
465+
<dl class="field-list simple">
466+
</dl>
467+
</dd>
468+
</dl>
415469
<p>
416470
Ref:
417471
<a class="reference internal" href="#lua-annotations.annotation_deprecated" title="annotations.annotation_deprecated">

0 commit comments

Comments
 (0)