Adding travis
[wolf] / src / main / syntax-checker.lisp
index 9a0716d6351c41fdd108b7b13a039b82d8688313..79cf0f53ca41a6bcb9e37fb2f57a0105bc1ab962 100644 (file)
@@ -1,27 +1,5 @@
 (in-package #:syntax-checker)
 
-; Rules
-; * Elements on new line in each form must be indented the same amount
-; * No space/newline after open parens
-; * No form longer than 50 lines
-; * Top level multiline forms must be separated by exactly one space
-; * No line longer than 120 characters
-; * No use of unexported symbols in other packages
-; * No tabs
-; * Only one space between elements in a form on a single line
-; * in-package must be first line in file unless file is package.lisp
-; * No whitespace at end of line
-; * No lines that are only whitespace
-; * No empty lines at end of file
-; * Never have two empty lines in a row
-; * Only one in-package per file
-; * No hanging close parens
-;
-; Exceptions
-; * comments
-; * multiline strings
-; * exclude in-package check from package.lisp
-
 ; Some thoughts
 ; - form starting reader macros will have to be hand added to this code
 ; - exceptions will eventually arise, and the rule file will have to be changed
   (let ((seq (make-sequence sequence-type (file-length str)))) (read-sequence seq str) seq)))
 
 (defun check-file (file)
+ "CHECK-FILE FILE => RESULT
+
+  RESULT: SUCCESS-RESULT | FAILURE-RESULT
+  SUCCESS-RESULT: (:success FILENAME)
+  FAILURE-RESULT: (:success FILENAME MSG LINE-NO COL-NO)
+
+ARGUMENTS AND VALUES
+
+  FILE: a pathname
+  FILENAME: the file this check was run on
+  MSG: a string containing the failure message
+  LINE-NO: an integer, the line number on which the failure appeared
+  COL-NO: an integer, the column number on which the failure appeared
+
+DESCRIPTION:
+
+  CHECK-FILE runs all the checks against a file and returns
+  as soon as the first style error is found.
+
+EXAMPLES:
+
+  (check-file #P\"path/to/file.lisp\") => (:success \"path/to/file.lisp\")
+  (check-file #P\"path/to/error.lisp\") => (:failure \"path/to/error.lisp\" \"File cannot end with empty line\" 20 0)"
+
  (if (string= "package" (pathname-name file))
   (set-state :normal)
   (set-state :begin))