@@ -8,7 +8,6 @@ import 'package:meta/meta.dart';
8
8
// ignore: implementation_imports
9
9
import 'package:pana/src/dartdoc/dartdoc_index.dart' ;
10
10
import 'package:path/path.dart' as p;
11
- import 'package:pub_dev/search/dart_sdk_mem_index.dart' ;
12
11
import 'package:pub_dev/search/flutter_sdk_mem_index.dart' ;
13
12
14
13
import '../shared/versions.dart' ;
@@ -17,6 +16,21 @@ import 'token_index.dart';
17
16
18
17
export 'package:pana/src/dartdoc/dartdoc_index.dart' ;
19
18
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
+
20
34
/// In-memory index for SDK library search queries.
21
35
class SdkMemIndex {
22
36
final String _sdk;
@@ -25,7 +39,6 @@ class SdkMemIndex {
25
39
final _tokensPerLibrary = < String , TokenIndex <String >> {};
26
40
final _baseUriPerLibrary = < String , String > {};
27
41
final _descriptionPerLibrary = < String , String > {};
28
- final Map <String , double > _libraryWeights;
29
42
final Map <String , double > _apiPageDirWeights;
30
43
31
44
SdkMemIndex ({
@@ -34,13 +47,11 @@ class SdkMemIndex {
34
47
required Uri baseUri,
35
48
required DartdocIndex index,
36
49
Set <String >? allowedLibraries,
37
- Map <String , double >? libraryWeights,
38
50
Map <String , double >? apiPageDirWeights,
39
51
}) : _sdk = sdk,
40
52
_version = version,
41
53
_baseUri = baseUri,
42
- _libraryWeights = libraryWeights ?? const {},
43
- _apiPageDirWeights = apiPageDirWeights ?? const {} {
54
+ _apiPageDirWeights = apiPageDirWeights ?? _defaultApiPageDirWeights {
44
55
_addDartdocIndex (index, allowedLibraries);
45
56
}
46
57
@@ -50,7 +61,6 @@ class SdkMemIndex {
50
61
version: runtimeSdkVersion,
51
62
baseUri: Uri .parse ('https://api.dart.dev/stable/latest/' ),
52
63
index: index,
53
- libraryWeights: dartSdkLibraryWeights,
54
64
);
55
65
}
56
66
@@ -61,7 +71,6 @@ class SdkMemIndex {
61
71
baseUri: Uri .parse ('https://api.flutter.dev/flutter/' ),
62
72
index: index,
63
73
allowedLibraries: flutterSdkAllowedLibraries,
64
- apiPageDirWeights: flutterApiPageDirWeights,
65
74
);
66
75
}
67
76
0 commit comments