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

Commit e99aefb

Browse files
timjbalexbiehl
authored andcommitted
Add compile step that bundles and compresses JS files (#684)
* Add compile step that bundles and compresses JS files Also, manage dependencies on third-party JS libraries using NPM. * Compile JS from TypeScript * Enable 'noImplicitAny' in TypeScript * QuickJump: use JSX syntax * Generate source maps from TypeScript for easier debugging * TypeScript: more accurate type * Separate quick jump css file from ocean theme
1 parent fe4c6c7 commit e99aefb

File tree

110 files changed

+4458
-2711
lines changed

Some content is hidden

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

110 files changed

+4458
-2711
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
tags
2020
TAGS
2121

22+
/haddock-api/resources/html/node_modules
23+
/haddock-api/resources/html/*.js.map
24+
2225
.cabal-sandbox
26+
.ghc.environment.*
2327
cabal.sandbox.config
2428

2529
.stack-work/

haddock-api/haddock-api.cabal

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ 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
25+
html/quick-jump.css
2626
html/solarized.css
27-
html/haddock-util.js
2827
html/highlight.js
2928
html/Classic.theme/haskell_icon.gif
3029
html/Classic.theme/minus.gif

haddock-api/resources/html/Ocean.std-theme/ocean.css

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -614,152 +614,3 @@ div#style-menu-holder {
614614
}
615615

616616
/* @end */
617-
618-
/* @group Search box */
619-
620-
#search {
621-
position: fixed;
622-
top: 3.2em;
623-
bottom: 0;
624-
left: calc(50% - 22em);
625-
width: 44em;
626-
z-index: 1000;
627-
pointer-events: none;
628-
}
629-
630-
#search.hidden {
631-
display: none;
632-
}
633-
634-
#search-form, #search-results {
635-
box-shadow: 2px 2px 6px rgb(199, 204, 208);
636-
pointer-events: all;
637-
}
638-
639-
#search-form input {
640-
font-size: 1.25em; line-height: 2.3em; height: 2.4em;
641-
display: block;
642-
box-sizing: border-box;
643-
width: 100%;
644-
padding: 0 0.75em;
645-
border: 0.05em solid rgb(151, 179, 202);
646-
}
647-
648-
#search input:focus {
649-
outline: none;
650-
}
651-
652-
#search-results {
653-
top: 3em;
654-
max-height: calc(100% - 3em);
655-
box-sizing: border-box;
656-
border-width: 0 0.05em 0.05em;
657-
border-style: solid;
658-
border-color: #b2d5fb;
659-
background: #e8f3ff;
660-
overflow-y: auto;
661-
}
662-
663-
#search-results > ul {
664-
margin: 0;
665-
list-style: none;
666-
}
667-
668-
#search-results > ul > li,
669-
#search-results > p,
670-
#search-results > table {
671-
padding: 0.5em 1em;
672-
margin: 0;
673-
}
674-
675-
#search-results > ul > li {
676-
border-bottom: 1px solid #b2d5fb;
677-
}
678-
679-
#search-results > ul > li > ul {
680-
list-style: none;
681-
}
682-
683-
.search-module h4 {
684-
margin: 0;
685-
}
686-
687-
.search-module > ul {
688-
margin: 0.5em 0 0.5em 2em;
689-
}
690-
691-
.search-module > ul > li > a[href] {
692-
display: block;
693-
color: inherit;
694-
padding: 0.25em 0.5em;
695-
}
696-
697-
.search-module > ul > li > a[href].active-link {
698-
background: #faf9dc;
699-
}
700-
701-
.search-module a[href]:hover {
702-
text-decoration: none;
703-
}
704-
705-
.search-result a a {
706-
pointer-events: none;
707-
}
708-
709-
.search-result ul.subs {
710-
display: inline-block;
711-
margin: 0; padding: 0;
712-
}
713-
714-
.search-result ul.subs li {
715-
display: none;
716-
}
717-
718-
.search-result ul.subs::after {
719-
display: inline-block;
720-
content: "...";
721-
color: rgb(78,98,114);
722-
margin: 0 0.25em;
723-
}
724-
725-
.more-results {
726-
color: rgb(99, 141, 173);
727-
position: relative;
728-
}
729-
730-
.more-results::before {
731-
content: "+";
732-
display: inline-block;
733-
color: #b2d5fb;
734-
font-weight: bold;
735-
font-size: 1.25em; line-height: inherit;
736-
position: absolute;
737-
left: -1em;
738-
}
739-
740-
.keyboard-shortcuts {
741-
line-height: 1.6em;
742-
}
743-
744-
.keyboard-shortcuts th {
745-
color: rgb(78,98,114);
746-
}
747-
748-
.keyboard-shortcuts td:first-child,
749-
.keyboard-shortcuts th:first-child {
750-
text-align: right;
751-
padding-right: 0.6em;
752-
}
753-
754-
.key {
755-
display: inline-block;
756-
font-size: 0.9em;
757-
min-width: 0.8em; line-height: 1.2em;
758-
text-align: center;
759-
background: #b2d5fb;
760-
border: 1px solid #74a3d6;
761-
padding: 0 0.2em;
762-
margin: 0 0.1em;
763-
}
764-
765-
/* @end */

haddock-api/resources/html/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
# Development and manual testing
8+
9+
Generate Haddock docs for some Haskell project. Start an HTTP server in the Haddock docs directory.
10+
(The `file://` protocol doesn't work since it doesn't allow AJAX requests.)
11+
12+
After each change to the TypeScript sources, compile and copy the generated files (JS and sourcemaps for better debugging) to the Haddock directory:
13+
14+
```
15+
gulp && cp *.min.js path-to/generated-haddock-docs && cp *.js.map path-to/generated-haddock-docs
16+
```

haddock-api/resources/html/fuse.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
const tsify = require('tsify');
7+
const sourcemaps = require('gulp-sourcemaps');
8+
9+
function buildJS(targetFileName, files) {
10+
var b = browserify({ entries: files, debug: true });
11+
return b
12+
.plugin(tsify)
13+
.bundle()
14+
.pipe(source(targetFileName))
15+
.pipe(buffer())
16+
.pipe(sourcemaps.init({loadMaps: true}))
17+
.pipe(uglify().on('error', function(e) { console.log(e); }))
18+
.pipe(sourcemaps.write('.'))
19+
.pipe(gulp.dest('.'));
20+
}
21+
22+
gulp.task('build-js', function() {
23+
buildJS('quick-jump.min.js', ['./js-src/quick-jump.tsx']);
24+
buildJS('haddock-bundle.min.js', ['./js-src/init.ts']);
25+
});
26+
27+
gulp.task('default', ['build-js']);

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

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

0 commit comments

Comments
 (0)