help.lint.spaces: new vocab

modern-harvey2
Alexander Iljin 2017-06-05 20:17:57 +03:00 committed by John Benediktsson
parent 2ffa446f5b
commit 6d355c998b
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1 @@
Alexander Ilin

View File

@ -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 ;