Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: publish examples assets for plunker with docs content #3987

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions scripts/release/publish-docs-content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ mkdir $repoPath/overview
mkdir $repoPath/guides
mkdir $repoPath/api
mkdir $repoPath/examples
mkdir $repoPath/plunker

# Move api files over to $repoPath/api
# Copy api files over to $repoPath/api
cp -r $docsPath/api/* $repoPath/api

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

# Move guide files over to $repoPath/guides
# Copy guide files over to $repoPath/guides
for filename in $overviewFiles*
do
if [ -f $filename ]; then
cp -r $filename $repoPath/guides
fi
done

# Move highlighted examples into $repoPath
# Copy highlighted examples into $repoPath
cp -r $examplesSource/* $repoPath/examples

# Copy example plunker assets
rsync -a $docsPath/plunker $repoPath/plunker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure rsync is supported in the Git Bash. But as we run this on the CI it's fine. Just think you can do the same with cp.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we'll ever need this running on a Window machine since it's not part of the dev workflow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. Just for consistency. Feel free to merge!


# Copies assets over to the docs-content repository.
cp LICENSE $repoPath/

Expand Down
31 changes: 27 additions & 4 deletions tools/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {task, src, dest} from 'gulp';
import {Dgeni} from 'dgeni';
import * as path from 'path';
import {HTML_MINIFIER_OPTIONS} from '../constants';
import {DIST_ROOT, HTML_MINIFIER_OPTIONS, SOURCE_ROOT} from '../constants';

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

const DIST_DOCS = path.join(DIST_ROOT, 'docs');

// Our docs contain comments of the form `<!-- example(...) -->` 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
Expand Down Expand Up @@ -46,8 +48,17 @@ const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
'code',
];

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

/** Generate all docs content. */
task('docs', [
'markdown-docs',
'highlight-examples',
'api-docs',
'minified-api-docs',
'plunker-example-assets',
]);

/** Generates html files from the markdown overviews and guides. */
task('markdown-docs', () => {
return src(['src/lib/**/*.md', 'guides/*.md'])
.pipe(markdown({
Expand All @@ -67,7 +78,11 @@ task('markdown-docs', () => {
.pipe(dest('dist/docs/markdown'));
});

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

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

task('minify-html-docs', ['api-docs'], () => {
/** Generates minified html api docs. */
task('minified-api-docs', ['api-docs'], () => {
return src('dist/docs/api/*.html')
.pipe(htmlmin(HTML_MINIFIER_OPTIONS))
.pipe(dest('dist/docs/api/'));
});

/** Copies example sources to be used as plunker assets for the docs site. */
task('plunker-example-assets', () => {
src(path.join(SOURCE_ROOT, 'examples', '**/*'))
.pipe(dest(path.join(DIST_DOCS, 'plunker', 'examples')));
});

/** Updates the markdown file's content to work inside of the docs app. */
function transformMarkdownFiles(buffer: Buffer, file: any): string {
let content = buffer.toString('utf-8');
Expand Down