Skip to content

Commit

Permalink
code: impls declare
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Apr 29, 2022
1 parent 9375150 commit 04b3b51
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 4 deletions.
34 changes: 34 additions & 0 deletions cmds/lint/declare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (C) 2022 Jen-Chieh Shen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Emacs; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/

"use strict";

exports.command = ['declare [files..]', 'lint-declare [files..]'];
exports.desc = 'run declare';
exports.builder = {
files: {
description: 'files you want checkdoc to run on',
requiresArg: false,
type: 'array',
},
};

exports.handler = async (argv) => {
await UTIL.e_call(argv, 'lint/declare', argv.files);
};
17 changes: 17 additions & 0 deletions lisp/help/declare
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

💡 You need to specify file(s) you want the check-declare to run

$ eask declare FILE-1 FILE-2

💡 Or edit Eask file with [package-file] or [files] specifier

[+] (package-file "ENTRY") ; One argument with a string
[+] (files "FILE-1" "FILE-2" ...) ; All arguments are wildcard patterns

For example,

[+] (files "*.el")

💡 Tip: You can use the command [files] to show all selected files

$ eask files
8 changes: 4 additions & 4 deletions lisp/lint/checkdoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
(file-name-directory (nth 1 (member "-scriptload" command-line-args))))
nil t)

(defvar eask--checkdoc-error nil "Error flag.")
(defvar eask--checkdoc-errors nil "Error flag.")

(defun eask--checkdoc-print-error (text start end &optional unfixable)
"Print error for checkdoc."
(setq eask--checkdoc-error t)
(setq eask--checkdoc-errors t)
(let ((msg (concat (checkdoc-buffer-label) ":"
(int-to-string (count-lines (point-min) (or start (point-min))))
": " text)))
Expand All @@ -37,11 +37,11 @@
"Run checkdoc on FILENAME."
(let* ((filename (expand-file-name filename))
(file (eask-root-del filename))
(eask--checkdoc-error))
(eask--checkdoc-errors))
(eask-msg "")
(eask-msg "`%s` with checkdoc (%s)" (ansi-green file) checkdoc-version)
(checkdoc-file filename)
(unless eask--checkdoc-error (eask-msg "No issues found"))))
(unless eask--checkdoc-errors (eask-msg "No issues found"))))

(eask-start
(require 'checkdoc)
Expand Down
51 changes: 51 additions & 0 deletions lisp/lint/declare.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
;;; declare.el --- Run declare -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Commmand use to run `declare' for all files
;;
;; $ eask declare
;;
;;
;; Initialization options:
;;
;; [files..] files you want checkdoc to run on
;;

;;; Code:

(load (expand-file-name
"../_prepare.el"
(file-name-directory (nth 1 (member "-scriptload" command-line-args))))
nil t)

(defun eask--check-declare-file (filename)
"Run check-declare on FILENAME."
(let* ((filename (expand-file-name filename))
(file (eask-root-del filename))
(errors))
(eask-msg "")
(eask-msg "`%s` with check-declare" (ansi-green file))
(setq errors (check-declare-file filename))
(if errors
(with-current-buffer check-declare-warning-buffer
(eask-msg (buffer-string)))
(eask-msg "No issues found"))))

(eask-start
(require 'check-declare)
(if-let* ((files (if (eask-args)
(eask-expand-file-specs (eask-args))
(eask-package-el-files)))
(len (length files))
(s (eask--sinr len "" "s"))
(have (eask--sinr len "has" "have")))
(progn
(mapcar #'eask--check-declare-file files)
(eask-info "(Total of %s file%s %s checked)" len s have))
(eask-info "(No files have been checked (declare))")
(if (eask-args)
(eask--print-no-matching-files)
(eask-help 'declare))))

;;; declare.el ends here

0 comments on commit 04b3b51

Please sign in to comment.