diff --git a/racket/lib-classify.rkt b/racket/lib-pkg.rkt similarity index 92% rename from racket/lib-classify.rkt rename to racket/lib-pkg.rkt index 7928d10f..cb5af0f5 100644 --- a/racket/lib-classify.rkt +++ b/racket/lib-pkg.rkt @@ -16,7 +16,7 @@ [(get-base-documentation-packages) '("racket-doc")] [(get-distribution-documentation-packages) '("main-distribution") ]) -(provide classify-lib) +(provide lib-pkg) ;; This code for classifying packages as "base" or "main-dist" is ;; borrowed from racket-index/scribblings/main/private/pkg.rkt @@ -72,7 +72,9 @@ ;; doesn't make it into the xref index. ;; ;; So instead: When a doc index item has an "exported from lib", we -;; use resolve-module-path and path->pkg. +;; use resolve-module-path and path->pkg. However this is moderately +;; expensive, and should be done lazily (definitely not eagerly for +;; all 32K+ xref-index items) and cached. (define pkg-cache-for-path->pkg (make-hash)) (define (pkg-name mp) @@ -84,7 +86,7 @@ [_ #f])) (define cache (make-hash)) -(define (classify-lib maybe-mod-path) ;=> (list pkg-name, sort) +(define (lib-pkg maybe-mod-path) ;=> (list pkg-name, sort) (hash-ref! cache maybe-mod-path diff --git a/racket/scribble.rkt b/racket/scribble.rkt index b4ba2c3d..63e2fa90 100644 --- a/racket/scribble.rkt +++ b/racket/scribble.rkt @@ -20,7 +20,7 @@ setup/main-doc version/utils "define-fallbacks.rkt" - "lib-classify.rkt" + "lib-pkg.rkt" "util.rkt" "xref.rkt") @@ -115,12 +115,12 @@ (with-time/log "build-doc-search-trie" (build-doc-search-trie))))) -(define (doc-search prefix) +(define (doc-search prefix [limit 256]) (unless doc-index-trie-root (refresh-doc-index!)) - (trie-find doc-index-trie-root prefix)) + (trie-find doc-index-trie-root prefix limit)) -(define (trie-find root prefix [stop-after 256]) +(define (trie-find root prefix limit) (match (string->list prefix) [(list) null] @@ -135,7 +135,7 @@ (define (report! n) (for ([v (in-set (node-values n))]) (set-add! results (force v))) - (when (< (set-count results) stop-after) + (when (< (set-count results) limit) (for ([n (in-hash-values (node-kids n))]) (report! n)))) (report! sub)] @@ -217,7 +217,7 @@ (define fams (match (hash-ref ht 'language-family #f) [(? list? fams) (string-join (map ~a fams) ", ")] [#f "Racket"])) - (define pkg (classify-lib + (define pkg (lib-pkg (match (exported-index-desc-from-libs desc) [(cons lib _) lib] [_ #f]))) @@ -239,7 +239,7 @@ (define fams (match (hash-ref ht 'language-family #f) [(? list? fams) (string-join (map ~a fams) ", ")] [#f "Racket"])) - (define pkg (classify-lib + (define pkg (lib-pkg (match (hash-ref ht 'module-kind #f) ['lib (string->symbol term)] [_ #f]))) @@ -261,22 +261,22 @@ [(? method-index-desc?) (method-what)] [_ ""])) (define from (string-join (map ~s (exported-index-desc-from-libs desc)) ", ")) - (define pkg (classify-lib + (define pkg (lib-pkg (match (exported-index-desc-from-libs desc) [(cons lib _) lib] [_ #f]))) (values what from "" pkg 0)] [(module-path-index-desc? desc) - (define pkg (classify-lib (string->symbol term))) + (define pkg (lib-pkg (string->symbol term))) (values "module" "" "" pkg 0)] [else - (define pkg (classify-lib #f)) + (define pkg (lib-pkg #f)) (values "documentation" (doc-from) "" pkg 0)])) (list term sort-order what from fams pkg path anchor)) ;; This is for package-details (define (module-doc-path mod-path-str lang?) - (for/or ([v (in-list (doc-search mod-path-str))]) + (for/or ([v (in-list (doc-search mod-path-str 0))]) (match-define (list term _sort what _from _fams _pkg path anchor) v) (and (equal? term mod-path-str) (equal? what (if lang? "language" "module"))