]> gitweb.factorcode.org Git - factor.git/blob - basis/help/lint/spaces/spaces.factor
help.lint.spaces: new vocab
[factor.git] / basis / help / lint / spaces / spaces.factor
1 ! Copyright (C) 2017 Alexander Ilin.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays combinators.short-circuit formatting io
4 io.directories.search io.encodings.utf8 io.files io.pathnames
5 kernel math namespaces prettyprint sequences ui.gadgets.panes
6 vocabs.loader ;
7
8 IN: help.lint.spaces
9
10 : all-docs-files ( -- seq )
11     vocab-roots get [
12         recursive-directory-files [ "-docs.factor" tail? ] filter
13     ] map concat ;
14
15 : lint-spaces ( -- )
16     all-docs-files [
17         dup utf8 file-lines [ 1 + 2array ] map-index
18         [
19             first [
20                 { [ CHAR: space = ] [ CHAR: " = ] } 1||
21             ] trim-head
22             "  " swap subseq?
23         ] filter
24         [ drop ] [
25             swap <pathname> .
26             [ first2 swap "%d: %s\n" printf ] each
27         ] if-empty
28     ] each ;