diff --git a/scripts/ci/after-success.sh b/scripts/ci/after-success.sh index 37524389d1e..599f097f2ce 100755 --- a/scripts/ci/after-success.sh +++ b/scripts/ci/after-success.sh @@ -10,4 +10,5 @@ cd $(dirname $0)/../.. if [ "$TRAVIS_PULL_REQUEST" = "false" ] && $(npm bin)/travis-after-modes; then echo "All travis modes passed. Publishing the build artifacts..." ./scripts/release/publish-build-artifacts.sh -fi \ No newline at end of file + ./scripts/release/publish-docs-content.sh +fi diff --git a/scripts/release/publish-docs-content.sh b/scripts/release/publish-docs-content.sh new file mode 100755 index 00000000000..e214b49e41e --- /dev/null +++ b/scripts/release/publish-docs-content.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# Publish material2 docs assets to the material2-docs-content repo +# material.angular.io will pull from this assets repo to get the latest docs + +cd "$(dirname $0)/../../" + +docsPath="/dist/docs" +repoPath="/tmp/material2-docs-content" +repoUrl="https://github.com/DevVersion/material2-docs-content" + +# If the docs directory is not present, generate docs +if [ ! -d $docsPath ]; then + $(npm bin)/gulp docs +fi + +# Get git meta info for commit +commitSha="$(git rev-parse --short HEAD)" +commitAuthorName="$(git --no-pager show -s --format='%an' HEAD)" +commitAuthorEmail="$(git --no-pager show -s --format='%ae' HEAD)" +commitMessage="$(git log --oneline -n 1)" + +# create directory and clone test repo +rm -rf "/tmp/" +mkdir "/tmp/" $repoPath +git clone $repoUrl $repoPath + +# Clean out repo directory and copy contents of dist/docs into it +rm -rf $repoPath/* +mkdir $repoPath/overview +mkdir $repoPath/guides +mkdir $repoPath/api +# mkdir $repoPath/examples + +# Move api files over to $repoPath/api +cp -r $docsPath/api/* $repoPath/api + +# Move guide files over to $repoPath/guides +for filename in $overviewFiles* +do + if [ -f $filename ]; then + cp -r $filename $repoPath/guides + fi +done + +# Flatten the markdown docs structure and move it into $repoPath/overview +overviewFiles=$docsPath/markdown/ +targetFile="OVERVIEW.html" +for filename in $overviewFiles* +do + if [ -d $filename ]; then + for _ in $filename/* + do + if [ -f $filename/$targetFile ]; then + name=${filename#$overviewFiles} + cp -r $filename/$targetFile $repoPath/overview/ + mv $repoPath/overview/$targetFile $repoPath/overview/$name.html + fi + done + fi +done + +# src/examples should be added to the $repoPath after they have been moved into +# the material2 repo from material.angular.io + +# Push content to repo +cd $repoPath +git config user.name "$commitAuthorName" +git config user.email "$commitAuthorEmail" +git config credential.helper "store --file=.git/credentials" + +echo "https://${MATERIAL2_BUILDS_TOKEN}:@github.com" > .git/credentials + +git add -A +git commit -m "$commitMessage" +git tag "$commitSha" +git push origin master --tags diff --git a/tools/dgeni/index.js b/tools/dgeni/index.js index 652288c9699..b22c3fe29ac 100644 --- a/tools/dgeni/index.js +++ b/tools/dgeni/index.js @@ -12,7 +12,7 @@ const typescriptPackage = require('dgeni-packages/typescript'); // Project configuration. const projectRootDir = path.resolve(__dirname, '../..'); const sourceDir = path.resolve(projectRootDir, 'src/lib'); -const outputDir = path.resolve(projectRootDir, 'dist/docs'); +const outputDir = path.resolve(projectRootDir, 'dist/docs/api'); const templateDir = path.resolve(__dirname, './templates'); // Package definition for material2 api docs. This only *defines* the package- it does not yet diff --git a/tools/gulp/tasks/docs.ts b/tools/gulp/tasks/docs.ts index ace221fde27..d8d6e65db00 100644 --- a/tools/gulp/tasks/docs.ts +++ b/tools/gulp/tasks/docs.ts @@ -16,7 +16,9 @@ const EXAMPLE_PATTERN = //g; // documentation page. Using a RegExp to rewrite links in HTML files to work in the docs. const LINK_PATTERN = /(]*) href="([^"]*)"/g; -gulp.task('docs', () => { +gulp.task('docs', ['markdown-docs', 'api-docs']) + +gulp.task('markdown-docs', () => { return gulp.src(['src/lib/**/*.md', 'guides/*.md']) .pipe(markdown({ // Add syntax highlight using highlight.js @@ -31,10 +33,10 @@ gulp.task('docs', () => { } })) .pipe(transform(transformMarkdownFiles)) - .pipe(gulp.dest('dist/docs')); + .pipe(gulp.dest('dist/docs/markdown')); }); -task('api', () => { +task('api-docs', () => { const Dgeni = require('dgeni'); const docsPackage = require(path.resolve(__dirname, '../../dgeni')); const dgeni = new Dgeni([docsPackage]);