feat(scripts): push generated docs to material assets repo (#2720)

This commit is contained in:
Raven Avalon
2017-02-06 14:56:54 -05:00
committed by tinayuangao
parent 2f10a95fc7
commit ba12f440c1
4 changed files with 85 additions and 5 deletions
+2 -1
View File
@@ -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
./scripts/release/publish-docs-content.sh
fi
+77
View File
@@ -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
+1 -1
View File
@@ -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
+5 -3
View File
@@ -16,7 +16,9 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
const LINK_PATTERN = /(<a[^>]*) 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]);