ctags: cleanup docs and tests.
parent
0609f790c7
commit
b35f388de0
|
@ -1,102 +1,26 @@
|
||||||
USING: help.syntax help.markup kernel prettyprint sequences strings words math ;
|
USING: help.markup help.syntax vocabs ;
|
||||||
IN: ctags
|
IN: ctags
|
||||||
|
|
||||||
ARTICLE: "ctags" "Ctags file"
|
ARTICLE: "ctags" "Ctags file"
|
||||||
{ $emphasis "ctags" } " generates a index file of every factor word in ctags format as supported by vi and other editors. More information can be found at " { $url "http://en.wikipedia.org/wiki/Ctags" } "."
|
{ $emphasis "ctags" } " generates a index file of every factor word in ctags format as supported by vi and other editors. More information can be found at " { $url "http://en.wikipedia.org/wiki/Ctags" } "."
|
||||||
{ $subsections
|
{ $subsections
|
||||||
ctags
|
ctags
|
||||||
ctags-write
|
write-ctags
|
||||||
ctag-strings
|
|
||||||
ctag
|
|
||||||
ctag-word
|
|
||||||
ctag-path
|
|
||||||
ctag-lineno
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
HELP: ctags
|
HELP: write-ctags
|
||||||
{ $values { "path" "a pathname string" } }
|
{ $values { "path" "a pathname string" } }
|
||||||
{ $description "Generates a index file in ctags format and stores in " { $snippet "path" } "." }
|
{ $description "Generates a index file in ctags format and stores in " { $snippet "path" } "." }
|
||||||
{ $examples
|
{ $examples
|
||||||
{ $unchecked-example
|
{ $unchecked-example
|
||||||
"USING: ctags ;"
|
"USING: ctags ;"
|
||||||
"\"tags\" ctags"
|
"\"tags\" write-ctags"
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
HELP: ctags-write
|
HELP: ctags
|
||||||
{ $values { "seq" sequence }
|
{ $values { "alist" "ctags" } }
|
||||||
{ "path" "a pathname string" } }
|
{ $description "Make a sequence of ctags from " { $link all-words } ", sorted by word name." } ;
|
||||||
{ $description "Stores a " { $snippet "alist" } " in " { $snippet "path" } ". " { $snippet "alist" } " must be an association list with ctags format: key must be a valid word and value a sequence whose first element is a resource name and second element is a line number" }
|
|
||||||
{ $examples
|
|
||||||
{ $unchecked-example
|
|
||||||
"USING: kernel ctags ;"
|
|
||||||
"{ { if { \"resource:extra/unix/unix.factor\" 91 } } } \"tags\" ctags-write"
|
|
||||||
""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{ $notes
|
|
||||||
{ $snippet "tags" } " file will contain a single line: if\\t/path/to/factor/extra/unix/unix.factor\\t91" } ;
|
|
||||||
|
|
||||||
HELP: ctag-strings
|
|
||||||
{ $values { "alist" "an association list" }
|
|
||||||
{ "seq" sequence } }
|
|
||||||
{ $description "Converts an " { $snippet "alist" } " with ctag format (a word as key and a sequence whose first element is a resource name and a second element is a line number as value) in a " { $snippet "seq" } " of ctag strings." }
|
|
||||||
{ $examples
|
|
||||||
{ $unchecked-example
|
|
||||||
"USING: kernel ctags prettyprint ;"
|
|
||||||
"{ { if { \"resource:extra/unix/unix.factor\" 91 } } } ctag-strings ."
|
|
||||||
"{ \"if\\t/path/to/factor/extra/unix/unix.factor\\t91\" }"
|
|
||||||
}
|
|
||||||
} ;
|
|
||||||
|
|
||||||
HELP: ctag
|
|
||||||
{ $values { "seq" sequence }
|
|
||||||
{ "str" string } }
|
|
||||||
{ $description "Outputs a string " { $snippet "str" } " in ctag format for sequence with two elements, first one must be a valid word and second one a sequence whose first element is a resource name and second element is a line number" }
|
|
||||||
{ $examples
|
|
||||||
{ $unchecked-example
|
|
||||||
"USING: kernel ctags prettyprint ;"
|
|
||||||
"{ if { \"resource:extra/unix/unix.factor\" 91 } } ctag ."
|
|
||||||
"\"if\\t/path/to/factor/extra/unix/unix.factor\\t91\""
|
|
||||||
}
|
|
||||||
} ;
|
|
||||||
|
|
||||||
HELP: ctag-lineno
|
|
||||||
{ $values { "ctag" sequence }
|
|
||||||
{ "n" integer } }
|
|
||||||
{ $description "Provides de line number " { $snippet "n" } " from a sequence in ctag format " }
|
|
||||||
{ $examples
|
|
||||||
{ $example
|
|
||||||
"USING: kernel ctags prettyprint ;"
|
|
||||||
"{ if { \"resource:extra/unix/unix.factor\" 91 } } ctag-lineno ."
|
|
||||||
"91"
|
|
||||||
}
|
|
||||||
} ;
|
|
||||||
|
|
||||||
HELP: ctag-path
|
|
||||||
{ $values { "ctag" sequence }
|
|
||||||
{ "path" string } }
|
|
||||||
{ $description "Provides a path string " { $snippet "path" } " from a sequence in ctag format" }
|
|
||||||
{ $examples
|
|
||||||
{ $example
|
|
||||||
"USING: kernel ctags prettyprint ;"
|
|
||||||
"{ if { \"resource:extra/unix/unix.factor\" 91 } } ctag-path ."
|
|
||||||
"\"resource:extra/unix/unix.factor\""
|
|
||||||
}
|
|
||||||
} ;
|
|
||||||
|
|
||||||
HELP: ctag-word
|
|
||||||
{ $values { "ctag" sequence }
|
|
||||||
{ "word" word } }
|
|
||||||
{ $description "Provides the " { $snippet "word" } " from a sequence in ctag format " }
|
|
||||||
{ $examples
|
|
||||||
{ $example
|
|
||||||
"USING: kernel ctags prettyprint ;"
|
|
||||||
"{ if { \"resource:extra/unix/unix.factor\" 91 } } ctag-word ."
|
|
||||||
"if"
|
|
||||||
}
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
ABOUT: "ctags"
|
ABOUT: "ctags"
|
||||||
|
|
|
@ -1,27 +1,13 @@
|
||||||
USING: kernel ctags tools.test io.backend sequences arrays prettyprint ;
|
USING: arrays ctags.private io.backend kernel sequences
|
||||||
|
tools.test ;
|
||||||
IN: ctags.tests
|
IN: ctags.tests
|
||||||
|
|
||||||
{ t } [
|
|
||||||
91
|
|
||||||
{ if { "resource:extra/unix/unix.factor" 91 } } ctag-lineno =
|
|
||||||
] unit-test
|
|
||||||
|
|
||||||
{ t } [
|
|
||||||
"resource:extra/unix/unix.factor"
|
|
||||||
{ if { "resource:extra/unix/unix.factor" 91 } } ctag-path =
|
|
||||||
] unit-test
|
|
||||||
|
|
||||||
{ t } [
|
|
||||||
\ if
|
|
||||||
{ if { "resource:extra/unix/unix.factor" 91 } } ctag-word =
|
|
||||||
] unit-test
|
|
||||||
|
|
||||||
{ t } [
|
{ t } [
|
||||||
"if\t" "resource:extra/unix/unix.factor" normalize-path "\t91" 3append
|
"if\t" "resource:extra/unix/unix.factor" normalize-path "\t91" 3append
|
||||||
{ if { "resource:extra/unix/unix.factor" 91 } } ctag =
|
\ if "resource:extra/unix/unix.factor" 91 ctag =
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
{ t } [
|
{ t } [
|
||||||
"if\t" "resource:extra/unix/unix.factor" normalize-path "\t91" 3append 1array
|
"if\t" "resource:extra/unix/unix.factor" normalize-path "\t91" 3append 1array
|
||||||
{ { if { "resource:extra/unix/unix.factor" 91 } } } ctag-strings =
|
{ { if { "resource:extra/unix/unix.factor" 91 } } } ctags =
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
|
@ -20,13 +20,13 @@ IN: ctags
|
||||||
[ number>string % ] tri*
|
[ number>string % ] tri*
|
||||||
] "" make ;
|
] "" make ;
|
||||||
|
|
||||||
: ctags ( alist -- seq )
|
: make-ctags ( alist -- seq )
|
||||||
[ first2 ctag ] { } assoc>map ;
|
[ first2 ctag ] { } assoc>map ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: make-ctags ( -- ctags )
|
: ctags ( -- ctags )
|
||||||
all-words locations sort-keys ctags ;
|
all-words locations sort-keys make-ctags ;
|
||||||
|
|
||||||
: write-ctags ( path -- )
|
: write-ctags ( path -- )
|
||||||
[ make-ctags ] dip ascii set-file-lines ;
|
[ ctags ] dip ascii set-file-lines ;
|
||||||
|
|
Loading…
Reference in New Issue