Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit e88260e

Browse files
committed
Add compile step that bundles and compresses JS files
Also, manage dependencies on third-party JS libraries using NPM.
1 parent fe4c6c7 commit e88260e

File tree

106 files changed

+3297
-1997
lines changed

Some content is hidden

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

106 files changed

+3297
-1997
lines changed

.ghc.environment.x86_64-darwin-8.2.1

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
-- This is a GHC environment file written by cabal. This means you can
2+
-- run ghc or ghci and get the environment of the project as a whole.
3+
-- But you still need to use cabal repl $target to get the environment
4+
-- of specific components (libs, exes, tests etc) because each one can
5+
-- have its own source dirs, cpp flags etc.
6+
--
7+
clear-package-db
8+
global-package-db
9+
package-db /Users/tim/.cabal/store/ghc-8.2.1/package.db
10+
package-db dist-newstyle/packagedb/ghc-8.2.1
11+
package-id base-4.10.0.0
12+
package-id rts
13+
package-id ghc-prim-0.5.1.0
14+
package-id integer-gmp-1.0.1.0
15+
package-id hspec-2.4.4-1c0b7d85ed834bde9b4fc0b67ffdca678fb05d0af151729fbb5937f90ecdebc4
16+
package-id hspec-core-2.4.4-807f12cd77dd6a3dc843790305e601dab88a824d262b2c9e4c52d31bdd7b4fe1
17+
package-id random-1.1-b5eae019205c436b65168623eadccb282a3368907e99b2197b8bf5ebbec87f10
18+
package-id time-1.8.0.2
19+
package-id deepseq-1.4.3.0
20+
package-id array-0.5.2.0
21+
package-id tf-random-0.5-9bcd920a3a53dfcdddf523c638d6ca0c5f5c8671008ea5e6e5966877654bf079
22+
package-id primitive-0.6.2.0-591913180aa7f665eb70f8649d947be41cc43927c33726da89f290095fa8dcf9
23+
package-id transformers-0.5.2.0
24+
package-id setenv-0.1.1.3-ac84fe3b56537f48ca8e0c15ab0cdb316e931e007a5785006135f58fe4313487
25+
package-id unix-2.7.2.2
26+
package-id bytestring-0.10.8.2
27+
package-id ansi-terminal-0.7.1.1-68169ce6c2f32f3c680ddaed58b58b2432bb4633791f154517abcc5ec1dc2abc
28+
package-id colour-2.3.3-777ceaf5f7b3188ef40ce15f303fcfcc6af0e44dd851955504a6bed0f8cb0f89
29+
package-id HUnit-1.6.0.0-9d0216c0eeea94fdc2364f3daab9b84f498800caebb2378a6b5b312fb8ab2ad0
30+
package-id call-stack-0.1.0-91535ce8ed4646395bd69e2e573fd77bbd01ffa7fa07519e2aa1790ce3d68fd9
31+
package-id QuickCheck-2.10.0.1-14eb05fbce793c97a6246c29bb7eafdea93c9e191233397d253a0cb33298aba6
32+
package-id containers-0.5.10.2
33+
package-id template-haskell-2.12.0.0
34+
package-id ghc-boot-th-8.2.1
35+
package-id pretty-1.1.3.3
36+
package-id quickcheck-io-0.2.0-25165274c80769eeb2ddb4eda44ea8f611449ead2858e2e61e8faf5ca0f61874
37+
package-id hspec-expectations-0.8.2-52a51410f728d3bc36fff2a4f669f158292d5541a1e00bbf6e17357c8e76ade8
38+
package-id async-2.1.1.1-a942400ba4fb0746be04a00b270f56696159d0e9149449689d86630a183715c9
39+
package-id stm-2.4.4.1-b93cc6a1c82b736dcfa75ec5908a8462866a07e9ecbfb5920c82efe10a147d6e
40+
package-id directory-1.3.0.2
41+
package-id filepath-1.4.1.2
42+
package-id hspec-discover-2.4.4-c0abb7aa79913de4aae506b6a6b18b2233bb2f1e4659ada9231344caca718079
43+
package-id haddock-api-2.18.2-inplace
44+
package-id Cabal-2.0.0.2
45+
package-id process-1.6.1.0
46+
package-id binary-0.8.5.1
47+
package-id ghc-8.2.1
48+
package-id hpc-0.6.0.3
49+
package-id ghc-boot-8.2.1
50+
package-id ghci-8.2.1
51+
package-id hoopl-3.10.2.2
52+
package-id terminfo-0.4.1.0
53+
package-id ghc-paths-0.1.0.9-013a97aeac002a1773522f13287773439d3c51c3200fb2bdf7f3c1de6f4e279b
54+
package-id haddock-library-1.4.6-inplace
55+
package-id haddock-library-1.4.6-inplace-attoparsec
56+
package-id xhtml-3000.2.2
57+
package-id haddock-test-0.0.1-inplace
58+
package-id xml-1.3.14-def5148bc6a54ed5ad89b9a71f36a9790f07dd65f92400fb8b2061cf6efb977f
59+
package-id text-1.2.2.2-52fc6c4fafb6b898175bc0eadd29d6b55afd242510914ad1ce3e65ab2ddf155d
60+
package-id syb-0.7-b0a8286f677ef2728b0c581fd92d9ed16d8ec958d4417c04fd24494069b0c8d1

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
tags
2020
TAGS
2121

22+
/haddock-api/resources/html/node_modules
23+
2224
.cabal-sandbox
2325
cabal.sandbox.config
2426

haddock-api/haddock-api.cabal

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ extra-source-files:
2020
data-dir:
2121
resources
2222
data-files:
23-
html/index.js
24-
html/fuse.js
25-
html/preact.js
23+
html/quick-jump.min.js
24+
html/haddock-bundle.min.js
2625
html/solarized.css
27-
html/haddock-util.js
2826
html/highlight.js
2927
html/Classic.theme/haskell_icon.gif
3028
html/Classic.theme/minus.gif

haddock-api/resources/html/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Compiling
2+
3+
* Install [node](https://nodejs.org/) and [npm](https://www.npmjs.com)
4+
* Run `npm install` and `npm install gulp-cli -g` in this directory.
5+
* Run `gulp` in this directory. This rebuilds the minified JS files.
6+
7+
# Manual Testing
8+
9+
Generate haddock docs for some Haskell project and replace the generated JS files:
10+
11+
```
12+
gulp && cp *.min.js path-to/generated-haddock-docs
13+
```

haddock-api/resources/html/fuse.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const gulp = require('gulp');
2+
const uglify = require('gulp-uglify');
3+
const browserify = require('browserify');
4+
const source = require('vinyl-source-stream');
5+
const buffer = require('vinyl-buffer');
6+
7+
function buildJS(targetFileName, files) {
8+
var b = browserify({ entries: files });
9+
return b
10+
.bundle()
11+
.pipe(source(targetFileName))
12+
.pipe(buffer())
13+
.pipe(uglify().on('error', function(e) { console.log(e); }))
14+
.pipe(gulp.dest('.'));
15+
}
16+
17+
gulp.task('build-js', function() {
18+
buildJS('quick-jump.min.js', ['./js-src/quick-jump.js']);
19+
buildJS('haddock-bundle.min.js', ['./js-src/init.js']);
20+
});
21+
22+
gulp.task('default', ['build-js']);

haddock-api/resources/html/haddock-bundle.min.js

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

haddock-api/resources/html/haddock-util.js renamed to haddock-api/resources/html/js-src/haddock-util.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ function toggleSection(id)
5656
return b;
5757
}
5858

59+
// TODO: get rid of global variables
60+
if (typeof window !== 'undefined') { window.toggleSection = toggleSection; }
61+
5962
var collapsed = {};
6063
function rememberCollapsed(id)
6164
{
@@ -88,6 +91,8 @@ function restoreCollapsed()
8891
}
8992
}
9093

94+
exports.restoreCollapsed = restoreCollapsed;
95+
9196
function setCookie(name, value) {
9297
document.cookie = name + "=" + escape(value) + ";path=/;";
9398
}
@@ -145,6 +150,8 @@ function addStyleMenu() {
145150
}
146151
}
147152

153+
exports.addStyleMenu = addStyleMenu;
154+
148155
function setActiveStyleSheet(title) {
149156
var as = styles();
150157
var i, a, found;
@@ -171,16 +178,9 @@ function resetStyle() {
171178
if (s) setActiveStyleSheet(s);
172179
}
173180

181+
exports.resetStyle = resetStyle;
174182

175183
function styleMenu(show) {
176184
var m = document.getElementById('style-menu');
177185
if (m) toggleShow(m, show);
178-
}
179-
180-
181-
function pageLoad() {
182-
addStyleMenu();
183-
resetStyle();
184-
restoreCollapsed();
185-
}
186-
186+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var util = require('./haddock-util');
2+
var quickJump = require('./quick-jump');
3+
4+
function onDomReady(callback) {
5+
if (document.readyState === 'interactive') {
6+
callback();
7+
} else {
8+
document.addEventListener('readystatechange', function () {
9+
if (document.readyState === 'interactive') {
10+
callback();
11+
}
12+
});
13+
}
14+
}
15+
16+
onDomReady(function() {
17+
util.addStyleMenu();
18+
util.resetStyle();
19+
util.restoreCollapsed();
20+
quickJump.init();
21+
});

haddock-api/resources/html/index.js renamed to haddock-api/resources/html/js-src/quick-jump.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
var Fuse = require('fuse.js');
2+
var preact = require('preact');
3+
14
quickNav = (function() {
25

36
var baseUrl;
@@ -230,7 +233,7 @@ var App = createClass({
230233
onFocus: this.show.bind(this),
231234
onClick: this.show.bind(this),
232235
onInput: this.updateResults.bind(this)
233-
}),
236+
})
234237
),
235238
h('div', {
236239
id: 'search-results',
@@ -276,8 +279,8 @@ var App = createClass({
276279
: h('li', { class: 'more-results' },
277280
this.actionLink(expand, {}, "show " + (items.length - visibleItems.length) + " more results from this module")
278281
)
279-
),
280-
)
282+
)
283+
);
281284
},
282285

283286
navigationLink: function(href, attrs) {
@@ -355,13 +358,13 @@ var KeyboardShortcuts = function() {
355358
h('tr', null,
356359
h('td', null, h('span', { class: 'key' }, "↵")),
357360
h('td', null, "Go to active search result")
358-
),
361+
)
359362
);
360363
};
361364

362365
var IntroMsg = function() {
363366
return h('p', null,
364-
"You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name.",
367+
"You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name."
365368
);
366369
};
367370

@@ -374,10 +377,10 @@ var NoResultsMsg = function(props) {
374377
),
375378
h('p', null,
376379
h('code', null, 'Nothing'),
377-
" matches your query for '" + props.searchString + "'.",
380+
" matches your query for '" + props.searchString + "'."
378381
),
379382
h('p', null,
380-
h('code', null, 'Left "no matches for \'' + props.searchString + '\'" :: Either String (NonEmpty SearchResult)'),
383+
h('code', null, 'Left "no matches for \'' + props.searchString + '\'" :: Either String (NonEmpty SearchResult)')
381384
)
382385
];
383386

@@ -392,3 +395,5 @@ return {
392395
}
393396
}
394397
})();
398+
399+
if (typeof exports === 'object') { exports.init = quickNav.init; }

0 commit comments

Comments
 (0)