]> gitweb.factorcode.org Git - factor.git/blob - basis/help/lint/spaces/spaces.factor
3411fb7ec09d867dcc585bd8527823e4d7da3fad
[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
4 io.directories io.encodings.utf8 io.files io.pathnames kernel
5 math namespaces prettyprint sequences vocabs.loader ;
6
7 IN: help.lint.spaces
8
9 : all-docs-files ( -- seq )
10     vocab-roots get [
11         recursive-directory-files [ "-docs.factor" tail? ] filter
12     ] map concat ;
13
14 : lint-spaces ( -- )
15     all-docs-files [
16         dup utf8 file-lines [ 1 + 2array ] map-index
17         [
18             first [
19                 { [ CHAR: space = ] [ CHAR: " = ] } 1||
20             ] trim-head
21             "  " subseq-index?
22         ] filter
23         [ drop ] [
24             swap <pathname> .
25             [ first2 swap "%d: %s\n" printf ] each
26         ] if-empty
27     ] each ;