]> gitweb.factorcode.org Git - factor.git/commitdiff
ctags: cleanup docs and tests.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 19 Apr 2016 03:24:42 +0000 (20:24 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 19 Apr 2016 03:24:42 +0000 (20:24 -0700)
extra/ctags/ctags-docs.factor
extra/ctags/ctags-tests.factor
extra/ctags/ctags.factor

index 5edaf237e8b5e33ecdfe8454033f2e538428d7eb..64a645df6469adb03f9f51cc0257ab9ad0774e36 100644 (file)
-USING: help.syntax help.markup kernel prettyprint sequences strings words math ;
+USING: help.markup help.syntax vocabs ;
 IN: ctags
 
 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" } "."
 { $subsections
     ctags
-    ctags-write
-    ctag-strings
-    ctag
-    ctag-word
-    ctag-path
-    ctag-lineno
+    write-ctags
 } ;
 
-HELP: ctags
+HELP: write-ctags
 { $values { "path" "a pathname string" } }
 { $description "Generates a index file in ctags format and stores in " { $snippet "path" } "." }
 { $examples
   { $unchecked-example
     "USING: ctags ;"
-    "\"tags\" ctags"
+    "\"tags\" write-ctags"
     ""
   }
 } ;
 
-HELP: ctags-write
-{ $values { "seq" sequence }
-          { "path" "a pathname string" } }
-{ $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"
-  }
-} ;
-
+HELP: ctags
+{ $values { "alist" "ctags" } }
+{ $description "Make a sequence of ctags from " { $link all-words } ", sorted by word name." } ;
 
 ABOUT: "ctags"
index a5738dca6bac013090c7ff494ceaab7cd876daa2..a7d9840f1351fe47a84b18ddb737844ae4ad6712 100644 (file)
@@ -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
 
-{ 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 } [
   "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
 
 { t } [
   "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
index 4e5beabe443c454a9a455e0692060eeab835fe33..cc83aa13d81ef169b9087745dcdd80d2f157e5d3 100644 (file)
@@ -20,13 +20,13 @@ IN: ctags
         [ number>string % ] tri*
     ] "" make ;
 
-: ctags ( alist -- seq )
+: make-ctags ( alist -- seq )
     [ first2 ctag ] { } assoc>map ;
 
 PRIVATE>
 
-: make-ctags ( -- ctags )
-    all-words locations sort-keys ctags ;
+: ctags ( -- ctags )
+    all-words locations sort-keys make-ctags ;
 
 : write-ctags ( path -- )
-    [ make-ctags ] dip ascii set-file-lines ;
+    [ ctags ] dip ascii set-file-lines ;