diff --git a/basis/help/crossref/crossref.factor b/basis/help/crossref/crossref.factor index 5e4922c7ad..36d780c99b 100644 --- a/basis/help/crossref/crossref.factor +++ b/basis/help/crossref/crossref.factor @@ -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 ; diff --git a/basis/tools/crossref/crossref.factor b/basis/tools/crossref/crossref.factor index 134395f1a8..daa30100a4 100644 --- a/basis/tools/crossref/crossref.factor +++ b/basis/tools/crossref/crossref.factor @@ -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 ; +: defs-to-crossref ( -- seq ) + [ + all-words + all-articles [ >link ] map + source-files get keys [ ] map + ] append-outputs ; + : build-crossref ( -- crossref ) "Computing usage index... " write flush yield - H{ } clone crossref [ - all-words - source-files get keys [ ] map - [ [ crossref-def ] each ] bi@ - crossref get - ] with-variable + 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 -- ? )