diff --git a/.gitignore b/.gitignore index 38afc934..e8d87581 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ jspm_packages /demo/build .tmp /coverage +.ghpages-tmp diff --git a/.travis.yml b/.travis.yml index 077a1cc3..208306e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,11 +41,7 @@ deploy: secure: PuhWLERrCEFmXmdFpw2OVFlqpOIVDmgwk5JUJOYaFdVCh/smp0+jZCQ4vrdFpuG96rnDVirD+A8xvW6NgsNNaRthLgOB/LRdFN69rU6Gvn3At6wlnC55t5dlhxPvCfnzJcHVBLXX4EmMkjnZqDg2uczXTzPodr3FnQJNuXmP8B33fzDVLyHccvXZ90abwXWVrgRIXPU28niqCR8DOC2OTzs7wqz+BLNkYDRRbyYXsg62HWuD33x5iof5IqBmhzBt3usCGmF3QGcgHrXHdZw3sZnit8+Bua++3KrXR0x6HGXXN1AoXVmCAkCa5OTQ5R3tCRxiJN3P2KLnvWeZR74sTFkovJB/6pGCvbJ/c7Wnuw6sD7SgOUBD359ULB6lAf5OnxBLoNebX4JxxVXF+zA4E3Bl44VxkzDpPWc15xqBPMB5vBREzMVmJ5mExn2s5cmLQjADbl9h0y6gZnhnNJ+iTmqtrVyM0ZkF2rPrzrTdGD+ULmRIlTMkdD1bh+/TJ3RdXT3P4/zNUJmiNnvgnnJVYYvsGaXWF+7uCVHT/8k2RsoSHqgkqh0gkDqGSwVix55y5mC7T2Vk9lMBhm6MvFJXaonOX0kxJS4EDQ3plPd6/ybG+TLhwggYnQ8o9msU5Nt6FpUShKiezjKurIhbQZdwlVivX3tahjW2QjNDO58xGgY= on: tags: true - - skip_cleanup: true - provider: script - script: npm run github-release - on: - tags: true + condition: $JOB != e2e - skip_cleanup: true provider: script script: npm run branch-release @@ -56,5 +52,5 @@ deploy: provider: script script: npm run deploy on: - branch: master + tags: true condition: $JOB != e2e diff --git a/build/paths.js b/build/paths.js index e2f27ffe..988f2cc8 100644 --- a/build/paths.js +++ b/build/paths.js @@ -9,7 +9,8 @@ var paths = { output: 'dist/', tmp: '.tmp/', demo: 'demo/**/*', - tests: '{lib,tests}/**/*.spec.js' + tests: '{lib,tests}/**/*.spec.js', + releases: 'demo/releases/' } paths.redocBuilt = path.join(paths.output, paths.outputName); diff --git a/build/prepare_deploy.sh b/build/prepare_deploy.sh index c55a08ae..137f404c 100755 --- a/build/prepare_deploy.sh +++ b/build/prepare_deploy.sh @@ -1,6 +1,15 @@ #!/bin/bash set -e set -x +mkdir -p .ghpages-tmp && cd .ghpages-tmp +git checkout gh-pages +cp -R ../releases/* . +git checkout master +cd - +gulp build cd demo cp -R ../dist ./dist +mkdir -p releases +cp -R ../.ghpages-tmp/* ./releases/ cd - +gulp copy-version diff --git a/build/tasks/build.js b/build/tasks/build.js index ef14693b..6897c0a0 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -28,8 +28,7 @@ gulp.task('buildDev', function (callback) { ); }); - -gulp.task('bundle', ['buildStatic', 'concatDeps']); +gulp.task('bundle', ['concatPrism', 'buildStatic', 'concatDeps']); gulp.task('bundleProd', ['bundle', 'buildStaticMin', 'concatDepsMin']); gulp.task('inlineTemplates', ['sass'], function() { @@ -101,3 +100,35 @@ function bundle(outputFile, minify, cb) { cb(new Error(err)); }); } + +gulp.task('concatPrism', function() { + require('../../system.config.js'); + var prismFolder = System.normalizeSync('prismjs').substring(8); + prismFolder = prismFolder.substring(0, prismFolder.length -3); + var prismFiles = [ + 'prism.js', + 'components/prism-actionscript.js', + 'components/prism-c.js', + 'components/prism-cpp.js', + 'components/prism-csharp.js', + 'components/prism-php.js', + 'components/prism-coffeescript.js', + 'components/prism-go.js', + 'components/prism-haskell.js', + 'components/prism-java.js', + 'components/prism-lua.js', + 'components/prism-matlab.js', + 'components/prism-perl.js', + 'components/prism-python.js', + 'components/prism-r.js', + 'components/prism-ruby.js', + 'components/prism-bash.js', + 'components/prism-swift.js', + 'components/prism-objectivec.js', + 'components/prism-scala.js' + ].map(file => path.join(prismFolder, file)); + + gulp.src(prismFiles) + .pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js'))) + .pipe(gulp.dest('.')) +}); diff --git a/build/tasks/copy-version.js b/build/tasks/copy-version.js new file mode 100644 index 00000000..aaf93012 --- /dev/null +++ b/build/tasks/copy-version.js @@ -0,0 +1,10 @@ +var gulp = require('gulp'); +var path = require('path'); +var paths = require('../paths'); + +gulp.task('copy-version', function() { + var tag = 'v' + require(path.join(__dirname, '../../package.json')).version; + gulp.src(paths.redocBuilt + '.min.js') + .pipe(gulp.dest(path.join(paths.releases, tag))) + .pipe(gulp.dest(path.join(paths.releases, 'latest'))); +}); diff --git a/build/tasks/github-release.js b/build/tasks/github-release.js deleted file mode 100644 index d2303cb2..00000000 --- a/build/tasks/github-release.js +++ /dev/null @@ -1,12 +0,0 @@ -var gulp = require('gulp'); -var release = require('gulp-github-release'); -var path = require('path'); -var paths = require('../paths'); - -gulp.task('github-release', ['build'], function(){ - gulp.src(paths.redocBuilt + '.min.js') - .pipe(release({ - token: process.env.GH_TOKEN, - manifest: require(path.join(__dirname, '../../package.json')) - })); -}); diff --git a/build/tasks/test.js b/build/tasks/test.js index 18d396f3..6b93998e 100644 --- a/build/tasks/test.js +++ b/build/tasks/test.js @@ -5,7 +5,7 @@ var Server = require('karma').Server; /** * Run test once and exit */ -gulp.task('test', ['inlineTemplates'], function (done) { +gulp.task('test', ['concatPrism', 'inlineTemplates'], function (done) { new Server({ configFile: __dirname + '/../../karma.conf.js', singleRun: true diff --git a/karma.conf.js b/karma.conf.js index bf73baac..a9dc7af0 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -46,6 +46,8 @@ module.exports = function (config) { //load angular dependencies and browser polyfills files: [ 'node_modules/zone.js/dist/zone.js', + 'node_modules/zone.js/dist/fake-async-test.js', + 'node_modules/zone.js/dist/async-test.js', 'node_modules/zone.js/dist/jasmine-patch.js', 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/babel-polyfill/dist/polyfill.js', @@ -55,7 +57,7 @@ module.exports = function (config) { jspm: { config: 'system.config.js', loadFiles: ['tests/setup.js', 'tests/helpers.js', 'tests/unit/*.spec.js', 'lib/**/*.js'], - serveFiles: ['tests/schemas/**/*.json','tests/schemas/**/*.yml', 'lib/**/*.html', '.tmp/lib/**/*.css'], + serveFiles: ['tests/schemas/**/*.json','tests/schemas/**/*.yml', 'lib/**/*.html', '.tmp/*js', '.tmp/lib/**/*.css'], nocache: true }, @@ -65,6 +67,7 @@ module.exports = function (config) { '/lib/': '/base/lib/', '/jspm_packages/': '/base/jspm_packages/', '/node_modules/': '/base/node_modules/', + '/prismjs-bundle.js': '/base/.tmp/prismjs-bundle.js', '/.tmp/': '/base/.tmp/' }, reporters: travis ? ['mocha', 'coverage', 'coveralls'] : ['mocha', 'coverage'], diff --git a/lib/common/components/DropDown/dropdown.scss b/lib/common/components/DropDown/dropdown.scss index d9d2ef4b..93f6721c 100644 --- a/lib/common/components/DropDown/dropdown.scss +++ b/lib/common/components/DropDown/dropdown.scss @@ -1,13 +1,12 @@ @import '../../styles/variables'; -$silver: #666D71; -$background-silver: #EEEFEF; -$border: darken($background-silver, 2%); - :host { .dk-select { max-width: 100%; - font-family: $headers-font; + font-family: $headers-font, $headers-font-family; + font-size: .929em; + min-width: 100px; + width: auto; } .dk-selected:after { @@ -15,16 +14,11 @@ $border: darken($background-silver, 2%); } // button - .dk-selected { - color: $silver; - border-color: $silver; - padding: 0.4em 0.9em 0.4em 0.4em; - border-radius: 0.4rem; - } - - .dk-select-open-down .dk-selected { - border-radius: 0.4rem; + color: $secondary-color; + border-color: rgba($secondary-color, .5); + padding: 0.15em 0.6em 0.2em 0.5em; + border-radius: $border-radius; } .dk-select-open-down .dk-selected, .dk-selected:focus, .dk-selected:hover { @@ -34,37 +28,45 @@ $border: darken($background-silver, 2%); // tick .dk-selected:before { - border-top-color: $silver; + border-top-color: $secondary-color; border-width: .35em .35em 0; } .dk-select-open-down .dk-selected:before, .dk-select-open-up .dk-selected:before { border-bottom-color: $primary-color; - border-width: 0 .35em .35em; } // items .dk-select-multi:focus .dk-select-options, .dk-select-open-down .dk-select-options, .dk-select-open-up .dk-select-options { - border-color: $silver; + border-color: rgba($secondary-color, .2); + } + + .dk-select-options .dk-option-highlight { + background: #ffffff; } .dk-select-options { margin-top: 0.2em; - border-radius: 0.4em; + padding: 0; + border-radius: $border-radius; + box-shadow: 0px 2px 4px 0px rgba(34, 36, 38, 0.12), 0px 2px 10px 0px rgba(34, 36, 38, 0.08) !important } .dk-option { - color: $black; - padding: 0.4em 0.4em; + color: $secondary-color; + padding: 0.16em 0.6em 0.2em 0.5em; &:hover { - background-color: $background-silver; + background-color: rgba($secondary-color, .12); + } + &:focus { + background-color: rgba($secondary-color, .12); } } .dk-option-selected { - background-color: $background-silver; + background-color: rgba(0, 0, 0, 0.05)!important; } } diff --git a/lib/common/components/StickySidebar/sticky-sidebar.spec.js b/lib/common/components/StickySidebar/sticky-sidebar.spec.js index 08cfe33c..58084d42 100644 --- a/lib/common/components/StickySidebar/sticky-sidebar.spec.js +++ b/lib/common/components/StickySidebar/sticky-sidebar.spec.js @@ -30,7 +30,7 @@ describe('Common components', () => { builder.createAsync(TestApp).then(_fixture => { fixture = _fixture; let debugEl = getChildDebugElementByType(fixture.debugElement, StickySidebar); - component = debugEl.componentInstance; + component = debugEl.injector.get(StickySidebar); done(); }, err => done.fail(err)); }); diff --git a/lib/common/components/Tabs/tabs.js b/lib/common/components/Tabs/tabs.js index d869df20..d8b23da1 100644 --- a/lib/common/components/Tabs/tabs.js +++ b/lib/common/components/Tabs/tabs.js @@ -8,7 +8,7 @@ import {CORE_DIRECTIVES} from 'angular2/common'; events: ['change'], template: ` @@ -61,7 +61,7 @@ export class Tabs { selector: 'tab', inputs: ['tabTitle', 'tabStatus'], template: ` -
+
`, diff --git a/lib/components/ApiInfo/api-info.spec.js b/lib/components/ApiInfo/api-info.spec.js index ae5e8b83..87bcbc0e 100644 --- a/lib/components/ApiInfo/api-info.spec.js +++ b/lib/components/ApiInfo/api-info.spec.js @@ -5,7 +5,8 @@ import {Component, provide} from 'angular2/core'; import { TestComponentBuilder, - injectAsync, + async, + inject, beforeEach, beforeEachProviders, it @@ -26,10 +27,12 @@ describe('Redoc components', () => { provide(SchemaManager, {useValue: new SchemaManager()}), provide(OptionsManager, {useValue: optsMgr}) ]); - beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { + + beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { builder = tcb; - return schemaMgr.load('/tests/schemas/api-info-test.json').then(() => null, (err) => { throw err; }); - })); + return schemaMgr.load('/tests/schemas/api-info-test.json'); + }))); + beforeEach((done) => { builder.createAsync(TestApp).then(_fixture => { fixture = _fixture; diff --git a/lib/components/ApiLogo/api-logo.spec.js b/lib/components/ApiLogo/api-logo.spec.js index 41976344..946f36c8 100644 --- a/lib/components/ApiLogo/api-logo.spec.js +++ b/lib/components/ApiLogo/api-logo.spec.js @@ -5,7 +5,8 @@ import {Component, provide} from 'angular2/core'; import { TestComponentBuilder, - injectAsync, + async, + inject, beforeEach, beforeEachProviders, it @@ -26,11 +27,11 @@ describe('Redoc components', () => { beforeEachProviders(() => [ provide(SchemaManager, {useValue: new SchemaManager()}) ]); - beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, _schemaMgr) => { + beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, _schemaMgr) => { builder = tcb; schemaMgr = _schemaMgr; - return schemaMgr.load(schemaUrl).then(() => null, (err) => { throw err; }); - })); + return schemaMgr.load(schemaUrl); + }))); beforeEach((done) => { builder.createAsync(TestApp).then(_fixture => { fixture = _fixture; diff --git a/lib/components/JsonSchema/json-schema-common.scss b/lib/components/JsonSchema/json-schema-common.scss index c03e356b..4b2d2953 100644 --- a/lib/components/JsonSchema/json-schema-common.scss +++ b/lib/components/JsonSchema/json-schema-common.scss @@ -70,7 +70,7 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; } .param-type { - color: $black; + color: rgba($black, 0.4); font-size: 0.929em; line-height: $param-name-height; vertical-align: middle; @@ -83,10 +83,6 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; font-weight: $base-font-weight; } -.param-type { - color: rgba($black, 0.4); -} - .param-type.with-hint { display: inline-block; margin-bottom: 0.4em; diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js index 47a98624..13457319 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -1,6 +1,6 @@ 'use strict'; -import {Component, ElementRef} from 'angular2/core'; +import {Component, ElementRef, ViewContainerRef} from 'angular2/core'; import {CORE_DIRECTIVES} from 'angular2/common'; import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; @@ -18,10 +18,11 @@ var cache = {}; template: '', directives: [CORE_DIRECTIVES] }) -@Reflect.metadata('parameters', [[SchemaManager], [ElementRef], [DynamicComponentLoader], [OptionsManager]]) +@Reflect.metadata('parameters', [[SchemaManager], [ViewContainerRef], [ElementRef], [DynamicComponentLoader], [OptionsManager]]) export default class JsonSchemaLazy { - constructor(schemaMgr, elementRef, dcl, optionsMgr) { + constructor(schemaMgr, viewRef, elementRef, dcl, optionsMgr) { + this.viewRef = viewRef; this.elementRef = elementRef; this.dcl = dcl; this.optionsMgr = optionsMgr; @@ -37,7 +38,7 @@ export default class JsonSchemaLazy { if (this.optionsMgr.options.disableLazySchemas) return; if (this.loaded) return; if (this.pointer) { - this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { + this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { this.initComponent(compRef); // trigger change detection compRef.hostView.changeDetectorRef.detectChanges(); @@ -57,9 +58,9 @@ export default class JsonSchemaLazy { // skip caching view with tabs inside (discriminator) as it needs attached controller // FIXME: get rid of dependency on selector if ($element.querySelector('.discriminator-wrap')) { - this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { + this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { this.initComponent(compRef); - compRef.hostView.changeDetectorRef.markForCheck(); + compRef.hostView.changeDetectorRef.detectChanges(); }); return; } @@ -67,9 +68,9 @@ export default class JsonSchemaLazy { } ); }); } else { - cache[this.pointer] = this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { + cache[this.pointer] = this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { this.initComponent(compRef); - compRef.hostView.changeDetectorRef.markForCheck(); + compRef.hostView.changeDetectorRef.detectChanges(); return compRef; }); } diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index f633f901..17f56144 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -5,13 +5,17 @@ {{schema._range}}
- {{enumItem.val | json}} + {{enumItem.val | json}}
-