|
| 1 | +;;; docstr-faces.el --- Faces for document string -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2020 Shen, Jen-Chieh <[email protected]> |
| 4 | + |
| 5 | +;; This file is NOT part of GNU Emacs. |
| 6 | + |
| 7 | +;; This program is free software; you can redistribute it and/or modify |
| 8 | +;; it under the terms of the GNU General Public License as published by |
| 9 | +;; the Free Software Foundation, either version 3 of the License, or |
| 10 | +;; (at your option) any later version. |
| 11 | + |
| 12 | +;; This program is distributed in the hope that it will be useful, |
| 13 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +;; GNU General Public License for more details. |
| 16 | + |
| 17 | +;; You should have received a copy of the GNU General Public License |
| 18 | +;; along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +;;; Commentary: |
| 21 | +;; |
| 22 | +;; Faces for document string. |
| 23 | +;; |
| 24 | + |
| 25 | +;;; Code: |
| 26 | + |
| 27 | +(defface docstr-tag-face |
| 28 | + '((t (:foreground "SlateGray"))) |
| 29 | + "Highlighting for Docstring tag." |
| 30 | + :group 'docstr) |
| 31 | +(defvar docstr-tag-face 'docstr-tag-face) |
| 32 | + |
| 33 | +(defface docstr-type-face |
| 34 | + '((t (:foreground "SteelBlue"))) |
| 35 | + "Highlighting for Docstring type." |
| 36 | + :group 'docstr) |
| 37 | +(defvar docstr-type-face 'docstr-type-face) |
| 38 | + |
| 39 | +(defface docstr-value-face |
| 40 | + '((t (:foreground "gold4"))) |
| 41 | + "Highlighting for Docstring value." |
| 42 | + :group 'docstr) |
| 43 | +(defvar docstr-value-face 'docstr-value-face) |
| 44 | + |
| 45 | +(defun docstr-apply-faces () |
| 46 | + "Apply standard document string faces." |
| 47 | + (dolist (mode (docstr-major-modes)) |
| 48 | + (font-lock-add-keywords |
| 49 | + mode |
| 50 | + '(;; `@param` { typename } val-tag : value tag description.. |
| 51 | + ("\\(?:^\\|\\s-\\)\\(@[^ \"'{}()\t\r\n]+\\)" 1 'docstr-tag-face t) |
| 52 | + ;; @param `{ typename }` val-tag : value tag description.. |
| 53 | + ("[ \t]+@[^ \t\r\n]+\\(?:^\\|\\s-\\)\\([\\[{][^}]*.\\)" 1 'docstr-type-face t) |
| 54 | + ;; @param { typename } `val-tag` : value tag description.. |
| 55 | + ("[ \t]+@[^ \t\r\n].*[\]\|}]\\([^\r\n]*\\)[:-]" 1 'docstr-value-face t) |
| 56 | + ;; @param `val-tag` : value tag description.. |
| 57 | + ("[ \t]+@[^ \t\r\n]*[ \t]*\\([a-zA-Z0-9_.*&]*\\)[ \t\n]*[{:-]" 1 'docstr-value-face t)) |
| 58 | + 'end))) |
| 59 | + |
| 60 | +(provide 'docstr-faces) |
| 61 | +;;; docstr-faces.el ends here |
0 commit comments