Skip to content

Commit ed277d0

Browse files
committed
feat(scripts): push generated docs to material assets repo
1 parent 8d900e0 commit ed277d0

File tree

4 files changed

+85
-5
lines changed

4 files changed

+85
-5
lines changed

scripts/ci/after-success.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ cd $(dirname $0)/../..
1010
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && $(npm bin)/travis-after-modes; then
1111
echo "All travis modes passed. Publishing the build artifacts..."
1212
./scripts/release/publish-build-artifacts.sh
13-
fi
13+
./scripts/release/publish-docs-content.sh
14+
fi
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
# Publish material2 docs assets to the material2-docs-content repo
4+
# material.angular.io will pull from this assets repo to get the latest docs
5+
6+
cd "$(dirname $0)/../../"
7+
8+
docsPath="/dist/docs"
9+
repoPath="/tmp/material2-docs-content"
10+
repoUrl="https://github.com/DevVersion/material2-docs-content"
11+
12+
# If the docs directory is not present, generate docs
13+
if [ ! -d $docsPath ]; then
14+
$(npm bin)/gulp docs
15+
fi
16+
17+
# Get git meta info for commit
18+
commitSha="$(git rev-parse --short HEAD)"
19+
commitAuthorName="$(git --no-pager show -s --format='%an' HEAD)"
20+
commitAuthorEmail="$(git --no-pager show -s --format='%ae' HEAD)"
21+
commitMessage="$(git log --oneline -n 1)"
22+
23+
# create directory and clone test repo
24+
rm -rf "/tmp/"
25+
mkdir "/tmp/" $repoPath
26+
git clone $repoUrl $repoPath
27+
28+
# Clean out repo directory and copy contents of dist/docs into it
29+
rm -rf $repoPath/*
30+
mkdir $repoPath/overview
31+
mkdir $repoPath/guides
32+
mkdir $repoPath/api
33+
# mkdir $repoPath/examples
34+
35+
# Move api files over to $repoPath/api
36+
cp -r $docsPath/api/* $repoPath/api
37+
38+
# Move guide files over to $repoPath/guides
39+
for filename in $overviewFiles*
40+
do
41+
if [ -f $filename ]; then
42+
cp -r $filename $repoPath/guides
43+
fi
44+
done
45+
46+
# Flatten the markdown docs structure and move it into $repoPath/overview
47+
overviewFiles=$docsPath/markdown/
48+
targetFile="OVERVIEW.html"
49+
for filename in $overviewFiles*
50+
do
51+
if [ -d $filename ]; then
52+
for _ in $filename/*
53+
do
54+
if [ -f $filename/$targetFile ]; then
55+
name=${filename#$overviewFiles}
56+
cp -r $filename/$targetFile $repoPath/overview/
57+
mv $repoPath/overview/$targetFile $repoPath/overview/$name.html
58+
fi
59+
done
60+
fi
61+
done
62+
63+
# src/examples should be added to the $repoPath after they have been moved into
64+
# the material2 repo from material.angular.io
65+
66+
# Push content to repo
67+
cd $repoPath
68+
git config user.name "$commitAuthorName"
69+
git config user.email "$commitAuthorEmail"
70+
git config credential.helper "store --file=.git/credentials"
71+
72+
echo "https://${MATERIAL2_BUILDS_TOKEN}:@github.com" > .git/credentials
73+
74+
git add -A
75+
git commit -m "$commitMessage"
76+
git tag "$commitSha"
77+
git push origin master --tags

tools/dgeni/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const typescriptPackage = require('dgeni-packages/typescript');
1212
// Project configuration.
1313
const projectRootDir = path.resolve(__dirname, '../..');
1414
const sourceDir = path.resolve(projectRootDir, 'src/lib');
15-
const outputDir = path.resolve(projectRootDir, 'dist/docs');
15+
const outputDir = path.resolve(projectRootDir, 'dist/docs/api');
1616
const templateDir = path.resolve(__dirname, './templates');
1717

1818
// Package definition for material2 api docs. This only *defines* the package- it does not yet

tools/gulp/tasks/docs.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
1616
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
1717
const LINK_PATTERN = /(<a[^>]*) href="([^"]*)"/g;
1818

19-
gulp.task('docs', () => {
19+
gulp.task('docs', ['markdown-docs', 'api-docs'])
20+
21+
gulp.task('markdown-docs', () => {
2022
return gulp.src(['src/lib/**/*.md', 'guides/*.md'])
2123
.pipe(markdown({
2224
// Add syntax highlight using highlight.js
@@ -31,10 +33,10 @@ gulp.task('docs', () => {
3133
}
3234
}))
3335
.pipe(transform(transformMarkdownFiles))
34-
.pipe(gulp.dest('dist/docs'));
36+
.pipe(gulp.dest('dist/docs/markdown'));
3537
});
3638

37-
task('api', () => {
39+
task('api-docs', () => {
3840
const Dgeni = require('dgeni');
3941
const docsPackage = require(path.resolve(__dirname, '../../dgeni'));
4042
const dgeni = new Dgeni([docsPackage]);

0 commit comments

Comments
 (0)