Skip to content

Commit a97823d

Browse files
committed
Apply faces.
1 parent c599af3 commit a97823d

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

docstr-faces.el

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

docstr.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
;; Author: Shen, Jen-Chieh <[email protected]>
77
;; Description: A document string minor mode.
88
;; Keyword: document string
9-
;; Version: 0.1.0
9+
;; Version: 5.2.0
1010
;; Package-Requires: ((emacs "24.4") (s "1.9.0"))
1111
;; URL: https://github.com/jcs-elpa/docstr
1212

@@ -39,6 +39,7 @@
3939

4040
(require 'docstr-util)
4141
(require 'docstr-writers)
42+
(require 'docstr-faces)
4243

4344
(defgroup docstr nil
4445
"A document string minor mode."

0 commit comments

Comments
 (0)