Skip to content

Commit c10ccb9

Browse files
committed
code: new command checkdoc
1 parent 4021335 commit c10ccb9

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

cmds/checkdoc.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (C) 2022 Jen-Chieh Shen
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with GNU Emacs; see the file COPYING. If not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+
* Boston, MA 02110-1301, USA.
18+
*/
19+
20+
"use strict";
21+
22+
const util = require("../src/util");
23+
24+
exports.command = ['checkdoc [files..]', 'lint-checkdoc [files..]'];
25+
exports.desc = 'run checkdoc';
26+
exports.builder = {
27+
files: {
28+
description: 'files you want checkdoc to run on',
29+
requiresArg: false,
30+
type: 'array',
31+
},
32+
};
33+
34+
exports.handler = async (argv) => {
35+
await util.e_call(argv, 'checkdoc', argv.files);
36+
};

lisp/checkdoc.el

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
;;; checkdoc.el --- Run checkdoc -*- lexical-binding: t; -*-
2+
3+
;;; Commentary:
4+
;;
5+
;; Commmand use to run `checkdoc' for all files
6+
;;
7+
;; $ eask checkdoc
8+
;;
9+
10+
;;; Code:
11+
12+
(load (expand-file-name
13+
"_prepare.el"
14+
(file-name-directory (nth 1 (member "-scriptload" command-line-args))))
15+
nil t)
16+
17+
(defun eask--checkdoc-print-error (text start end &optional unfixable)
18+
"Print error for checkdoc."
19+
(let ((msg (concat (checkdoc-buffer-label) ":"
20+
(int-to-string (count-lines (point-min) (or start (point-min))))
21+
": " text)))
22+
(if (eask-strict-p) (error msg) (warn msg))
23+
;; Return nil because we *are* generating a buffered list of errors.
24+
nil))
25+
26+
(setq checkdoc-create-error-function #'eask--checkdoc-print-error)
27+
28+
(eask-start
29+
(if-let ((files (eask-args)))
30+
(mapcar #'checkdoc-file files)
31+
(message "You need to specify the file you want the checkdoc to run on")
32+
(message "For example,")
33+
(message " eask checkdoc FILE-1 FILE-2")))
34+
35+
;;; checkdoc.el ends here

0 commit comments

Comments
 (0)