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

Commit 5e79a1a

Browse files
chalinkwalrath
authored andcommitted
chore: fix broken links and transform API links for dart docs
- Dart non-api doc pages w/ links to API entries will now have those links translated from a TS API reference URL to a Dart API reference URL. - Created and ran a link checker to verify that all such links to API entries refer to Dart. - Fixed links to pages that have moved: - JS & Dart: `i18n` is under now `cookbook` not `guide` - Dart: testing page is now directly under guide. Contributes to #1895 Fixes #2273
1 parent a46cba0 commit 5e79a1a

File tree

5 files changed

+64
-4
lines changed

5 files changed

+64
-4
lines changed

public/docs/_layout.jade

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
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+
4+
- function tsApiHrefToDart(match, hrefApi, dontcare1, urlRest) {
5+
- // Simple argument values:
6+
- // hrefApi: href="../api/
7+
- // urlRest: core/index/ViewChild-var.html"
8+
- // console.log(`got match on ${match}, 1: ${hrefApi}, 3: ${urlRest}`);
9+
- var matches = urlRest.match(/^(\w*)\/index\/(\w*)-(\w*)(\.html")$/);
10+
- // console.log(`urlRest matches ${matches}`);
11+
- if (!matches) return match; // leave unchanged
12+
- var i = 1; // matches[0] corresponds to the fully matched result
13+
- var libName = matches[i++];
14+
- var apiPageEntryName = matches[i++];
15+
- var apiEntryKind = matches[i++];
16+
- var suffix = matches[i++];
17+
- return hrefApi + 'angular2.' + libName + '/' + apiPageEntryName + '-class' + suffix;
18+
- }
19+
320
if jade2ng
421
.side-nav--offset
522
!= partial("../_includes/_hero")
@@ -35,8 +52,10 @@ else
3552
article(class="l-content-small grid-fluid docs-content")
3653
!= yield
3754
else
55+
- var isDart = current.path[1] === 'dart';
56+
- var regex = /(href=\"(\.?\.\/)*api\/)(.*")/g;
3857
article(class="l-content-small grid-fluid docs-content")
39-
!= yield
58+
!= !isDart ? yield : yield.replace(regex, tsApiHrefToDart)
4059
if (current.path[3] == 'guide' || current.path[3] == 'tutorial') && current.path[4]
4160
!= partial("../_includes/_next-item")
4261

public/docs/dart/latest/guide/i18n.jade

-1
This file was deleted.

public/docs/js/latest/guide/i18n.jade

-1
This file was deleted.

public/docs/ts/_cache/guide/dependency-injection.jade

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ block ctor-syntax
362362

363363
.l-sub-section
364364
:marked
365-
Learn more in [Testing](../testing/index.html).
365+
Learn more in [Testing](./testing.html).
366366

367367
:marked
368368
### When the service needs a service

scripts/check-dart-api-links.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This script currently requires that the site have been generated
4+
# under $SITE and that it is being served via http://localhost:8080.
5+
6+
set -e -o pipefail
7+
8+
[[ -z "$NGIO_ENV_DEFS" ]] && . ./scripts/env-set.sh > /dev/null
9+
if [[ "x$1" == "x-v" ]]; then VERBOSE=1; shift; fi
10+
11+
SITE=./www
12+
13+
CHECK_FOR=dart-bad-api-links
14+
15+
LOGFILE_PREFIX=$CHECK_FOR-log
16+
LOGFILE_FULL=$TMP/$LOGFILE_PREFIX-full.txt
17+
LOGFILE=$TMP/$LOGFILE_PREFIX.txt
18+
19+
if [[ ! -d $SITE ]]; then
20+
echo "Missing site folder $SITE"
21+
exit 1;
22+
fi
23+
24+
cd $SITE
25+
echo "" > $LOGFILE_FULL
26+
27+
# We don't check cookbook pages since they are all empty.
28+
# We don't check api pages because there are currently too many broken links.
29+
for f in docs/dart/latest/{,guide/,tutorial/}*.html; do
30+
echo "Checking links in $f";
31+
$(npm bin)/blc -e --get http://localhost:8080/$f >> $LOGFILE_FULL
32+
done
33+
echo ""
34+
35+
echo "Listing broken links, if any:"
36+
grep -i broken $LOGFILE_FULL | grep -v Finished || true
37+
echo ""
38+
39+
echo "Listing links to TS api pages from Dart docs pages, if any:"
40+
grep /api/ $LOGFILE_FULL | grep -v '/api/$' | grep -v /angular2. || true
41+
echo ""
42+
43+
echo "For details consult the full log $LOGFILE_FULL"

0 commit comments

Comments
 (0)