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

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

Merged
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
3 changes: 2 additions & 1 deletion scripts/ci/after-success.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 77 additions & 0 deletions scripts/release/publish-docs-content.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tools/dgeni/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions tools/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]);
Expand Down