unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript
@ 2024-06-25  9:52 Vincenzo Pupillo
  2024-06-27  9:45 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Vincenzo Pupillo @ 2024-06-25  9:52 UTC (permalink / raw)
  To: 71771

[-- Attachment #1: Type: text/plain, Size: 171 bytes --]

Hi, 
this patch add support for embedding jsdoc into inline javascript element.

Thanks

Vincenzo

p.s. Damien's patch broke php-ts-mode if jsdoc parser is not installed.

[-- Attachment #2: 0001-Add-jsdoc-support-to-php-ts-mode-in-script-element.patch --]
[-- Type: text/x-patch, Size: 2500 bytes --]

From 31e4f30c4a7f867e1bb690a0f53918326b7aaa00 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Tue, 25 Jun 2024 11:29:54 +0200
Subject: [PATCH] Add jsdoc support to php-ts-mode in <script> element

In the <script> element, enable jsdoc embedding in javascript.

* lisp/progmodes/php-ts-mode.el
(php-ts-mode--language-source-alist): Add jsdoc to parser recipe.

* lisp/progmodes/php-ts-mode.el (php-ts-mode):
Add jsdoc parser check and a new rule for treesit-range-settings.

* lisp/progmodes/php-ts-mode.el: Updated the commentary section.
---
 lisp/progmodes/php-ts-mode.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el
index 826c131ca70..8eade9ef112 100644
--- a/lisp/progmodes/php-ts-mode.el
+++ b/lisp/progmodes/php-ts-mode.el
@@ -36,6 +36,7 @@
 ;; * https://github.com/tree-sitter/tree-sitter-php
 ;; * https://github.com/tree-sitter/tree-sitter-html
 ;; * https://github.com/tree-sitter/tree-sitter-javascript
+;; * https://github.com/tree-sitter/tree-sitter-jsdoc
 ;; * https://github.com/tree-sitter/tree-sitter-css
 ;; * https://github.com/claytonrcarter/tree-sitter-phpdoc
 ;;
@@ -86,6 +87,7 @@ php-ts-mode--language-source-alist
     (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc"))
     (html . ("https://github.com/tree-sitter/tree-sitter-html"  "v0.20.3"))
     (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2"))
+    (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.21.0"))
     (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.21.0")))
   "Treesitter language parsers required by `php-ts-mode'.
 You can customize this variable if you want to stick to a specific
@@ -1296,6 +1298,7 @@ php-ts-mode
             (treesit-ready-p 'phpdoc)
             (treesit-ready-p 'html)
             (treesit-ready-p 'javascript)
+            (treesit-ready-p 'jsdoc)
             (treesit-ready-p 'css)))
       (error "Tree-sitter for PHP isn't
     available.  You can install the parsers with M-x
@@ -1334,6 +1337,11 @@ php-ts-mode
                     (start_tag (tag_name))
                     (raw_text) @cap))
 
+                 :embed 'jsdoc
+                 :host 'javascript
+                 `(((comment) @capture
+                    (:match ,js--treesit-jsdoc-beginning-regexp @capture)))
+
                  :embed 'css
                  :host 'html
                  :offset '(1 . -1)
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript
  2024-06-25  9:52 bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript Vincenzo Pupillo
@ 2024-06-27  9:45 ` Eli Zaretskii
  2024-06-27 10:29   ` Vincenzo Pupillo
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-06-27  9:45 UTC (permalink / raw)
  To: Vincenzo Pupillo; +Cc: 71771

> From: Vincenzo Pupillo <v.pupillo@gmail.com>
> Date: Tue, 25 Jun 2024 11:52:20 +0200
> 
> this patch add support for embedding jsdoc into inline javascript element.

Thanks, but is this for the master branch or for the emacs-30 release
branch?  Where was php-ts-mode broken?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript
  2024-06-27  9:45 ` Eli Zaretskii
@ 2024-06-27 10:29   ` Vincenzo Pupillo
  2024-06-27 19:44     ` Vincenzo Pupillo
  2024-06-28  0:52     ` Dmitry Gutov
  0 siblings, 2 replies; 7+ messages in thread
From: Vincenzo Pupillo @ 2024-06-27 10:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71771

In data giovedì 27 giugno 2024 11:45:54 CEST, Eli Zaretskii ha scritto:
> > From: Vincenzo Pupillo <v.pupillo@gmail.com>
> > Date: Tue, 25 Jun 2024 11:52:20 +0200
> > 
> > this patch add support for embedding jsdoc into inline javascript element.
> 
> Thanks, but is this for the master branch or for the emacs-30 release
> branch?  Where was php-ts-mode broken?
Hi Eli, 
this is for the master branch.
jsdoc is not available in emacs-30. 
Thanks.
V.








^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript
  2024-06-27 10:29   ` Vincenzo Pupillo
@ 2024-06-27 19:44     ` Vincenzo Pupillo
  2024-06-28  0:52     ` Dmitry Gutov
  1 sibling, 0 replies; 7+ messages in thread
From: Vincenzo Pupillo @ 2024-06-27 19:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71771

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

In data giovedì 27 giugno 2024 12:29:40 CEST, Vincenzo Pupillo ha scritto:
> In data giovedì 27 giugno 2024 11:45:54 CEST, Eli Zaretskii ha scritto:
> > > From: Vincenzo Pupillo <v.pupillo@gmail.com>
> > > Date: Tue, 25 Jun 2024 11:52:20 +0200
> > > 
> > > this patch add support for embedding jsdoc into inline javascript
> > > element.
> > 
> > Thanks, but is this for the master branch or for the emacs-30 release
> > branch?  Where was php-ts-mode broken?
> 
> Hi Eli,
> this is for the master branch.
> jsdoc is not available in emacs-30.
> Thanks.
> V.
php-ts-mode was broken because the js--treesit-font-lock-settings variable now 
contains rules for jsdoc, a parser that php-ts-mode did not use.
I fixed the patch because, as I wrote for bug 71776, the jsdoc parser is 
local, just like the phpdoc parser.
 The screenshot I attach is the result of this patch and the two from bug 
71776.

Thanks.
Vincenzo

[-- Attachment #2: 0001-Add-jsdoc-support-to-php-ts-mode-in-script-element.patch --]
[-- Type: text/x-patch, Size: 2520 bytes --]

From 03eca8bd6cb19871e6ac86fb2559088a9a0fd8a9 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Tue, 25 Jun 2024 11:29:54 +0200
Subject: [PATCH] Add jsdoc support to php-ts-mode in <script> element

In the <script> element, enable jsdoc embedding in javascript.

* lisp/progmodes/php-ts-mode.el
(php-ts-mode--language-source-alist): Add jsdoc to parser recipe.

* lisp/progmodes/php-ts-mode.el (php-ts-mode):
Add jsdoc parser check and a new rule for treesit-range-settings.

* lisp/progmodes/php-ts-mode.el: Updated the commentary section.
---
 lisp/progmodes/php-ts-mode.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el
index 826c131ca70..1298b39311b 100644
--- a/lisp/progmodes/php-ts-mode.el
+++ b/lisp/progmodes/php-ts-mode.el
@@ -36,6 +36,7 @@
 ;; * https://github.com/tree-sitter/tree-sitter-php
 ;; * https://github.com/tree-sitter/tree-sitter-html
 ;; * https://github.com/tree-sitter/tree-sitter-javascript
+;; * https://github.com/tree-sitter/tree-sitter-jsdoc
 ;; * https://github.com/tree-sitter/tree-sitter-css
 ;; * https://github.com/claytonrcarter/tree-sitter-phpdoc
 ;;
@@ -86,6 +87,7 @@ php-ts-mode--language-source-alist
     (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc"))
     (html . ("https://github.com/tree-sitter/tree-sitter-html"  "v0.20.3"))
     (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2"))
+    (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.21.0"))
     (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.21.0")))
   "Treesitter language parsers required by `php-ts-mode'.
 You can customize this variable if you want to stick to a specific
@@ -1296,6 +1298,7 @@ php-ts-mode
             (treesit-ready-p 'phpdoc)
             (treesit-ready-p 'html)
             (treesit-ready-p 'javascript)
+            (treesit-ready-p 'jsdoc)
             (treesit-ready-p 'css)))
       (error "Tree-sitter for PHP isn't
     available.  You can install the parsers with M-x
@@ -1334,6 +1337,12 @@ php-ts-mode
                     (start_tag (tag_name))
                     (raw_text) @cap))
 
+                 :embed 'jsdoc
+                 :host 'javascript
+                 :local t
+                 `(((comment) @cap
+                    (:match ,js--treesit-jsdoc-beginning-regexp @cap)))
+
                  :embed 'css
                  :host 'html
                  :offset '(1 . -1)
-- 
2.45.2


[-- Attachment #3: php_with_jsdoc_20240627_152341.png --]
[-- Type: image/png, Size: 27659 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript
  2024-06-27 10:29   ` Vincenzo Pupillo
  2024-06-27 19:44     ` Vincenzo Pupillo
@ 2024-06-28  0:52     ` Dmitry Gutov
  2024-06-28  8:00       ` Vincenzo Pupillo
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2024-06-28  0:52 UTC (permalink / raw)
  To: Vincenzo Pupillo, Eli Zaretskii; +Cc: 71771

On 27/06/2024 13:29, Vincenzo Pupillo wrote:
> this is for the master branch.
> jsdoc is not available in emacs-30.

To be clear, js-ts-mode's jsdoc integration is in emacs-30.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript
  2024-06-28  0:52     ` Dmitry Gutov
@ 2024-06-28  8:00       ` Vincenzo Pupillo
  2024-06-29 12:09         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Vincenzo Pupillo @ 2024-06-28  8:00 UTC (permalink / raw)
  To: Eli Zaretskii, Dmitry Gutov; +Cc: 71771

In data venerdì 28 giugno 2024 02:52:41 CEST, Dmitry Gutov ha scritto:
> On 27/06/2024 13:29, Vincenzo Pupillo wrote:
> > this is for the master branch.
> > jsdoc is not available in emacs-30.
> 
> To be clear, js-ts-mode's jsdoc integration is in emacs-30.
> 
Whoops, I missed it.
This patch also works with emacs-30.

Thanks.
Vincenzo







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript
  2024-06-28  8:00       ` Vincenzo Pupillo
@ 2024-06-29 12:09         ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2024-06-29 12:09 UTC (permalink / raw)
  To: Vincenzo Pupillo; +Cc: dmitry, 71771-done

> From: Vincenzo Pupillo <v.pupillo@gmail.com>
> Cc: 71771@debbugs.gnu.org
> Date: Fri, 28 Jun 2024 10:00:30 +0200
> 
> In data venerdì 28 giugno 2024 02:52:41 CEST, Dmitry Gutov ha scritto:
> > On 27/06/2024 13:29, Vincenzo Pupillo wrote:
> > > this is for the master branch.
> > > jsdoc is not available in emacs-30.
> > 
> > To be clear, js-ts-mode's jsdoc integration is in emacs-30.
> > 
> Whoops, I missed it.
> This patch also works with emacs-30.

Thanks, installed on emacs-30, and closing the bug.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-06-29 12:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-25  9:52 bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript Vincenzo Pupillo
2024-06-27  9:45 ` Eli Zaretskii
2024-06-27 10:29   ` Vincenzo Pupillo
2024-06-27 19:44     ` Vincenzo Pupillo
2024-06-28  0:52     ` Dmitry Gutov
2024-06-28  8:00       ` Vincenzo Pupillo
2024-06-29 12:09         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).