Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions app/lib/search/dart_sdk_mem_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ import 'sdk_mem_index.dart';

final _logger = Logger('search.dart_sdk_mem_index');

/// Results from these libraries are ranked with lower score and
/// will be displayed only if the query has the library name, or
/// there are not other results that could match the query.
const dartSdkLibraryWeights = <String, double>{
'dart:html': 0.7,
};

/// Sets the Dart SDK in-memory index.
void registerDartSdkMemIndex(SdkMemIndex? index) {
if (index != null) {
Expand Down
5 changes: 0 additions & 5 deletions app/lib/search/flutter_sdk_mem_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ const flutterSdkAllowedLibraries = <String>{
'flutter_web_plugins',
};

const flutterApiPageDirWeights = <String, double>{
'cupertino/CupertinoIcons': 0.25,
'material/Icons': 0.25,
};

final _logger = Logger('search.flutter_sdk_mem_index');

/// Sets the Flutter SDK in-memory index.
Expand Down
23 changes: 16 additions & 7 deletions app/lib/search/sdk_mem_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:meta/meta.dart';
// ignore: implementation_imports
import 'package:pana/src/dartdoc/dartdoc_index.dart';
import 'package:path/path.dart' as p;
import 'package:pub_dev/search/dart_sdk_mem_index.dart';
import 'package:pub_dev/search/flutter_sdk_mem_index.dart';

import '../shared/versions.dart';
Expand All @@ -17,6 +16,21 @@ import 'token_index.dart';

export 'package:pana/src/dartdoc/dartdoc_index.dart';

/// Results from these libraries are ranked with lower score and
/// will be displayed only if the query has the library name, or
/// there are not other results that could match the query.
const _libraryWeights = {
'dart:html': 0.7,
};

/// Results from these API pages are ranked with lower score and
/// will be displayed only if the query has the library and the page
/// name, or there are not other results that could match the query.
const _defaultApiPageDirWeights = {
'cupertino/CupertinoIcons': 0.25,
'material/Icons': 0.25,
};

/// In-memory index for SDK library search queries.
class SdkMemIndex {
final String _sdk;
Expand All @@ -25,7 +39,6 @@ class SdkMemIndex {
final _tokensPerLibrary = <String, TokenIndex<String>>{};
final _baseUriPerLibrary = <String, String>{};
final _descriptionPerLibrary = <String, String>{};
final Map<String, double> _libraryWeights;
final Map<String, double> _apiPageDirWeights;

SdkMemIndex({
Expand All @@ -34,13 +47,11 @@ class SdkMemIndex {
required Uri baseUri,
required DartdocIndex index,
Set<String>? allowedLibraries,
Map<String, double>? libraryWeights,
Map<String, double>? apiPageDirWeights,
}) : _sdk = sdk,
_version = version,
_baseUri = baseUri,
_libraryWeights = libraryWeights ?? const {},
_apiPageDirWeights = apiPageDirWeights ?? const {} {
_apiPageDirWeights = apiPageDirWeights ?? _defaultApiPageDirWeights {
_addDartdocIndex(index, allowedLibraries);
}

Expand All @@ -50,7 +61,6 @@ class SdkMemIndex {
version: runtimeSdkVersion,
baseUri: Uri.parse('https://api.dart.dev/stable/latest/'),
index: index,
libraryWeights: dartSdkLibraryWeights,
);
}

Expand All @@ -61,7 +71,6 @@ class SdkMemIndex {
baseUri: Uri.parse('https://api.flutter.dev/flutter/'),
index: index,
allowedLibraries: flutterSdkAllowedLibraries,
apiPageDirWeights: flutterApiPageDirWeights,
);
}

Expand Down
5 changes: 0 additions & 5 deletions app/test/search/sdk_mem_index_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'dart:convert';

import 'package:pub_dev/search/dart_sdk_mem_index.dart';
import 'package:pub_dev/search/sdk_mem_index.dart';
import 'package:test/test.dart';

Expand All @@ -17,10 +16,6 @@ void main() {
sdk: 'dart',
version: '',
baseUri: Uri.parse('https://api.dart.dev/x/'),
libraryWeights: dartSdkLibraryWeights,
apiPageDirWeights: {
'dart:html/FakeIcons': 0.7,
},
index: DartdocIndex.fromJsonList([
{
'name': 'dart:async',
Expand Down