@@ -8,7 +8,6 @@ import 'package:meta/meta.dart';
88// ignore: implementation_imports
99import 'package:pana/src/dartdoc/dartdoc_index.dart' ;
1010import 'package:path/path.dart' as p;
11- import 'package:pub_dev/search/dart_sdk_mem_index.dart' ;
1211import 'package:pub_dev/search/flutter_sdk_mem_index.dart' ;
1312
1413import '../shared/versions.dart' ;
@@ -17,6 +16,21 @@ import 'token_index.dart';
1716
1817export 'package:pana/src/dartdoc/dartdoc_index.dart' ;
1918
19+ /// Results from these libraries are ranked with lower score and
20+ /// will be displayed only if the query has the library name, or
21+ /// there are not other results that could match the query.
22+ const _libraryWeights = {
23+ 'dart:html' : 0.7 ,
24+ };
25+
26+ /// Results from these API pages are ranked with lower score and
27+ /// will be displayed only if the query has the library and the page
28+ /// name, or there are not other results that could match the query.
29+ const _defaultApiPageDirWeights = {
30+ 'cupertino/CupertinoIcons' : 0.25 ,
31+ 'material/Icons' : 0.25 ,
32+ };
33+
2034/// In-memory index for SDK library search queries.
2135class SdkMemIndex {
2236 final String _sdk;
@@ -25,7 +39,6 @@ class SdkMemIndex {
2539 final _tokensPerLibrary = < String , TokenIndex <String >> {};
2640 final _baseUriPerLibrary = < String , String > {};
2741 final _descriptionPerLibrary = < String , String > {};
28- final Map <String , double > _libraryWeights;
2942 final Map <String , double > _apiPageDirWeights;
3043
3144 SdkMemIndex ({
@@ -34,13 +47,11 @@ class SdkMemIndex {
3447 required Uri baseUri,
3548 required DartdocIndex index,
3649 Set <String >? allowedLibraries,
37- Map <String , double >? libraryWeights,
3850 Map <String , double >? apiPageDirWeights,
3951 }) : _sdk = sdk,
4052 _version = version,
4153 _baseUri = baseUri,
42- _libraryWeights = libraryWeights ?? const {},
43- _apiPageDirWeights = apiPageDirWeights ?? const {} {
54+ _apiPageDirWeights = apiPageDirWeights ?? _defaultApiPageDirWeights {
4455 _addDartdocIndex (index, allowedLibraries);
4556 }
4657
@@ -50,7 +61,6 @@ class SdkMemIndex {
5061 version: runtimeSdkVersion,
5162 baseUri: Uri .parse ('https://api.dart.dev/stable/latest/' ),
5263 index: index,
53- libraryWeights: dartSdkLibraryWeights,
5464 );
5565 }
5666
@@ -61,7 +71,6 @@ class SdkMemIndex {
6171 baseUri: Uri .parse ('https://api.flutter.dev/flutter/' ),
6272 index: index,
6373 allowedLibraries: flutterSdkAllowedLibraries,
64- apiPageDirWeights: flutterApiPageDirWeights,
6574 );
6675 }
6776
0 commit comments