Skip to content

Commit bd3f3c6

Browse files
committed
Don't consider a comment after docs-comment a documentation
As described in the test and the commentary, PureScript doesn't consider a "no-bar" comment that follows documentation part of the documentation. It is an explicitly documented behavior that is different from Haskell.
1 parent e0e33fd commit bd3f3c6

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

purescript-font-lock.el

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,6 @@ that should be commented under LaTeX-style literate scripts."
363363
:type 'boolean
364364
:group 'purescript)
365365

366-
(defvar purescript-font-lock-seen-docstring nil)
367-
(make-variable-buffer-local 'purescript-font-lock-seen-docstring)
368-
369366
(defvar purescript-literate)
370367

371368
(defun purescript-syntactic-face-function (state)
@@ -383,31 +380,16 @@ that should be commented under LaTeX-style literate scripts."
383380
;; b) {-^ ... -}
384381
;; c) -- | ...
385382
;; d) -- ^ ...
386-
;; e) -- ...
387-
;; Where `e' is the tricky one: it is only a docstring comment if it
388-
;; follows immediately another docstring comment. Even an empty line
389-
;; breaks such a sequence of docstring comments. It is not clear if `e'
390-
;; can follow any other case, so I interpreted it as following only cases
391-
;; c,d,e (not a or b). In any case, this `e' is expensive since it
392-
;; requires extra work for each and every non-docstring comment, so I only
393-
;; go through the more expensive check if we've already seen a docstring
394-
;; comment in the buffer.
383+
384+
;; Worth pointing out purescript opted out of ability to continue
385+
;; docs-comment by omitting an empty line like in Haskell, see:
386+
;; https://github.com/purescript/documentation/blob/master/language/Syntax.md
387+
;; IOW, given a `-- | foo' line followed by `-- bar' line, the latter is a
388+
;; plain comment.
395389
((and purescript-font-lock-docstrings
396390
(save-excursion
397391
(goto-char (nth 8 state))
398-
(or (looking-at "\\(-- \\|{-\\)[ \\t]*[|^]")
399-
(and purescript-font-lock-seen-docstring
400-
(looking-at "-- ")
401-
(let ((doc nil)
402-
pos)
403-
(while (and (not doc)
404-
(setq pos (line-beginning-position))
405-
(forward-comment -1)
406-
(eq (line-beginning-position 2) pos)
407-
(looking-at "--\\( [|^]\\)?"))
408-
(setq doc (match-beginning 1)))
409-
doc)))))
410-
(set (make-local-variable 'purescript-font-lock-seen-docstring) t)
392+
(looking-at "\\(-- \\|{-\\)[ \\t]*[|^]")))
411393
'font-lock-doc-face)
412394
(t 'font-lock-comment-face)))
413395

tests/purescript-font-lock-tests.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ this = \"still a string\"
102102

103103
(ert-deftest docs-bar-comment-different-spacings ()
104104
(purescript-test-ranges
105-
"-- | Docs comment space
105+
"-- | Docs comment 1 space
106106
-- | Docs comment many spaces
107107
"
108108
'((1 57 font-lock-doc-face))))
@@ -112,7 +112,6 @@ this = \"still a string\"
112112
https://github.com/purescript/documentation/blob/master/language/Syntax.md
113113
PureScript explicitly doesn't support Haskell-style docs continuation
114114
where vertical bar is omitted"
115-
:expected-result :failed
116115
(purescript-test-ranges
117116
"-- | Docs start
118117
-- continue

0 commit comments

Comments
 (0)