]> gitweb.factorcode.org Git - factor.git/commitdiff
help.crossref, tools.crossref: improved help cross-referencing
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 25 Jan 2010 12:18:10 +0000 (01:18 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 25 Jan 2010 12:18:10 +0000 (01:18 +1300)
basis/help/crossref/crossref.factor
basis/tools/crossref/crossref.factor

index 5e4922c7ad75354a92cef89e115b5ca892be7084..36d780c99b71b2a4436c876b780a2c3345d40195 100644 (file)
@@ -7,10 +7,10 @@ IN: help.crossref
 
 : article-links ( topic elements -- seq )
     [ article-content ] dip
-    collect-elements [ >link ] map ;
+    collect-elements ;
 
 : article-children ( topic -- seq )
-    { $subsection $subsections } article-links ;
+    { $subsection $subsections } article-links [ >link ] map ;
 
 : help-path ( topic -- seq )
     [ article-parent ] follow rest ;
index 134395f1a85881e02a047c8f90f2fd3e8fa9659f..daa30100a46e30c64913534b462380403a026359 100644 (file)
@@ -1,9 +1,10 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: words assocs definitions io io.pathnames io.styles kernel
-prettyprint sorting see sets sequences arrays hashtables help.crossref
-help.topics help.markup quotations accessors source-files namespaces
-graphs vocabs generic generic.single threads compiler.units init ;
+prettyprint sorting see sets sequences arrays hashtables help
+help.crossref help.topics help.markup quotations accessors
+source-files namespaces graphs vocabs generic generic.single
+threads compiler.units init combinators.smart ;
 IN: tools.crossref
 
 SYMBOL: crossref
@@ -50,10 +51,16 @@ M: callable uses ( quot -- assoc )
 
 M: word uses def>> uses ;
 
-M: link uses { $subsection $subsections $link $see-also } article-links ;
+M: link uses
+    [ { $subsection $subsections $link $see-also } article-links [ >link ] map ]
+    [ { $vocab-link } article-links [ >vocab-link ] map ]
+    bi append ;
 
 M: pathname uses string>> source-file top-level-form>> [ uses ] [ { } ] if* ;
 
+! To make UI browser happy
+M: vocab uses drop f ;
+
 GENERIC: crossref-def ( defspec -- )
 
 M: object crossref-def
@@ -62,18 +69,23 @@ M: object crossref-def
 M: word crossref-def
     [ call-next-method ] [ subwords [ crossref-def ] each ] bi ;
 
-: build-crossref ( -- crossref )
-    "Computing usage index... " write flush yield
-    H{ } clone crossref [
+: defs-to-crossref ( -- seq )
+    [
         all-words
+        all-articles [ >link ] map
         source-files get keys [ <pathname> ] map
-        [ [ crossref-def ] each ] bi@
-        crossref get
-    ] with-variable
+    ] append-outputs ;
+
+: build-crossref ( -- crossref )
+    "Computing usage index... " write flush yield
+    H{ } clone [
+        crossref set-global
+        defs-to-crossref [ crossref-def ] each
+    ] keep
     "done" print flush ;
 
 : get-crossref ( -- crossref )
-    crossref global [ drop build-crossref ] cache ;
+    crossref get-global [ build-crossref ] unless* ;
 
 GENERIC: irrelevant? ( defspec -- ? )