[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog 0a58409a4c: Fix docs for predicate at point in
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/sweeprolog 0a58409a4c: Fix docs for predicate at point in DCG bodies |
|
Date: |
Fri, 24 Nov 2023 07:00:21 -0500 (EST) |
branch: elpa/sweeprolog
commit 0a58409a4c5404ee349654fde66dd7742a4f4e73
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
Fix docs for predicate at point in DCG bodies
* sweep.pl (sweep_short_documentation_body/9): Add special handling
for control constructs in DCG bodies.
* sweeprolog-tests.el (eldoc-dcg): New test.
---
sweep.pl | 8 ++++++++
sweeprolog-tests.el | 33 ++++++++++++++++++++++++++-------
2 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/sweep.pl b/sweep.pl
index 21fb0f6449..cb99ee6392 100644
--- a/sweep.pl
+++ b/sweep.pl
@@ -375,6 +375,14 @@ sweep_short_documentation_body(Pos, Body, Neck, Point,
FileName, Mod, PIString,
Neck > 0,
!,
sweep_short_documentation_body(Pos, Body, 0, Point, FileName, Mod,
PIString, Doc, ArgSpan).
+sweep_short_documentation_body(term_position(_, _, _, _, ArgsPos), Body, '//',
Point, FileName, Mod, PIString, Doc, ArgSpan) :-
+ is_control_goal(Body),
+ !,
+ nth1(Index, ArgsPos, ArgPos),
+ pos_bounds(ArgPos, ArgBeg, ArgEnd),
+ ArgBeg =< Point, Point =< ArgEnd,
+ arg(Index, Body, ArgBody),
+ sweep_short_documentation_body(ArgPos, ArgBody, '//', Point, FileName,
Mod, PIString, Doc, ArgSpan).
sweep_short_documentation_body(term_position(_, _, _, _, ArgsPos), Body, Neck,
Point, FileName, Mod, PIString, Doc, ArgSpan) :-
!,
( nth1(Index, ArgsPos, ArgPos),
diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el
index 595b89e030..5c57520ab3 100644
--- a/sweeprolog-tests.el
+++ b/sweeprolog-tests.el
@@ -2254,8 +2254,8 @@ bbb(A, B) :-
")))
(sweeprolog-deftest extract-region-to-predicate-ext-1 ()
- "Test `sweeprolog-extract-region-to-predicate'."
- "
+ "Test `sweeprolog-extract-region-to-predicate'."
+ "
:- module(bbb, []).
bar(A, Y) :-
@@ -2316,17 +2316,17 @@ bbb(VarName) :-
")))
(sweeprolog-deftest extract-region-to-predicate-lambda-2 ()
- "Test `sweeprolog-extract-region-to-predicate'."
- "
+ "Test `sweeprolog-extract-region-to-predicate'."
+ "
:- module(bbb, []).
bar(A, Y) :-
maplist({GoalVarNames}/[VarName]>>ignore(memberchk(VarName, GoalVarNames)),
TemplateVarNames).
"
- (sweeprolog-extract-region-to-predicate 48 114 "bbb")
- (should (string= (buffer-string)
- "
+ (sweeprolog-extract-region-to-predicate 48 114 "bbb")
+ (should (string= (buffer-string)
+ "
:- module(bbb, []).
bar(A, Y) :-
@@ -2336,4 +2336,23 @@ bar(A, Y) :-
bbb(GoalVarNames, VarName) :-
ignore(memberchk(VarName, GoalVarNames)).
")))
+
+(sweeprolog-deftest eldoc-dcg ()
+ "Test `sweep_short_documentation/2' with DCG body terms."
+ "
+:- module(eldocdcg, []).
+
+%! foo(-Baz:string)// is det.
+%
+% Doit.
+
+foo(Bar) --> baz(Bar).
+"
+ (should (equal (sweeprolog--query-once
+ "sweep" "sweep_short_documentation"
+ (list "bar --> foo(bar), foo(baz)." 12 (buffer-file-name)))
+ (list "eldocdcg:foo//1" "foo(-Baz:string)// is det.
+ Doit.
+" (cons 4 15)))))
+
;;; sweeprolog-tests.el ends here
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/sweeprolog 0a58409a4c: Fix docs for predicate at point in DCG bodies,
ELPA Syncer <=