From aeadac234cb893ce4c2a54eb3140625050f0599b Mon Sep 17 00:00:00 2001 From: Pascal Duez Date: Wed, 11 Nov 2015 13:11:43 +0100 Subject: [PATCH 1/9] Add overwritePoster docs and update default file level annotations --- annotations/index.md | 38 +++++++++++----------- extending-sassdoc/index.md | 5 +-- file-level-annotations/index.md | 57 ++++++++++++++++++++++++++++++--- 3 files changed, 75 insertions(+), 25 deletions(-) diff --git a/annotations/index.md b/annotations/index.md index 4df1aaa..4a338f1 100644 --- a/annotations/index.md +++ b/annotations/index.md @@ -63,15 +63,16 @@ Describes the documented item. ## @access -| Attribute | Value | -|-------------|------------------------------------------------------------| -| Description | Defines the access of the documented item | -| Multiple | false | -| Default | `public` | -| Aliases | — | -| Autofilled | false | -| Allowed on | functions, mixins, placeholders, variables | -| Extra notes | Either `public` or `private`. | +| Attribute | Value | +|-----------------|--------------------------------------------------------| +| Description | Defines the access of the documented item | +| Multiple | false | +| Default | `public` | +| Aliases | — | +| Autofilled | false | +| OverwritePoster | true | +| Allowed on | functions, mixins, placeholders, variables | +| Extra notes | Either `public` or `private`. |

Example

@@ -101,15 +102,16 @@ Describes the documented item. ## @author -| Attribute | Value | -|-------------|------------------------------------------------------------| -| Description | Describes the author of the documented item | -| Multiple | true | -| Default | — | -| Aliases | — | -| Autofilled | false | -| Allowed on | functions, mixins, placeholders, variables | -| Extra notes | Parsed as Markdown.* | +| Attribute | Value | +|-----------------|--------------------------------------------------------| +| Description | Describes the author of the documented item | +| Multiple | true | +| Default | — | +| Aliases | — | +| Autofilled | false | +| OverwritePoster | true | +| Allowed on | functions, mixins, placeholders, variables | +| Extra notes | Parsed as Markdown.* |

Example

diff --git a/extending-sassdoc/index.md b/extending-sassdoc/index.md index f27429f..4573c72 100644 --- a/extending-sassdoc/index.md +++ b/extending-sassdoc/index.md @@ -27,8 +27,8 @@ module.exports.annotations = []; ## Schema Each annotation is an object with a `name` property, a `parse` -method, and optionnally `resolve`, `default` and `autofill` -methods and well as an `alias` array and a `multiple` boolean. +method, and optionally `resolve`, `default` and `autofill` +methods and well as an `alias` array, a `multiple` and an `overwritePoster` boolean. | Key | Type | Description | |-----|------|-------------| @@ -38,6 +38,7 @@ methods and well as an `alias` array and a `multiple` boolean. | `default` | function | Returns a default value when — if ever — the annotation is not present. | | `autofill` | function | Takes a parsed annotation object. You can modify this object reference as you want while having access to the whole parsed content of the current annotation. | | `multiple` | boolean | Indicates if this annotation is allowed multiple times per item (default is `true`). | +| `overwritePoster` | boolean | Indicates if this annotation is allowed to override a file level instance (default is `false`). | | `alias` | array | Array of aliases for the annotation. | ## Examples diff --git a/file-level-annotations/index.md b/file-level-annotations/index.md index 7f104a5..e43e2e1 100644 --- a/file-level-annotations/index.md +++ b/file-level-annotations/index.md @@ -11,31 +11,78 @@ Usually, the *poster comment* goes on top of the file. In order to be parsed as Feel free to add a description to it, however it won't be parsed in any way. For now, it is nothing but a comment. [At some point](https://github.com/SassDoc/sassdoc/issues/256), it might be useful though. -

Warning: when an item has an annotation that has already been defined on the poster, it overrides it. It is not merged with the one from the poster, it purely replaces it.

-## Example +## Default behavior (extend) + +When an item has an annotation that has already been defined on the poster, it will get merged (extend). So item level values will get added to file level ones. + +This is the case for most of `multiple` enabled annotations. + +#### Example {% highlight scss %} //// /// This is a poster comment. /// It will apply annotations to all items from file. /// @group API +/// @todo use more variables +//// + +/// This item will have: +/// `@group API` and `@todo use more variables` +/// inherited from the poster. +@function dummy-function() { + // ... +} + +/// This item extends the `@group` and `@todo` annotations +/// from the poster; they are merged. +/// @group utils +/// @todo fix it +@mixin dummy-mixin { + // ... +} +// This item will have: +// group: ['API', 'utils'] +// todo: ['use more variables', 'fix it'] +{% endhighlight %} + + +## Override + +However, annotation with the `overwritePoster` flag will have the opposite behaviour; they will override file level values. + +This is the case for: `@author`, `@access` + +#### Example + +{% highlight scss %} +//// +/// This is a poster comment. +/// It will apply annotations to all items from file. +/// @access private /// @author Hugo Giraudel //// /// This item will have: -/// `@group API` and `@author Hugo Giraudel` +/// `@access private` and `@author Hugo Giraudel` /// inherited from the poster. @function dummy-function() { // ... } -/// This item overrides the `@author` annotation -/// from the poster; it's not merged with it. +/// This item overrides the `@access` and `@author` annotations +/// from the poster; they are replaced. +/// @access public /// @author Fabrice Weinberg @mixin dummy-mixin { // ... } +// This item will have: +// access: 'public' +// author: ['Fabrice Weinberg'] {% endhighlight %} + + {% include routes.html %} From 6bc782f3b0ecfb57fe1059be2e9353b8cf2798bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Galliat?= Date: Fri, 29 May 2015 21:37:23 +0200 Subject: [PATCH 2/9] Add a `debug` option --- configuration/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration/index.md b/configuration/index.md index 94d65da..b127aa8 100644 --- a/configuration/index.md +++ b/configuration/index.md @@ -38,6 +38,7 @@ Here are the available configuration options that does not depend on the theme w | `no-update-notifier` | Boolean | `false` | | `verbose` | Boolean | `false` | | `strict` | Boolean | `false` | +| `debug` | Boolean | `false` | ## Destination From d9aa047be1adb096c9a96a8a9a975aaefccceb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Galliat?= Date: Sat, 21 Feb 2015 15:13:07 +0100 Subject: [PATCH 3/9] Refactor (once again) the make script --- .gitignore | 2 ++ Jakefile | 10 ++++++++ Makefile | 9 ++++--- _themes/package.json | 7 ++++++ jakelib/gallery.jake | 28 +++++++++++++++++++++ jakelib/help.jake | 46 ++++++++++++++++++++++++++++++++++ jakelib/pages.jake | 51 ++++++++++++++++++++++++++++++++++++++ jakelib/preview.jake | 32 ++++++++++++++++++++++++ jakelib/sample.jake | 19 ++++++++++++++ jakelib/theme-gallery.jake | 45 +++++++++++++++++++++++++++++++++ jakelib/themes.jake | 42 +++++++++++++++++++++++++++++++ jakelib/utils.js | 27 ++++++++++++++++++++ jakelib/webshot-promise | 4 +++ jakelib/webshot.jake | 4 +++ package.json | 17 ++++--------- 15 files changed, 328 insertions(+), 15 deletions(-) create mode 100644 Jakefile create mode 100644 _themes/package.json create mode 100644 jakelib/gallery.jake create mode 100644 jakelib/help.jake create mode 100644 jakelib/pages.jake create mode 100644 jakelib/preview.jake create mode 100644 jakelib/sample.jake create mode 100644 jakelib/theme-gallery.jake create mode 100644 jakelib/themes.jake create mode 100644 jakelib/utils.js create mode 100644 jakelib/webshot-promise create mode 100644 jakelib/webshot.jake diff --git a/.gitignore b/.gitignore index 74b9996..36f858d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ node_modules .DS_Store _site +_preview +_sample .sass-cache sassdoc *.map diff --git a/Jakefile b/Jakefile new file mode 100644 index 0000000..b0efe4a --- /dev/null +++ b/Jakefile @@ -0,0 +1,10 @@ +// Register Babel ES6 module loader. +require('babel/register')({ experimental: true }) + +// Require `.jake` files as `.js`. +require.extensions['.jake'] = require.extensions['.js'] + +// Show help by default. +task('default', ['help']) + +// See `jakelib/*.jake` for included files. diff --git a/Makefile b/Makefile index 7550a02..513c059 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -$(MAKECMDGOALS): force - npm run make $@ +all: + @node_modules/.bin/jake -force: +$(MAKECMDGOALS): + @node_modules/.bin/jake $@ + +.PHONY: $(MAKECMDGOALS) diff --git a/_themes/package.json b/_themes/package.json new file mode 100644 index 0000000..f5d5f5f --- /dev/null +++ b/_themes/package.json @@ -0,0 +1,7 @@ +{ + "devDependencies": { + "sassdoc-theme-default": "2.0.0", + "sassdoc-theme-neat": "0.0.2", + "sassdoc-theme-vulcan": "^0.2.0" + } +} diff --git a/jakelib/gallery.jake b/jakelib/gallery.jake new file mode 100644 index 0000000..abad645 --- /dev/null +++ b/jakelib/gallery.jake @@ -0,0 +1,28 @@ +const { im, yaml } = require('./utils') +const exec = require('mz/child_process').exec + +const gallery = yaml('_data/gallery.yml') + .map(x => { x.name = x.image.replace(/\..*$/, ''); return x }) + +const galleryDir = 'assets/images/gallery' + +directory(galleryDir) + +gallery.forEach(item => { + const image = `${galleryDir}/${item.image}` + + file(image, [galleryDir, 'webshot'], async () => { + im`Rendering ${item.url} in ${image}.` + + await require('./webshot-promise')(item.url, image, { + screenSize: { width: 1440, height: 900 }, + defaultWhiteBackground: true, + }) + + await exec(`mogrify -resize 900x '${image}'`) + }) + + task(`gallery-${item.name}`, [image]) +}) + +task('gallery', gallery.map(x => `gallery-${x.name}`)) diff --git a/jakelib/help.jake b/jakelib/help.jake new file mode 100644 index 0000000..d299b4f --- /dev/null +++ b/jakelib/help.jake @@ -0,0 +1,46 @@ +const chalk = require('chalk') + +const key = name => + `${chalk.red('*')} ${chalk.green(name)}` + +const title = (text, char='-') => + `${chalk.blue(text)}\n${chalk.yellow(char.repeat(text.length))}` + +const code = text => chalk.green(text) + +task('help', () => { + console.log(` +${title('sassdoc.com build script', '=')} + +Execute ${chalk.green('make ...')} to execute one or multiple tasks. + +${title('General')} + +${key('help')} Show this help. +${key('preview')} Render the preview image ${code('assets/images/preview-image.png')}. +${key('sample')} Fetch some SCSS sample in ${code('_sample')}. +${key('webshot')} Download Webshot. + +${title('Pages')} + +${key('changelog')} Fetch the changelog from GitHub repository. +${key('upgrading')} Fetch the upgrading page from GitHub repository. + +${title('Themes')} + +${key('themes')} Compile ${code('_data/themes.yml')} (package data for each + theme shown on the website). +${key('theme-')} Download given theme (e.g. ${code('make theme-vulcan')}). + +${title('Gallery')} + +${key('gallery')} Render all gallery images (${code('assets/images/gallery/*')}). +${key('gallery-')} Render a specific gallery image (e.g. ${code('make gallery-sassysort')}). + +${title('Theme gallery')} + +${key('theme-gallery')} Render all the themes and their preview images + in ${code('theme-gallery')}. +${key('theme-gallery-')} Render a specific themes (e.g. ${code('make theme-gallery-neat')}). +`) +}) diff --git a/jakelib/pages.jake b/jakelib/pages.jake new file mode 100644 index 0000000..abbdcb0 --- /dev/null +++ b/jakelib/pages.jake @@ -0,0 +1,51 @@ +const { im } = require('./utils') +const filter = require('through2-filter') +const fs = require('fs') +const map = require('through2-map') +const promisePipe = require('promisepipe') +const request = require('request') +const split = require('split') + +const repo = 'https://raw.githubusercontent.com/SassDoc/sassdoc/master' + +// Filter stream chunks with a count. +const filterCount = (f, i=0) => + filter(line => f(line, ++i)) + +// Turn GitHub code blocks in Liquide code blocks. +const convertCodeBlocks = line => + line + .replace(/^( *)```([a-z0-9]+)$/, '$1{% highlight $2 %}') + .replace(/^( *)```$/, '$1{% endhighlight %}') + +function page(name, remote, header) { + task(name, async () => { + const local = `${name}/index.md` + const url = `${repo}/${remote}` + const output = fs.createWriteStream(local) + + im`Retrieving ${remote} from main repository to ${local}.` + + output.write(header) + + await promisePipe( + request(url), + split(/(\n)/), + filterCount((line, i) => i > 4), + map({ wantStrings: true }, convertCodeBlocks), + output + ) + }) +} + +page( + 'changelog', + 'CHANGELOG.md', + '---\nlayout: default\ntitle: "Changelog"\n---\n\n' +) + +page( + 'upgrading', + 'UPGRADE-2.0.md', + '---\nlayout: default\ntitle: "Upgrade from 1.0 to 2.0"\n---\n\n' +) diff --git a/jakelib/preview.jake b/jakelib/preview.jake new file mode 100644 index 0000000..f605e56 --- /dev/null +++ b/jakelib/preview.jake @@ -0,0 +1,32 @@ +const { im, furl } = require('./utils') +const { themes } = require('./themes') +const { sampleDir } = require('./sample') +const fse = require('fs-extra-promise') +const sassdoc = require('sassdoc') + +const defaultTheme = themes.find(x => x.shortName === 'default') +const preview = 'assets/images/preview-image.png' + +file('_preview', [sampleDir, defaultTheme.package], async () => { + im`Compiling ${'default'} theme in ${'_preview'}.` + console.log() + + await sassdoc(sampleDir, { + dest: '_preview', + package: defaultTheme.package, + verbose: true, + }) + + console.log() +}) + +file(preview, ['_preview', 'webshot'], async () => { + im`Taking a screenshot in ${preview}.` + + await require('./webshot-promise')(furl('_preview/index.html'), preview, { + screenSize: { width: 1200, height: 675 }, + defaultWhiteBackground: true, + }) +}) + +task('preview', [preview]) diff --git a/jakelib/sample.jake b/jakelib/sample.jake new file mode 100644 index 0000000..21bef26 --- /dev/null +++ b/jakelib/sample.jake @@ -0,0 +1,19 @@ +const { im, asyncTask } = require('./utils') +const { themes } = require('./themes') +const exec = require('mz/child_process').exec +const fs = require('mz/fs') +const fse = require('fs-extra-promise') + +const defaultTheme = 'https://github.com/SassDoc/sassdoc-theme-default' +export const sampleDir = `_sample` + +file(sampleDir, async () => { + im`Cloning ${defaultTheme}.` + await exec(`git clone '${defaultTheme}' '${sampleDir}-git'`) + + im`Copying ${'scss/utils'} from theme to ${sampleDir}.` + await fs.rename(`${sampleDir}-git/scss/utils`, sampleDir) + await fse.remove(`${sampleDir}-git`) +}) + +task('sample', [sampleDir]) diff --git a/jakelib/theme-gallery.jake b/jakelib/theme-gallery.jake new file mode 100644 index 0000000..06b35e3 --- /dev/null +++ b/jakelib/theme-gallery.jake @@ -0,0 +1,45 @@ +const { im, furl } = require('./utils') +const { themes } = require('./themes') +const { sampleDir } = require('./sample') +const exec = require('mz/child_process').exec +const sassdoc = require('sassdoc') + +const previewDir = 'theme-gallery/preview' +const thumbDir = 'theme-gallery/thumbs' + +directory(previewDir) +directory(thumbDir) + +themes.forEach(theme => { + const preview = `${previewDir}/${theme.shortName}` + const thumb = `${thumbDir}/${theme.shortName}.png` + + task(preview, [sampleDir, theme.dir, previewDir], async () => { + im`Compiling ${theme.shortName} theme in ${preview}.` + console.log() + + await sassdoc(sampleDir, { + dest: preview, + package: theme.package, + theme: theme.dir, + verbose: true, + }) + + console.log() + }) + + task(thumb, [preview, thumbDir, 'webshot'], async () => { + im`Taking a screenshot of ${preview} in ${thumb}.` + + await require('./webshot-promise')(furl(`${preview}/index.html`), thumb, { + screenSize: { width: 1024, height: 768 }, + defaultWhiteBackground: true, + }) + + await exec(`mogrify -resize 256x192 '${thumb}'`) + }) + + task(`theme-gallery-${theme.shortName}`, [preview, thumb]) +}) + +task('theme-gallery', themes.map(x => `theme-gallery-${x.shortName}`)) diff --git a/jakelib/themes.jake b/jakelib/themes.jake new file mode 100644 index 0000000..4c0d1a7 --- /dev/null +++ b/jakelib/themes.jake @@ -0,0 +1,42 @@ +const { im } = require('./utils') +const CombinedStream = require('combined-stream') +const exec = require('mz/child_process').exec +const fs = require('fs') +const promisePipe = require('promisepipe') +const themesPackage = require('../_themes/package') + +export const themes = Object.keys(themesPackage.devDependencies) + .map(name => ({ + shortName: name.replace(/^sassdoc-theme-/, ''), + name, + dir: `_themes/node_modules/${name}`, + package: `_themes/node_modules/${name}/package.json`, + version: themesPackage.devDependencies[name], + })) + +themes.forEach(theme => { + file(theme.dir, async () => { + im`Installing ${theme.name}.` + await exec(`cd _themes && npm install '${theme.name}@${theme.version}'`) + }) + + file(theme.package, [theme.dir], () => {}) + task(`theme-${theme.shortName}`, [theme.dir]) +}) + +file('_data/themes.yml', themes.map(x => x.package), async () => { + const file = '_data/themes.yml' + const output = fs.createWriteStream(file) + const combined = CombinedStream.create() + + im`Generating ${file}.` + + themes.forEach(theme => { + combined.append(`${theme.shortName}: `) + combined.append(fs.createReadStream(theme.package)) + }) + + await promisePipe(combined, output) +}) + +task('themes', ['_data/themes.yml']) diff --git a/jakelib/utils.js b/jakelib/utils.js new file mode 100644 index 0000000..5ba6f6c --- /dev/null +++ b/jakelib/utils.js @@ -0,0 +1,27 @@ +const chalk = require('chalk') +const fs = require('mz/fs') +const path = require('path') +const jsYaml = require('js-yaml') + +const chevron = '»' + +export const zip = (...arrays) => + arrays[0].map((_, i) => + arrays.map(array => array[i]) + ) + +const decorateValues = values => + values.map(x => chalk.green(x)) + +// Say what I'm doing (template string). +export function im(strings, ...values) { + const [xs, x] = [strings.slice(0, -1), strings.slice(-1)] + const parts = [].concat(...zip(xs, decorateValues(values)), x) + console.log(chalk.green(chevron), parts.join('')) +} + +// Convert a file to absolute `file://` URL. +export const furl = file => `file://${path.resolve(file)}` + +export const yaml = file => + jsYaml.safeLoad(fs.readFileSync(file)) diff --git a/jakelib/webshot-promise b/jakelib/webshot-promise new file mode 100644 index 0000000..80bb20a --- /dev/null +++ b/jakelib/webshot-promise @@ -0,0 +1,4 @@ +const denodeify = require('es6-denodeify')(Promise) +const webshot = require('webshot') + +export default denodeify(webshot) diff --git a/jakelib/webshot.jake b/jakelib/webshot.jake new file mode 100644 index 0000000..c7023b8 --- /dev/null +++ b/jakelib/webshot.jake @@ -0,0 +1,4 @@ +const exec = require('mz/child_process').exec + +file('node_modules/webshot', () => exec('npm install webshot')) +task('webshot', ['node_modules/webshot']) diff --git a/package.json b/package.json index 5d71d4e..f417413 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,19 @@ { - "dependencies": { - "array-zip": "^1.0.0", - "atom-screenshot": "^0.4.3", - "babel": "^4.4.0", + "devDependencies": { + "babel": "^4.4.3", + "chalk": "^0.5.1", "combined-stream": "0.0.7", + "es6-denodeify": "^0.1.1", "event-stream": "^3.2.1", "fs-extra-promise": "^0.1.0", + "jake": "^8.0.10", "js-yaml": "^3.2.5", "mz": "^1.2.1", "promisepipe": "^1.0.1", "request": "^2.51.0", "sassdoc": "^2.1.0", - "sassdoc-theme-default": "^2.3.0", - "sassdoc-theme-flippant": "^0.1.0", - "sassdoc-theme-neat": "0.0.2", - "sassdoc-theme-rest": "^1.0.2", - "sassdoc-theme-vulcan": "^0.2.0", "split": "^0.3.2", "through2-filter": "^1.4.0", "through2-map": "^1.4.0" - }, - "scripts": { - "make": "babel-node --experimental make" } } From 0f3a9b7d3341007c7418ea13adc2b85f90ec77ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Galliat?= Date: Sun, 6 Dec 2015 12:00:25 -0500 Subject: [PATCH 4/9] Move to electron-screenshot-service --- jakelib/gallery.jake | 10 ++++++---- jakelib/help.jake | 2 +- jakelib/preview.jake | 10 ++++++---- jakelib/screenshot | 10 ++++++++++ jakelib/screenshot.jake | 5 +++++ jakelib/theme-gallery.jake | 10 ++++++---- jakelib/webshot-promise | 4 ---- jakelib/webshot.jake | 4 ---- 8 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 jakelib/screenshot create mode 100644 jakelib/screenshot.jake delete mode 100644 jakelib/webshot-promise delete mode 100644 jakelib/webshot.jake diff --git a/jakelib/gallery.jake b/jakelib/gallery.jake index abad645..9a5170f 100644 --- a/jakelib/gallery.jake +++ b/jakelib/gallery.jake @@ -11,12 +11,14 @@ directory(galleryDir) gallery.forEach(item => { const image = `${galleryDir}/${item.image}` - file(image, [galleryDir, 'webshot'], async () => { + file(image, [galleryDir, 'screenshot'], async () => { im`Rendering ${item.url} in ${image}.` - await require('./webshot-promise')(item.url, image, { - screenSize: { width: 1440, height: 900 }, - defaultWhiteBackground: true, + await require('./screenshot')({ + url: item.url, + dest: image, + width: 1440, + height: 900 }) await exec(`mogrify -resize 900x '${image}'`) diff --git a/jakelib/help.jake b/jakelib/help.jake index d299b4f..c310c0f 100644 --- a/jakelib/help.jake +++ b/jakelib/help.jake @@ -19,7 +19,7 @@ ${title('General')} ${key('help')} Show this help. ${key('preview')} Render the preview image ${code('assets/images/preview-image.png')}. ${key('sample')} Fetch some SCSS sample in ${code('_sample')}. -${key('webshot')} Download Webshot. +${key('screenshot')} Download the screenshot tool. ${title('Pages')} diff --git a/jakelib/preview.jake b/jakelib/preview.jake index f605e56..496b447 100644 --- a/jakelib/preview.jake +++ b/jakelib/preview.jake @@ -20,12 +20,14 @@ file('_preview', [sampleDir, defaultTheme.package], async () => { console.log() }) -file(preview, ['_preview', 'webshot'], async () => { +file(preview, ['_preview', 'screenshot'], async () => { im`Taking a screenshot in ${preview}.` - await require('./webshot-promise')(furl('_preview/index.html'), preview, { - screenSize: { width: 1200, height: 675 }, - defaultWhiteBackground: true, + await require('./screenshot')({ + url: furl('_preview/index.html'), + dest: preview, + width: 1200, + height: 675 }) }) diff --git a/jakelib/screenshot b/jakelib/screenshot new file mode 100644 index 0000000..ac6a844 --- /dev/null +++ b/jakelib/screenshot @@ -0,0 +1,10 @@ +const denodeify = require('es6-denodeify')(Promise) +const screenshot = require('electron-screenshot-service') +const fs = require('fs') +const writeFile = denodeify(fs.writeFile) + +jake.addListener('complete', () => screenshot.close()) + +export default opts => + screenshot(opts) + .then(img => writeFile(opts.dest, img.data)) diff --git a/jakelib/screenshot.jake b/jakelib/screenshot.jake new file mode 100644 index 0000000..d4b2234 --- /dev/null +++ b/jakelib/screenshot.jake @@ -0,0 +1,5 @@ +const exec = require('mz/child_process').exec +const name = 'electron-screenshot-service' + +file(`node_modules/${name}`, () => exec(`npm install ${name}`)) +task('screenshot', [`node_modules/${name}`]) diff --git a/jakelib/theme-gallery.jake b/jakelib/theme-gallery.jake index 06b35e3..4afc9c3 100644 --- a/jakelib/theme-gallery.jake +++ b/jakelib/theme-gallery.jake @@ -28,12 +28,14 @@ themes.forEach(theme => { console.log() }) - task(thumb, [preview, thumbDir, 'webshot'], async () => { + task(thumb, [preview, thumbDir, 'screenshot'], async () => { im`Taking a screenshot of ${preview} in ${thumb}.` - await require('./webshot-promise')(furl(`${preview}/index.html`), thumb, { - screenSize: { width: 1024, height: 768 }, - defaultWhiteBackground: true, + await require('./screenshot')({ + url: furl(`${preview}/index.html`), + dest: thumb, + width: 1024, + height: 768 }) await exec(`mogrify -resize 256x192 '${thumb}'`) diff --git a/jakelib/webshot-promise b/jakelib/webshot-promise deleted file mode 100644 index 80bb20a..0000000 --- a/jakelib/webshot-promise +++ /dev/null @@ -1,4 +0,0 @@ -const denodeify = require('es6-denodeify')(Promise) -const webshot = require('webshot') - -export default denodeify(webshot) diff --git a/jakelib/webshot.jake b/jakelib/webshot.jake deleted file mode 100644 index c7023b8..0000000 --- a/jakelib/webshot.jake +++ /dev/null @@ -1,4 +0,0 @@ -const exec = require('mz/child_process').exec - -file('node_modules/webshot', () => exec('npm install webshot')) -task('webshot', ['node_modules/webshot']) From db9244ab68ffb077ec225512cf3ab91ed5ad5f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Galliat?= Date: Sun, 6 Dec 2015 13:27:04 -0500 Subject: [PATCH 5/9] Include new themes --- _themes/package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/_themes/package.json b/_themes/package.json index f5d5f5f..6aea336 100644 --- a/_themes/package.json +++ b/_themes/package.json @@ -1,7 +1,9 @@ { "devDependencies": { - "sassdoc-theme-default": "2.0.0", - "sassdoc-theme-neat": "0.0.2", + "sassdoc-theme-default": "^2.0.0", + "sassdoc-theme-flippant": "^0.1.0", + "sassdoc-theme-neat": "^0.0.2", + "sassdoc-theme-rest": "^1.0.2", "sassdoc-theme-vulcan": "^0.2.0" } } From 17a9720ae4e0e4e1f1bc877107b4da377d14be22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Galliat?= Date: Sun, 6 Dec 2015 13:28:48 -0500 Subject: [PATCH 6/9] Remove `make.js` --- make.js | 289 -------------------------------------------------------- 1 file changed, 289 deletions(-) delete mode 100644 make.js diff --git a/make.js b/make.js deleted file mode 100644 index ca2a0fc..0000000 --- a/make.js +++ /dev/null @@ -1,289 +0,0 @@ -// Dependencies {{{ -// ================ - -const CombinedStream = require('combined-stream') -const es = require('event-stream') -const exec = require('mz/child_process').exec -const filter = require('through2-filter') -const fs = require('mz/fs') -const fse = require('fs-extra-promise') -const map = require('through2-map') -const path = require('path') -const promisePipe = require('promisepipe') -const readline = require('readline') -const request = require('request') -const sassdoc = require('sassdoc') -const screenshot = require('atom-screenshot') -const split = require('split') -const yaml = require('js-yaml') -const zip = require('array-zip') - -// }}} - -// Helpers {{{ -// =========== - -const repoUrl = 'https://raw.githubusercontent.com/SassDoc/sassdoc/master' - -// Say what I'm doing. -function im(...args) { - console.log() - console.log(...args) - console.log() -} - -// Get a file as URL. -const furl = file => `file://${path.resolve(file)}` - -// Return a callback to write given file. -const writeFile = (file, options) => - buffer => fs.writeFile(file, buffer, options) - -// Filter stream chunks with a count. -const filterCount = (f, i=0) => - filter(line => f(line, ++i)) - -// Read a YAML file. -const yamlf = async file => - yaml.safeLoad(await fs.readFile(file)) - -const shot = options => - screenshot({ - ...options, - css: '::-webkit-scrollbar { display: none; }', - }) - -// Tasks container. -const t = {} - -// }}} - -// Pages {{{ -// ========= - -// Turn GitHub code blocks in Liquide code blocks. -const convertCodeBlocks = line => - line - .replace(/^( *)```([a-z0-9]+)$/, '$1{% highlight $2 %}') - .replace(/^( *)```$/, '$1{% endhighlight %}') - -async function page(local, remote, header) { - im(`Retrieving \`${remote}\` from main repository to \`${local}\`.`) - - const url = `${repoUrl}/${remote}` - const output = fs.createWriteStream(local) - - output.write(header) - - await promisePipe( - request(url), - split(/(\n)/), - filterCount((line, i) => i > 4), - map({ wantStrings: true }, convertCodeBlocks), - output - ) -} - -t.changelog = () => - page( - 'changelog/index.md', - 'CHANGELOG.md', - '---\nlayout: default\ntitle: "Changelog"\n---\n\n' - ) - -t.upgrading = () => - page( - 'upgrading/index.md', - 'UPGRADE-2.0.md', - '---\nlayout: default\ntitle: "Upgrade from 1.0 to 2.0"\n---\n\n' - ) - -// }}} - -// Themes {{{ -// ========== - -const themes = ['default', 'vulcan', 'neat', 'flippant' /*, 'rest' */] -const themeDirs = themes.map(x => `node_modules/sassdoc-theme-${x}`) -const themePackages = themeDirs.map(x => `${x}/package.json`) - -const themeGallery = 'theme-gallery' -const sampleDir = `${themeGallery}/sample` -const defaultTheme = 'https://github.com/SassDoc/sassdoc-theme-default' - -// Sample {{{ -// ---------- - -t.sample = async () => { - if (!await fs.exists(sampleDir)) { - im('Cloning default theme to get sample SCSS files.') - await exec(`git clone '${defaultTheme}' '${sampleDir}-git'`) - await fs.rename(`${sampleDir}-git/scss/utils`, sampleDir) - await fse.remove(`${sampleDir}-git`) - } -} - -// }}} - -// Gallery {{{ -// ----------- - -t['theme-gallery'] = async () => { - // Ensure sample directory exists. - await t.sample() - - const previewDir = `${themeGallery}/preview` - const thumbDir = `${themeGallery}/thumbs` - - await Promise.all([previewDir, thumbDir].map(x => fse.mkdirs(x))) - - for (let theme of process.env.THEME ? [process.env.THEME] : themes) { - const themePackage = themePackages[themes.indexOf(theme)] - const preview = `${previewDir}/${theme}` - const thumb = `${thumbDir}/${theme}.png` - - im(`Compiling \`${theme}\` theme in \`${preview}\`.`) - - await sassdoc(sampleDir, { - dest: preview, - package: themePackage, - theme, - verbose: true, - }) - - im(`Taking a screenshot of \`${theme}\` theme in \`${thumb}\`.`) - - await shot({ - url: furl(`${preview}/index.html`), - width: 1024, - height: 768, - }) - .then(writeFile(thumb)) - - await exec(`mogrify -resize 256x192 '${thumb}'`) - } -} - -// }}} - -t.themes = async () => { - const file = '_data/themes.yml' - const output = fs.createWriteStream(file) - const combined = CombinedStream.create() - - im(`Generating \`${file}\`.`) - - for (let [theme, themePackage] of zip(themes, themePackages)) { - combined.append(`${theme}: `) - combined.append(fs.createReadStream(themePackage)) - } - - await promisePipe(combined, output) -} - -// }}} - -// Preview {{{ -// =========== - -t.preview = async () => { - // Ensure sample directory exists. - await t.sample() - - const preview = 'assets/images/preview-image.png' - - im('Compiling `default` theme in `.preview`.') - - await sassdoc(sampleDir, { - dest: '.preview', - package: `node_modules/sassdoc-theme-default/package.json`, - verbose: true, - }) - - im(`Taking a screenshot in \`${preview}\`.`) - - await shot({ - url: furl('.preview/index.html'), - width: 1200, - height: 675, - }) - .then(writeFile(preview)) - - await fse.remove('.preview') -} - -// }}} - -// Gallery {{{ -// =========== - -t.gallery = async () => { - const gallery = await yamlf('_data/gallery.yml') - const galleryDir = 'assets/images/gallery' - - const images = gallery - .map(x => x.image) - .map(x => `${galleryDir}/${x}`) - - // Ensure directory exists. - await fse.mkdirs(galleryDir) - - const filter = !process.env.SITE - ? () => true - : x => x.image === `${process.env.SITE}.png` - - await Promise.all( - gallery - .filter(filter) - .map(async x => { - const file = `${galleryDir}/${x.image}` - - await shot({ - url: x.url, - width: 1440, - height: 900, - }) - .then(writeFile(file)) - - await exec(`mogrify -resize 900x '${file}'`) - }) - ) -} - -// }}} - -// Execution {{{ -// ============= - -async () => { - const targets = process.argv.slice(2) - - // Show existing targets. - if (!targets.length) { - console.error('Please specify a target. Available targets:') - Object.keys(t).map(x => ` ${x}`).forEach(console.error) - process.exit(1) - } - - // Show unknown targets and exit if any. - targets - .filter(target => !(target in t)) - .map(target => console.error(`Unknown target \`${target}\`.`)) - .forEach(() => process.exit(1)) - - const throwNextTick = err => - setImmediate(() => { throw err }) - - // Call all targets, wait promises. - await Promise.all( - targets - .map(target => t[target]()) - .filter(p => p instanceof Promise) - .map(p => p.catch(throwNextTick)) - ) - - // Close screenshot service if needed. - screenshot.close() -}() - -// }}} From e526bc50fe41ac61b1ddcd2c5bf09d13614121bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Galliat?= Date: Sun, 6 Dec 2015 18:42:19 -0500 Subject: [PATCH 7/9] Upgrade dependencies --- Jakefile | 3 ++- package.json | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Jakefile b/Jakefile index b0efe4a..87c7543 100644 --- a/Jakefile +++ b/Jakefile @@ -1,5 +1,6 @@ // Register Babel ES6 module loader. -require('babel/register')({ experimental: true }) +require('babel-core/register') +require('babel-polyfill') // Require `.jake` files as `.js`. require.extensions['.jake'] = require.extensions['.js'] diff --git a/package.json b/package.json index f417413..c93b7d0 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,28 @@ { "devDependencies": { - "babel": "^4.4.3", - "chalk": "^0.5.1", - "combined-stream": "0.0.7", + "babel-core": "^6.3.15", + "babel-polyfill": "^6.3.14", + "babel-preset-es2015": "^6.3.13", + "babel-preset-stage-0": "^6.3.13", + "chalk": "^1.1.1", + "combined-stream": "^1.0.5", "es6-denodeify": "^0.1.1", "event-stream": "^3.2.1", - "fs-extra-promise": "^0.1.0", + "fs-extra-promise": "^0.3.1", "jake": "^8.0.10", "js-yaml": "^3.2.5", - "mz": "^1.2.1", + "mz": "^2.1.0", "promisepipe": "^1.0.1", "request": "^2.51.0", "sassdoc": "^2.1.0", - "split": "^0.3.2", - "through2-filter": "^1.4.0", - "through2-map": "^1.4.0" + "split": "^1.0.0", + "through2-filter": "^2.0.0", + "through2-map": "^2.0.0" + }, + "babel": { + "presets": [ + "es2015", + "stage-0" + ] } } From e48fdf6408b54c196b42a15175ee0df1d1bb15af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Galliat?= Date: Sun, 6 Dec 2015 18:55:39 -0500 Subject: [PATCH 8/9] ES6 imports --- jakelib/gallery.jake | 7 ++++--- jakelib/help.jake | 2 +- jakelib/pages.jake | 14 +++++++------- jakelib/preview.jake | 13 +++++++------ jakelib/sample.jake | 10 +++++----- jakelib/screenshot | 10 ---------- jakelib/screenshot.jake | 3 ++- jakelib/screenshot.js | 11 +++++++++++ jakelib/theme-gallery.jake | 13 +++++++------ jakelib/themes.jake | 12 ++++++------ jakelib/utils.js | 8 ++++---- 11 files changed, 54 insertions(+), 49 deletions(-) delete mode 100644 jakelib/screenshot create mode 100644 jakelib/screenshot.js diff --git a/jakelib/gallery.jake b/jakelib/gallery.jake index 9a5170f..78d28fe 100644 --- a/jakelib/gallery.jake +++ b/jakelib/gallery.jake @@ -1,5 +1,6 @@ -const { im, yaml } = require('./utils') -const exec = require('mz/child_process').exec +import { im, yaml } from './utils' +import { exec } from 'mz/child_process' +import screenshot from './screenshot' const gallery = yaml('_data/gallery.yml') .map(x => { x.name = x.image.replace(/\..*$/, ''); return x }) @@ -14,7 +15,7 @@ gallery.forEach(item => { file(image, [galleryDir, 'screenshot'], async () => { im`Rendering ${item.url} in ${image}.` - await require('./screenshot')({ + await screenshot({ url: item.url, dest: image, width: 1440, diff --git a/jakelib/help.jake b/jakelib/help.jake index c310c0f..05afdf2 100644 --- a/jakelib/help.jake +++ b/jakelib/help.jake @@ -1,4 +1,4 @@ -const chalk = require('chalk') +import chalk from 'chalk' const key = name => `${chalk.red('*')} ${chalk.green(name)}` diff --git a/jakelib/pages.jake b/jakelib/pages.jake index abbdcb0..a15257d 100644 --- a/jakelib/pages.jake +++ b/jakelib/pages.jake @@ -1,10 +1,10 @@ -const { im } = require('./utils') -const filter = require('through2-filter') -const fs = require('fs') -const map = require('through2-map') -const promisePipe = require('promisepipe') -const request = require('request') -const split = require('split') +import { im } from './utils' +import filter from 'through2-filter' +import fs from 'fs' +import map from 'through2-map' +import promisePipe from 'promisepipe' +import request from 'request' +import split from 'split' const repo = 'https://raw.githubusercontent.com/SassDoc/sassdoc/master' diff --git a/jakelib/preview.jake b/jakelib/preview.jake index 496b447..427491a 100644 --- a/jakelib/preview.jake +++ b/jakelib/preview.jake @@ -1,8 +1,9 @@ -const { im, furl } = require('./utils') -const { themes } = require('./themes') -const { sampleDir } = require('./sample') -const fse = require('fs-extra-promise') -const sassdoc = require('sassdoc') +import { im, furl } from './utils' +import { themes } from './themes' +import { sampleDir } from './sample' +import fse from 'fs-extra-promise' +import sassdoc from 'sassdoc' +import screenshot from './screenshot' const defaultTheme = themes.find(x => x.shortName === 'default') const preview = 'assets/images/preview-image.png' @@ -23,7 +24,7 @@ file('_preview', [sampleDir, defaultTheme.package], async () => { file(preview, ['_preview', 'screenshot'], async () => { im`Taking a screenshot in ${preview}.` - await require('./screenshot')({ + await screenshot({ url: furl('_preview/index.html'), dest: preview, width: 1200, diff --git a/jakelib/sample.jake b/jakelib/sample.jake index 21bef26..5227265 100644 --- a/jakelib/sample.jake +++ b/jakelib/sample.jake @@ -1,8 +1,8 @@ -const { im, asyncTask } = require('./utils') -const { themes } = require('./themes') -const exec = require('mz/child_process').exec -const fs = require('mz/fs') -const fse = require('fs-extra-promise') +import { im, asyncTask } from './utils' +import { themes } from './themes' +import exec from 'mz/child_process' +import fs from 'mz/fs' +import fse from 'fs-extra-promise' const defaultTheme = 'https://github.com/SassDoc/sassdoc-theme-default' export const sampleDir = `_sample` diff --git a/jakelib/screenshot b/jakelib/screenshot deleted file mode 100644 index ac6a844..0000000 --- a/jakelib/screenshot +++ /dev/null @@ -1,10 +0,0 @@ -const denodeify = require('es6-denodeify')(Promise) -const screenshot = require('electron-screenshot-service') -const fs = require('fs') -const writeFile = denodeify(fs.writeFile) - -jake.addListener('complete', () => screenshot.close()) - -export default opts => - screenshot(opts) - .then(img => writeFile(opts.dest, img.data)) diff --git a/jakelib/screenshot.jake b/jakelib/screenshot.jake index d4b2234..bb068cd 100644 --- a/jakelib/screenshot.jake +++ b/jakelib/screenshot.jake @@ -1,4 +1,5 @@ -const exec = require('mz/child_process').exec +import { exec } from 'mz/child_process' + const name = 'electron-screenshot-service' file(`node_modules/${name}`, () => exec(`npm install ${name}`)) diff --git a/jakelib/screenshot.js b/jakelib/screenshot.js new file mode 100644 index 0000000..6562155 --- /dev/null +++ b/jakelib/screenshot.js @@ -0,0 +1,11 @@ +import denodeify from 'es6-denodeify' +import screenshot from 'electron-screenshot-service' +import fs from 'fs' + +const writeFile = denodeify(Promise)(fs.writeFile) + +jake.addListener('complete', () => screenshot.close()) + +export default opts => + screenshot(opts) + .then(img => writeFile(opts.dest, img.data)) diff --git a/jakelib/theme-gallery.jake b/jakelib/theme-gallery.jake index 4afc9c3..aebab3b 100644 --- a/jakelib/theme-gallery.jake +++ b/jakelib/theme-gallery.jake @@ -1,8 +1,9 @@ -const { im, furl } = require('./utils') -const { themes } = require('./themes') -const { sampleDir } = require('./sample') -const exec = require('mz/child_process').exec -const sassdoc = require('sassdoc') +import { im, furl } from './utils' +import { themes } from './themes' +import { sampleDir } from './sample' +import { exec } from 'mz/child_process' +import sassdoc from 'sassdoc' +import screenshot from './screenshot' const previewDir = 'theme-gallery/preview' const thumbDir = 'theme-gallery/thumbs' @@ -31,7 +32,7 @@ themes.forEach(theme => { task(thumb, [preview, thumbDir, 'screenshot'], async () => { im`Taking a screenshot of ${preview} in ${thumb}.` - await require('./screenshot')({ + await screenshot({ url: furl(`${preview}/index.html`), dest: thumb, width: 1024, diff --git a/jakelib/themes.jake b/jakelib/themes.jake index 4c0d1a7..2a1a5e8 100644 --- a/jakelib/themes.jake +++ b/jakelib/themes.jake @@ -1,9 +1,9 @@ -const { im } = require('./utils') -const CombinedStream = require('combined-stream') -const exec = require('mz/child_process').exec -const fs = require('fs') -const promisePipe = require('promisepipe') -const themesPackage = require('../_themes/package') +import { im } from './utils' +import CombinedStream from 'combined-stream' +import { exec } from 'mz/child_process' +import fs from 'fs' +import promisePipe from 'promisepipe' +import themesPackage from '../_themes/package' export const themes = Object.keys(themesPackage.devDependencies) .map(name => ({ diff --git a/jakelib/utils.js b/jakelib/utils.js index 5ba6f6c..cf9758a 100644 --- a/jakelib/utils.js +++ b/jakelib/utils.js @@ -1,7 +1,7 @@ -const chalk = require('chalk') -const fs = require('mz/fs') -const path = require('path') -const jsYaml = require('js-yaml') +import chalk from 'chalk' +import fs from 'mz/fs' +import path from 'path' +import jsYaml from 'js-yaml' const chevron = '»' From 2cfc3c4239c2f9e5d2d789daf67b3201392b553a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Galliat?= Date: Sun, 6 Dec 2015 18:58:41 -0500 Subject: [PATCH 9/9] Remove unused dep --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index c93b7d0..8d86a17 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "chalk": "^1.1.1", "combined-stream": "^1.0.5", "es6-denodeify": "^0.1.1", - "event-stream": "^3.2.1", "fs-extra-promise": "^0.3.1", "jake": "^8.0.10", "js-yaml": "^3.2.5",