Skip to content

Commit ce296b7

Browse files
committed
Merge pull request #1127 from dart-lang/url-search
Add support for URL-based searches.
2 parents 320e5a4 + 4da8b15 commit ce296b7

File tree

579 files changed

+715
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

579 files changed

+715
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions

lib/resources/URI.js

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/resources/script.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function initSearch() {
7272
'constructor' : 4
7373
};
7474

75-
function findMatches(q, cb) {
75+
function findMatches(q) {
7676
var allMatches = []; // list of matches
7777

7878
function score(element, num) {
@@ -137,10 +137,19 @@ function initSearch() {
137137
sortedMatches.push(allMatches[i].e);
138138
}
139139

140-
cb(sortedMatches);
140+
return sortedMatches;
141141
};
142142

143143
function initTypeahead() {
144+
var search = new URI().query(true)["search"];
145+
if (search) {
146+
var matches = findMatches(search);
147+
if (matches.length != 0) {
148+
window.location = matches[0].href;
149+
return;
150+
}
151+
}
152+
144153
$('#search-box').prop('disabled', false);
145154
$('#search-box').prop('placeholder', 'Search');
146155
$(document).keypress(function(event) {
@@ -158,7 +167,7 @@ function initSearch() {
158167
{
159168
name: 'elements',
160169
limit: 10,
161-
source: findMatches,
170+
source: function(q, cb) { cb(findMatches(q)); },
162171
display: function(element) { return element.name; },
163172
templates: {
164173
suggestion: function(match) {

lib/src/html/resources.g.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
library dartdoc.html.resources;
44

55
const List<String> resource_names = const [
6+
'package:dartdoc/resources/URI.js',
67
'package:dartdoc/resources/css/bootstrap.css',
78
'package:dartdoc/resources/css/bootstrap.css.map',
89
'package:dartdoc/resources/css/bootstrap.min.css',

lib/templates/_footer.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
2727
<script src="static-assets/typeahead.bundle.min.js"></script>
2828
<script src="static-assets/prettify.js"></script>
29+
<script src="static-assets/URI.js"></script>
2930
<script src="static-assets/script.js"></script>
3031
<!-- Do not remove placeholder -->
3132
<!-- Footer Placeholder -->

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dartdoc
22
# Also update the `version` field in lib/dartdoc.dart.
3-
version: 0.9.2
3+
version: 0.9.3-dev
44
author: Dart Team <[email protected]>
55
description: A documentation generator for Dart.
66
homepage: https://github.com/dart-lang/dartdoc

test_package_docs/anonymous_library/anonymous_library-library.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ <h5>anonymous_library</h5>
150150
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
151151
<script src="static-assets/typeahead.bundle.min.js"></script>
152152
<script src="static-assets/prettify.js"></script>
153+
<script src="static-assets/URI.js"></script>
153154
<script src="static-assets/script.js"></script>
154155
<!-- Do not remove placeholder -->
155156
<!-- Footer Placeholder -->

test_package_docs/anonymous_library/doesStuff.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ <h5><a href="anonymous_library/anonymous_library-library.html">anonymous_library
119119
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
120120
<script src="static-assets/typeahead.bundle.min.js"></script>
121121
<script src="static-assets/prettify.js"></script>
122+
<script src="static-assets/URI.js"></script>
122123
<script src="static-assets/script.js"></script>
123124
<!-- Do not remove placeholder -->
124125
<!-- Footer Placeholder -->

test_package_docs/another_anonymous_lib/another_anonymous_lib-library.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ <h5>another_anonymous_lib</h5>
150150
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
151151
<script src="static-assets/typeahead.bundle.min.js"></script>
152152
<script src="static-assets/prettify.js"></script>
153+
<script src="static-assets/URI.js"></script>
153154
<script src="static-assets/script.js"></script>
154155
<!-- Do not remove placeholder -->
155156
<!-- Footer Placeholder -->

test_package_docs/another_anonymous_lib/greeting.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ <h5><a href="another_anonymous_lib/another_anonymous_lib-library.html">another_a
119119
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
120120
<script src="static-assets/typeahead.bundle.min.js"></script>
121121
<script src="static-assets/prettify.js"></script>
122+
<script src="static-assets/URI.js"></script>
122123
<script src="static-assets/script.js"></script>
123124
<!-- Do not remove placeholder -->
124125
<!-- Footer Placeholder -->

0 commit comments

Comments
 (0)