Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit db6625e

Browse files
chalinkwalrath
authored andcommitted
Fix dartdoc styles and prep layout for ng2 pages (#2530)
- Use custom bootstrap grid system styles - Cache a copy of the dartdoc static-assets styles.css w/ footer styles disabled. - Alternate page layout controlled by jade2ng harp global
1 parent 661c971 commit db6625e

File tree

10 files changed

+1901
-84
lines changed

10 files changed

+1901
-84
lines changed

gulpfile.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ var regularPlunker = require(path.resolve(TOOLS_PATH, 'plunker-builder/regularPl
5050
var embeddedPlunker = require(path.resolve(TOOLS_PATH, 'plunker-builder/embeddedPlunker'));
5151
var fsUtils = require(path.resolve(TOOLS_PATH, 'fs-utils/fsUtils'));
5252

53+
const WWW = argv.page ? 'www-pages' : 'www'
54+
5355
const isSilent = !!argv.silent;
5456
if (isSilent) gutil.log = gutil.noop;
5557
const _dgeniLogLevel = argv.dgeniLog || (isSilent ? 'error' : 'info');
@@ -747,7 +749,7 @@ gulp.task('harp-serve', () => {
747749

748750
gulp.task('serve-www', () => {
749751
// Serve generated site.
750-
return execPromise('npm run live-server ./www');
752+
return execPromise(`npm run live-server ${WWW}`);
751753
});
752754

753755
gulp.task('build-compile', ['build-docs'], function() {
@@ -758,7 +760,7 @@ gulp.task('check-deploy', ['build-docs'], function() {
758760
return harpCompile().then(function() {
759761
gutil.log('compile ok');
760762
gutil.log('running live server ...');
761-
execPromise('npm run live-server ./www');
763+
execPromise(`npm run live-server ${WWW}`);
762764
return askDeploy();
763765
}).then(function(shouldDeploy) {
764766
if (shouldDeploy) {
@@ -902,11 +904,13 @@ function harpCompile() {
902904
env({ vars: { NODE_ENV: "production" } });
903905
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
904906

905-
if(skipLangs && fs.existsSync('www') && backupApiHtmlFilesExist('www')) {
907+
if(argv.page) harpJsonSetJade2NgTo(true);
908+
909+
if(skipLangs && fs.existsSync(WWW) && backupApiHtmlFilesExist(WWW)) {
906910
gutil.log(`Harp site recompile: skipping recompilation of API docs for [${skipLangs}]`);
907-
gutil.log(`API docs will be copied from existing www folder.`)
908-
del.sync('www-backup'); // remove existing backup if it exists
909-
renameIfExistsSync('www', 'www-backup');
911+
gutil.log(`API docs will be copied from existing ${WWW} folder.`)
912+
del.sync(`${WWW}-backup`); // remove existing backup if it exists
913+
renameIfExistsSync(WWW, `${WWW}-backup`);
910914
} else {
911915
gutil.log(`Harp full site compile, including API docs for all languages.`);
912916
if (skipLangs)
@@ -918,11 +922,12 @@ function harpCompile() {
918922
gutil.log('running harp compile...');
919923
showHideExampleNodeModules('hide');
920924
showHideApiDir('hide');
921-
var spawnInfo = spawnExt('npm',['run','harp', '--', 'compile', '.', './www' ]);
925+
var spawnInfo = spawnExt('npm',['run','harp', '--', 'compile', '.', WWW ]);
922926
spawnInfo.promise.then(function(x) {
923927
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
924928
showHideExampleNodeModules('show');
925929
showHideApiDir('show');
930+
harpJsonSetJade2NgTo(false);
926931
if (x !== 0) {
927932
deferred.reject(x)
928933
} else {
@@ -933,6 +938,7 @@ function harpCompile() {
933938
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
934939
showHideExampleNodeModules('show');
935940
showHideApiDir('show');
941+
harpJsonSetJade2NgTo(false);
936942
deferred.reject(e);
937943
});
938944
return deferred.promise;
@@ -1050,21 +1056,21 @@ function _showHideApiDir(lang, showOrHide) {
10501056
renameIfExistsSync(...args);
10511057
}
10521058

1053-
// For each lang in skipLangs, copy the API dir from www-backup to www.
1059+
// For each lang in skipLangs, copy the API dir from ${WWW}-backup to WWW.
10541060
function restoreApiHtml() {
10551061
const vers = 'latest';
10561062
skipLangs.forEach(lang => {
10571063
const relApiDir = path.join('docs', lang, vers, 'api');
1058-
const wwwApiSubdir = path.join('www', relApiDir);
1059-
const backupApiSubdir = path.join('www-backup', relApiDir);
1064+
const apiSubdir = path.join(WWW, relApiDir);
1065+
const backupApiSubdir = path.join(`${WWW}-backup`, relApiDir);
10601066
if (fs.existsSync(backupApiSubdir) || argv.forceSkipApi !== true) {
1061-
gutil.log(`cp ${backupApiSubdir} ${wwwApiSubdir}`)
1062-
fs.copySync(backupApiSubdir, wwwApiSubdir);
1067+
gutil.log(`cp ${backupApiSubdir} ${apiSubdir}`)
1068+
fs.copySync(backupApiSubdir, apiSubdir);
10631069
}
10641070
});
10651071
}
10661072

1067-
// For each lang in skipLangs, ensure API dir exists in www-backup
1073+
// For each lang in skipLangs, ensure API dir exists in folderName
10681074
function backupApiHtmlFilesExist(folderName) {
10691075
const vers = 'latest';
10701076
var result = 1;
@@ -1079,6 +1085,14 @@ function backupApiHtmlFilesExist(folderName) {
10791085
return result;
10801086
}
10811087

1088+
function harpJsonSetJade2NgTo(v) {
1089+
const execSync = require('child_process').execSync;
1090+
const harpJsonPath = path.join(ANGULAR_IO_PROJECT_PATH, 'harp.json');
1091+
execSync(`perl -pi -e 's/("jade2ng": *)\\w+/$1${v}/' ${harpJsonPath}`);
1092+
const harpJson = require(harpJsonPath);
1093+
gutil.log(`jade2ng: ${harpJson.globals.jade2ng}`);
1094+
}
1095+
10821096
// Copies fileNames into destPaths, setting the mode of the
10831097
// files at the destination as optional_destFileMode if given.
10841098
// returns a promise

harp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"siteURL": "http://angular.io",
77
"jsLatest": "2.0.0-beta.02",
88
"dartLatest": "2.0.0-beta.02",
9+
"jade2ng": false,
910

1011
"bios": {
1112
"misko": {

public/_includes/_hero.jade

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// template: public/_includes/_hero
1+
//- template: public/_includes/_hero
22
//- Refer to jade.template.html and addJadeDataDocsProcessor to figure out where the context of this jade file originates
33
- var textFormat = '';
44
- var headerTitle = title + (typeof varType !== 'undefined' ? (': ' + varType) : '');
@@ -24,16 +24,14 @@ header.hero.background-sky
2424
span(class="badge is-deprecated").
2525
Security Risk
2626

27-
//CLEAR FLOAT ELEMENTS
27+
//- CLEAR FLOAT ELEMENTS
2828
.clear
2929

3030
if subtitle
3131
h2.hero-subtitle #{subtitle}
32-
3332
else if docType
3433
h2.hero-subtitle #{renamer(capitalize(docType))}
3534

36-
37-
if current.path[3] == 'api' && current.path[1] == 'dart'
38-
block breadcrumbs
35+
if current.path[3] == 'api' && current.path[1] == 'dart'
36+
block breadcrumbs
3937

public/_includes/_util-fns.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ if !jade2ng
300300
- } else {
301301
- // ``` gets translated to <pre><code>.....</code></pre> and we need
302302
- // to remove this from the fragment prefix is 11 long and suffix is 13 long
303-
- frag = jade2ng ? frag : frag.substring(11, frag.length-13);
303+
- frag = frag.substring(11, frag.length-13);
304304
- // Uncomment next line for debugging.
305305
- // frag = "FileName: " + fullFileName + " Current path: " + current.path + " PathToDocs: " + getPathToDocs() + "\n" + frag;
306306
- return frag;

public/docs/_layout-dart-api.jade

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
11
//- WARNING: _layout.jade and _layout-dart-api.jade should match in terms of content
22
//- except that one uses Harp partial/yield and the other uses Jade extends/include.
3-
doctype
4-
html(lang="en" ng-app="angularIOApp" itemscope itemtype="http://schema.org/Framework")
5-
// template: public/docs/_layout-dart-api
6-
head
7-
include ../_includes/_head-include
8-
block head-extra
9-
10-
block var-def
11-
body(class="l-offset-nav l-offset-side-nav" ng-controller="AppCtrl as appCtrl")
12-
include ../_includes/_main-nav
13-
if current.path[2]
14-
include _includes/_side-nav
3+
if jade2ng
4+
.side-nav--offset
5+
link(rel="stylesheet" href="/assets/css/vendor/dartdoc/bootstrap.min.css")
6+
link(rel="stylesheet" href="/assets/css/vendor/dartdoc/styles.css")
157
include ../_includes/_hero
168
include ../_includes/_banner
17-
18-
if current.path[3] == 'api'
19-
if current.path[4] == 'index'
20-
block main-content
21-
else
22-
article(class="l-content-small grid-fluid docs-content")
23-
block main-content
24-
else if current.path.indexOf('cheatsheet') > 0
9+
.l-content-small.grid-fluid.docs-content
2510
block main-content
26-
else
27-
if current.path[3] == 'index' || current.path[3] == 'styleguide'
28-
article(class="l-content-small grid-fluid docs-content")
11+
else
12+
doctype
13+
html(lang="en" ng-app="angularIOApp" itemscope itemtype="http://schema.org/Framework")
14+
// template: public/docs/_layout-dart-api
15+
head
16+
include ../_includes/_head-include
17+
link(rel="stylesheet" href="/resources/css/vendor/dartdoc/bootstrap.min.css")
18+
link(rel="stylesheet" href="/resources/css/vendor/dartdoc/styles.css")
19+
block head-extra
20+
21+
block var-def
22+
body(class="l-offset-nav l-offset-side-nav" ng-controller="AppCtrl as appCtrl")
23+
include ../_includes/_main-nav
24+
if current.path[2]
25+
include _includes/_side-nav
26+
include ../_includes/_hero
27+
include ../_includes/_banner
28+
29+
if current.path[3] == 'api'
30+
if current.path[4] == 'index'
2931
block main-content
32+
else
33+
article(class="l-content-small grid-fluid docs-content")
34+
block main-content
35+
else if current.path.indexOf('cheatsheet') > 0
36+
block main-content
3037
else
31-
article(class="l-content-small grid-fluid docs-content")
32-
div(class="c10")
33-
.showcase
34-
.showcase-content
35-
block main-content
36-
if (current.path[3] == 'guide' || current.path[3] == 'tutorial') && current.path[4]
37-
include ../_includes/_next-item
38+
if current.path[3] == 'index' || current.path[3] == 'styleguide'
39+
article(class="l-content-small grid-fluid docs-content")
40+
block main-content
41+
else
42+
article(class="l-content-small grid-fluid docs-content")
43+
div(class="c10")
44+
.showcase
45+
.showcase-content
46+
block main-content
47+
if (current.path[3] == 'guide' || current.path[3] == 'tutorial') && current.path[4]
48+
include ../_includes/_next-item
3849

39-
include ../_includes/_footer
40-
include ../_includes/_scripts-include
50+
include ../_includes/_footer
51+
include ../_includes/_scripts-include

public/docs/_layout.jade

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,44 @@
11
//- WARNING: _layout.jade and _layout-dart-api.jade should match in terms of content
22
//- except that one uses Harp partial/yield and the other uses Jade extends/include.
3-
doctype
4-
html(lang="en" ng-app="angularIOApp" itemscope itemtype="http://schema.org/Framework")
5-
// template: public/docs/_layout
6-
head
7-
!= partial("../_includes/_head-include")
8-
block head-extra
9-
10-
//-
11-
body(class="l-offset-nav l-offset-side-nav" ng-controller="AppCtrl as appCtrl")
12-
!= partial("../_includes/_main-nav")
13-
if current.path[2]
14-
!= partial("_includes/_side-nav")
3+
if jade2ng
4+
.side-nav--offset
155
!= partial("../_includes/_hero")
166
!= partial("../_includes/_banner")
7+
.l-content-small.grid-fluid.docs-content
8+
!= yield
9+
else
10+
doctype
11+
html(lang="en" ng-app="angularIOApp" itemscope itemtype="http://schema.org/Framework")
12+
// template: public/docs/_layout
13+
head
14+
!= partial("../_includes/_head-include")
15+
block head-extra
1716

18-
if current.path[3] == 'api'
19-
if current.path[4] == 'index'
20-
!= yield
21-
else
22-
article(class="l-content-small grid-fluid docs-content")
23-
!= yield
24-
else if current.path.indexOf('cheatsheet') > 0
25-
!= yield
26-
else
27-
if current.path[3] == 'index' || current.path[3] == 'styleguide'
28-
article(class="l-content-small grid-fluid docs-content")
17+
//-
18+
body(class="l-offset-nav l-offset-side-nav" ng-controller="AppCtrl as appCtrl")
19+
!= partial("../_includes/_main-nav")
20+
if current.path[2]
21+
!= partial("_includes/_side-nav")
22+
!= partial("../_includes/_hero")
23+
!= partial("../_includes/_banner")
24+
25+
if current.path[3] == 'api'
26+
if current.path[4] == 'index'
2927
!= yield
28+
else
29+
article(class="l-content-small grid-fluid docs-content")
30+
!= yield
31+
else if current.path.indexOf('cheatsheet') > 0
32+
!= yield
3033
else
31-
article(class="l-content-small grid-fluid docs-content")
32-
!= yield
33-
if (current.path[3] == 'guide' || current.path[3] == 'tutorial') && current.path[4]
34-
!= partial("../_includes/_next-item")
34+
if current.path[3] == 'index' || current.path[3] == 'styleguide'
35+
article(class="l-content-small grid-fluid docs-content")
36+
!= yield
37+
else
38+
article(class="l-content-small grid-fluid docs-content")
39+
!= yield
40+
if (current.path[3] == 'guide' || current.path[3] == 'tutorial') && current.path[4]
41+
!= partial("../_includes/_next-item")
3542

36-
!= partial("../_includes/_footer")
37-
!= partial("../_includes/_scripts-include")
43+
!= partial("../_includes/_footer")
44+
!= partial("../_includes/_scripts-include")

0 commit comments

Comments
 (0)