Skip to content

Commit c54617c

Browse files
mmalerbakara
authored andcommitted
chore: add gulp task to convert markdown to html (#1821)
1 parent 41ad382 commit c54617c

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@
5959
"gulp-autoprefixer": "^3.1.1",
6060
"gulp-clean": "^0.3.2",
6161
"gulp-cli": "^1.2.2",
62+
"gulp-markdown": "^1.2.0",
6263
"gulp-sass": "^2.3.2",
6364
"gulp-server-livereload": "^1.8.2",
6465
"gulp-shell": "^0.5.2",
6566
"gulp-sourcemaps": "^1.6.0",
67+
"gulp-transform": "^1.1.0",
6668
"gulp-typescript": "^2.13.6",
6769
"jasmine-core": "^2.4.1",
6870
"karma": "^1.1.1",

src/lib/button/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ between the tags, as you would with a normal button.
4040

4141
Example:
4242

43+
<!-- example(my example) -->
44+
4345
```html
4446
<button md-button>FLAT</button>
4547
<button md-raised-button>RAISED</button>
@@ -67,6 +69,8 @@ In flat buttons, the palette chosen will affect the text color, while in other b
6769

6870
Example:
6971

72+
<!-- example(my other example) -->
73+
7074
```html
7175
<button md-raised-button color="primary">PRIMARY</button>
7276
<button md-raised-button color="accent">ACCENT</button>

tools/gulp/gulpfile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import './tasks/clean';
33
import './tasks/components';
44
import './tasks/default';
55
import './tasks/development';
6+
import './tasks/docs';
67
import './tasks/e2e';
78
import './tasks/lint';
89
import './tasks/release';

tools/gulp/tasks/docs.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import gulp = require('gulp');
2+
const markdown = require('gulp-markdown');
3+
const transform = require('gulp-transform');
4+
5+
6+
// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
7+
// example code should be inserted. We replace these comments with divs that have a
8+
// `material-docs-example` attribute which can be used to locate the divs and initialize the example
9+
// viewer.
10+
const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
11+
12+
13+
gulp.task('docs', () => {
14+
return gulp.src(['src/lib/**/*.md'])
15+
.pipe(markdown())
16+
.pipe(transform((content: string) =>
17+
content.toString().replace(EXAMPLE_PATTERN, (match: string, name: string) =>
18+
`<div material-docs-example="${name}"></div>`)))
19+
.pipe(gulp.dest('dist/docs'));
20+
});

0 commit comments

Comments
 (0)