Add authors and summary and documentation files and polish testsuite
parent
a10fc1e00e
commit
222aa829bc
|
@ -0,0 +1 @@
|
|||
Alfredo Beaumont
|
|
@ -0,0 +1,39 @@
|
|||
USING: help.syntax help.markup kernel prettyprint sequences strings words math ;
|
||||
IN: ctags.etags
|
||||
|
||||
ARTICLE: "etags" "Etags file"
|
||||
{ $emphasis "Etags" } " generates a index file of every factor word in etags format as supported by emacs and other editors. More information can be found at " { $url "http://en.wikipedia.org/wiki/Ctags#Etags_2" } "."
|
||||
{ $subsection etags }
|
||||
{ $subsection etags-write }
|
||||
{ $subsection etag-strings }
|
||||
{ $subsection etag-header }
|
||||
|
||||
HELP: etags ( path -- )
|
||||
{ $values { "path" string } }
|
||||
{ $description "Generates a index file in etags format and stores in " { $snippet "path" } "." }
|
||||
{ $examples
|
||||
{ $unchecked-example
|
||||
"USING: ctags.etags ;"
|
||||
"\"ETAGS\" etags"
|
||||
""
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: etags-write ( alist path -- )
|
||||
{ $values { "alist" sequence }
|
||||
{ "path" string } }
|
||||
{ $description "Stores a " { $snippet "alist" } " in " { $snippet "path" } ". " { $snippet "alist" } " must be an association list with etags format: its key must be a resource path and its value a vector, containing pairs of words and lines" }
|
||||
{ $examples
|
||||
{ $unchecked-example
|
||||
"USING: kernel etags.ctags ;"
|
||||
"{ { \"resource:extra/unix/unix.factor\" V{ { dup2 91 } } } } \"ETAGS\" etags-write"
|
||||
""
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: etag-strings ( alist -- seq )
|
||||
{ $values { "alist" sequence }
|
||||
{ "seq" sequence } }
|
||||
{ $description "Converts an " { $snippet "alist" } " with etag format (a path as key and a vector containing word/line pairs) in a " { $snippet "seq" } " of strings." }
|
||||
|
||||
ABOUT: "etags"
|
|
@ -1,47 +1,72 @@
|
|||
USING: kernel ctags ctags.etags tools.test io.backend sequences arrays prettyprint hashtables assocs ;
|
||||
IN: ctags.etags.tests
|
||||
|
||||
|
||||
[ H{ { "path" V{ if { "path" 1 } } } } ]
|
||||
[ H{ } clone dup V{ if { "path" 1 } } "path" rot set-at ] unit-test
|
||||
|
||||
[ { "path" V{ if { "path" 1 } } } ]
|
||||
[ H{ } clone dup { "path" V{ if { "path" 1 } } } "path" rot set-at "path" swap at ] unit-test
|
||||
|
||||
|
||||
[ V{ if { "path" 1 } } ]
|
||||
[ "path" H{ { "path" V{ if { "path" 1 } } } } at ] unit-test
|
||||
|
||||
[ "path" ] [ { if { "path" 1 } } ctag-path ] unit-test
|
||||
|
||||
[ V{ } ]
|
||||
[ "path" H{ } clone etag-at ] unit-test
|
||||
|
||||
[ V{ if { "path" 1 } } ]
|
||||
[ "path" H{ { "path" V{ if { "path" 1 } } } } etag-at ] unit-test
|
||||
|
||||
[ { if 28 } ]
|
||||
[ { if { "resource:core/kernel/kernel.factor" 28 } } etag-pair ] unit-test
|
||||
|
||||
[ V{ } ] [ { if { "path" 1 } } H{ } clone etag-vector ] unit-test
|
||||
|
||||
[ V{ if { "path" 1 } } ]
|
||||
[ { if { "path" 1 } }
|
||||
{ { "path" V{ if { "path" 1 } } } } >hashtable
|
||||
etag-vector
|
||||
! etag-at
|
||||
[ t ]
|
||||
[
|
||||
V{ }
|
||||
"path" H{ } clone etag-at =
|
||||
] unit-test
|
||||
|
||||
[ H{ { "path" V{ { if 1 } } } } ]
|
||||
[ { if { "path" 1 } } H{ } clone [ etag-add ] keep ] unit-test
|
||||
[ t ]
|
||||
[
|
||||
V{ if { "path" 1 } }
|
||||
"path" H{ { "path" V{ if { "path" 1 } } } } etag-at =
|
||||
] unit-test
|
||||
|
||||
[ H{ { "path" V{ { if 1 } } } } ]
|
||||
[ { { if { "path" 1 } } } etag-hash ] unit-test
|
||||
! etag-vector
|
||||
[ t ]
|
||||
[
|
||||
V{ }
|
||||
{ if { "path" 1 } } H{ } clone etag-vector =
|
||||
] unit-test
|
||||
|
||||
[ "if28,704" ]
|
||||
[ "resource:core/kernel/kernel.factor" file>lines { if 28 } etag ] unit-test
|
||||
[ t ]
|
||||
[
|
||||
V{ if { "path" 1 } }
|
||||
{ if { "path" 1 } }
|
||||
{ { "path" V{ if { "path" 1 } } } } >hashtable
|
||||
etag-vector =
|
||||
] unit-test
|
||||
|
||||
! [ V{ "" "resource:core/kernel/kernel.factor,22" "if28,704" "unless31,755" } ]
|
||||
! [ { { "resource:core/kernel/kernel.factor"
|
||||
! V{ { if 28 }
|
||||
! { unless 31 } } } } etag-strings ] unit-test
|
||||
! etag-pair
|
||||
[ t ]
|
||||
[
|
||||
{ if 28 }
|
||||
{ if { "resource:core/kernel/kernel.factor" 28 } } etag-pair =
|
||||
] unit-test
|
||||
|
||||
! etag-add
|
||||
[ t ]
|
||||
[
|
||||
H{ { "path" V{ { if 1 } } } }
|
||||
{ if { "path" 1 } } H{ } clone [ etag-add ] keep =
|
||||
] unit-test
|
||||
|
||||
! etag-hash
|
||||
[ t ]
|
||||
[
|
||||
H{ { "path" V{ { if 1 } } } }
|
||||
{ { if { "path" 1 } } } etag-hash =
|
||||
] unit-test
|
||||
|
||||
! line-bytes (note that for each line implicit \n is counted)
|
||||
[ t ]
|
||||
[
|
||||
17
|
||||
{ "1234567890" "12345" } 2 lines>bytes =
|
||||
] unit-test
|
||||
|
||||
! etag
|
||||
[ t ]
|
||||
[
|
||||
"if2,11"
|
||||
{ "1234567890" "12345" } { if 2 } etag =
|
||||
] unit-test
|
||||
|
||||
! etag-length
|
||||
[ t ]
|
||||
[
|
||||
14
|
||||
V{ "if2,11" "if2,11" } etag-length =
|
||||
] unit-test
|
||||
|
|
|
@ -31,7 +31,7 @@ IN: ctags.etags
|
|||
: lines>bytes ( seq n -- bytes )
|
||||
head 0 [ length 1+ + ] reduce ;
|
||||
|
||||
: file>lines ( resource -- lines )
|
||||
: file>lines ( path -- lines )
|
||||
ascii file-lines ;
|
||||
|
||||
: etag ( lines seq -- str )
|
||||
|
@ -46,7 +46,7 @@ IN: ctags.etags
|
|||
: etag-length ( vector -- n )
|
||||
0 [ length + ] reduce ;
|
||||
|
||||
: <header> ( n path -- str )
|
||||
: (etag-header) ( n path -- str )
|
||||
[
|
||||
%
|
||||
1 CHAR: , <string> %
|
||||
|
@ -54,7 +54,7 @@ IN: ctags.etags
|
|||
] "" make ;
|
||||
|
||||
: etag-header ( vec1 n resource -- vec2 )
|
||||
normalize-path <header> prefix
|
||||
normalize-path (etag-header) prefix
|
||||
1 HEX: 0c <string> prefix ;
|
||||
|
||||
: etag-strings ( alist -- seq )
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Etags generator
|
Loading…
Reference in New Issue