diff --git a/package.json b/package.json index 97fd10eff17..deaa3e9ea9f 100644 --- a/package.json +++ b/package.json @@ -59,10 +59,12 @@ "gulp-autoprefixer": "^3.1.1", "gulp-clean": "^0.3.2", "gulp-cli": "^1.2.2", + "gulp-markdown": "^1.2.0", "gulp-sass": "^2.3.2", "gulp-server-livereload": "^1.8.2", "gulp-shell": "^0.5.2", "gulp-sourcemaps": "^1.6.0", + "gulp-transform": "^1.1.0", "gulp-typescript": "^2.13.6", "jasmine-core": "^2.4.1", "karma": "^1.1.1", diff --git a/src/lib/button/README.md b/src/lib/button/README.md index 3dc9923f618..306afe2bd08 100644 --- a/src/lib/button/README.md +++ b/src/lib/button/README.md @@ -40,6 +40,8 @@ between the tags, as you would with a normal button. Example: + + ```html @@ -67,6 +69,8 @@ In flat buttons, the palette chosen will affect the text color, while in other b Example: + + ```html diff --git a/tools/gulp/gulpfile.ts b/tools/gulp/gulpfile.ts index 636fa57715b..32892a6d78f 100644 --- a/tools/gulp/gulpfile.ts +++ b/tools/gulp/gulpfile.ts @@ -3,6 +3,7 @@ import './tasks/clean'; import './tasks/components'; import './tasks/default'; import './tasks/development'; +import './tasks/docs'; import './tasks/e2e'; import './tasks/lint'; import './tasks/release'; diff --git a/tools/gulp/tasks/docs.ts b/tools/gulp/tasks/docs.ts new file mode 100644 index 00000000000..bdef54cb706 --- /dev/null +++ b/tools/gulp/tasks/docs.ts @@ -0,0 +1,20 @@ +import gulp = require('gulp'); +const markdown = require('gulp-markdown'); +const transform = require('gulp-transform'); + + +// Our docs contain comments of the form `` which serve as placeholders where +// example code should be inserted. We replace these comments with divs that have a +// `material-docs-example` attribute which can be used to locate the divs and initialize the example +// viewer. +const EXAMPLE_PATTERN = //g; + + +gulp.task('docs', () => { + return gulp.src(['src/lib/**/*.md']) + .pipe(markdown()) + .pipe(transform((content: string) => + content.toString().replace(EXAMPLE_PATTERN, (match: string, name: string) => + `
`))) + .pipe(gulp.dest('dist/docs')); +});