]> gitweb.factorcode.org Git - factor.git/commitdiff
help.lint.spaces: new vocab
authorAlexander Iljin <ajsoft@yandex.ru>
Mon, 5 Jun 2017 17:17:57 +0000 (20:17 +0300)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 5 Jun 2017 20:16:07 +0000 (13:16 -0700)
basis/help/lint/spaces/authors.txt [new file with mode: 0644]
basis/help/lint/spaces/spaces.factor [new file with mode: 0644]

diff --git a/basis/help/lint/spaces/authors.txt b/basis/help/lint/spaces/authors.txt
new file mode 100644 (file)
index 0000000..8e1955f
--- /dev/null
@@ -0,0 +1 @@
+Alexander Ilin
diff --git a/basis/help/lint/spaces/spaces.factor b/basis/help/lint/spaces/spaces.factor
new file mode 100644 (file)
index 0000000..54dd5cf
--- /dev/null
@@ -0,0 +1,28 @@
+! Copyright (C) 2017 Alexander Ilin.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays combinators.short-circuit formatting io
+io.directories.search io.encodings.utf8 io.files io.pathnames
+kernel math namespaces prettyprint sequences ui.gadgets.panes
+vocabs.loader ;
+
+IN: help.lint.spaces
+
+: all-docs-files ( -- seq )
+    vocab-roots get [
+        recursive-directory-files [ "-docs.factor" tail? ] filter
+    ] map concat ;
+
+: lint-spaces ( -- )
+    all-docs-files [
+        dup utf8 file-lines [ 1 + 2array ] map-index
+        [
+            first [
+                { [ CHAR: space = ] [ CHAR: " = ] } 1||
+            ] trim-head
+            "  " swap subseq?
+        ] filter
+        [ drop ] [
+            swap <pathname> .
+            [ first2 swap "%d: %s\n" printf ] each
+        ] if-empty
+    ] each ;