Skip to content

Commit e0124bb

Browse files
authored
chore: publish examples assets for plunker with docs content (#3987)
1 parent c38c9c3 commit e0124bb

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

scripts/release/publish-docs-content.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ mkdir $repoPath/overview
3232
mkdir $repoPath/guides
3333
mkdir $repoPath/api
3434
mkdir $repoPath/examples
35+
mkdir $repoPath/plunker
3536

36-
# Move api files over to $repoPath/api
37+
# Copy api files over to $repoPath/api
3738
cp -r $docsPath/api/* $repoPath/api
3839

3940
# Flatten the markdown docs structure and move it into $repoPath/overview
@@ -52,17 +53,20 @@ do
5253
fi
5354
done
5455

55-
# Move guide files over to $repoPath/guides
56+
# Copy guide files over to $repoPath/guides
5657
for filename in $overviewFiles*
5758
do
5859
if [ -f $filename ]; then
5960
cp -r $filename $repoPath/guides
6061
fi
6162
done
6263

63-
# Move highlighted examples into $repoPath
64+
# Copy highlighted examples into $repoPath
6465
cp -r $examplesSource/* $repoPath/examples
6566

67+
# Copy example plunker assets
68+
rsync -a $docsPath/plunker $repoPath/plunker
69+
6670
# Copies assets over to the docs-content repository.
6771
cp LICENSE $repoPath/
6872

tools/gulp/tasks/docs.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {task, src, dest} from 'gulp';
22
import {Dgeni} from 'dgeni';
33
import * as path from 'path';
4-
import {HTML_MINIFIER_OPTIONS} from '../constants';
4+
import {DIST_ROOT, HTML_MINIFIER_OPTIONS, SOURCE_ROOT} from '../constants';
55

66
// There are no type definitions available for these imports.
77
const markdown = require('gulp-markdown');
@@ -13,6 +13,8 @@ const htmlmin = require('gulp-htmlmin');
1313
const hljs = require('highlight.js');
1414
const dom = require('gulp-dom');
1515

16+
const DIST_DOCS = path.join(DIST_ROOT, 'docs');
17+
1618
// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
1719
// example code should be inserted. We replace these comments with divs that have a
1820
// `material-docs-example` attribute which can be used to locate the divs and initialize the example
@@ -46,8 +48,17 @@ const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
4648
'code',
4749
];
4850

49-
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs', 'minify-html-docs']);
5051

52+
/** Generate all docs content. */
53+
task('docs', [
54+
'markdown-docs',
55+
'highlight-examples',
56+
'api-docs',
57+
'minified-api-docs',
58+
'plunker-example-assets',
59+
]);
60+
61+
/** Generates html files from the markdown overviews and guides. */
5162
task('markdown-docs', () => {
5263
return src(['src/lib/**/*.md', 'guides/*.md'])
5364
.pipe(markdown({
@@ -67,7 +78,11 @@ task('markdown-docs', () => {
6778
.pipe(dest('dist/docs/markdown'));
6879
});
6980

70-
task('highlight-docs', () => {
81+
/**
82+
* Creates syntax-highlighted html files from the examples to be used for the source view of
83+
* live examples on the docs site.
84+
*/
85+
task('highlight-examples', () => {
7186
// rename files to fit format: [filename]-[filetype].html
7287
const renameFile = (path: any) => {
7388
const extension = path.extname.slice(1);
@@ -81,18 +96,26 @@ task('highlight-docs', () => {
8196
.pipe(dest('dist/docs/examples'));
8297
});
8398

99+
/** Generates API docs from the source JsDoc using dgeni. */
84100
task('api-docs', () => {
85101
const docsPackage = require(path.resolve(__dirname, '../../dgeni'));
86102
const docs = new Dgeni([docsPackage]);
87103
return docs.generate();
88104
});
89105

90-
task('minify-html-docs', ['api-docs'], () => {
106+
/** Generates minified html api docs. */
107+
task('minified-api-docs', ['api-docs'], () => {
91108
return src('dist/docs/api/*.html')
92109
.pipe(htmlmin(HTML_MINIFIER_OPTIONS))
93110
.pipe(dest('dist/docs/api/'));
94111
});
95112

113+
/** Copies example sources to be used as plunker assets for the docs site. */
114+
task('plunker-example-assets', () => {
115+
src(path.join(SOURCE_ROOT, 'examples', '**/*'))
116+
.pipe(dest(path.join(DIST_DOCS, 'plunker', 'examples')));
117+
});
118+
96119
/** Updates the markdown file's content to work inside of the docs app. */
97120
function transformMarkdownFiles(buffer: Buffer, file: any): string {
98121
let content = buffer.toString('utf-8');

0 commit comments

Comments
 (0)