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

[WIP] Pull LoopBack 4 doc updates from loopback-next #643

Merged
merged 1 commit into from
Mar 26, 2018
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
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: node_js
node_js:
- "8"

os:
- linux

deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
keep-history: true
on:
branch: gh-pages
script:
- /bin/bash ./update-readmes.sh
- /bin/bash ./update-community-readmes.sh
- /bin/bash ./update-v4-readmes.sh
- npm test
email: [email protected]
name: StrongLoop Bot

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ gem 'rouge'
gem 'github-pages'
gem 'jekyll'
gem 'jekyll-redirect-from'
gem 'jekyll-relative-links'
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ DEPENDENCIES
github-pages
jekyll
jekyll-redirect-from
jekyll-relative-links
rouge

BUNDLED WITH
1.15.1
1.16.0
43 changes: 0 additions & 43 deletions Jenkinsfile

This file was deleted.

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ summary: A brief tutorial on creating an Angular client app using the Loopback A
{% include readmes/loopback-example-angular.md %}
```

## Incorporating updates from loopback-next

We use a node script `update-lb4-docs` to copy over contents from loopback-next
repository using `@loopback/docs` package. The script is responsible for copying
over the markdown documentation and related tables, as well as the sidebar used
for LoopBack 4 content. The changes are then picked up as part of Travis CI's
builds along with README update scripts and deployed to GitHub Pages once
successful. The `upgrade-swagger-ui.js` script is also run as part of the
builds. If you'd like to make documentation changes for LoopBack 4, please do so
on its own [repository](https://github.com/strongloop/loopback-next/).

### Linting Readmes

There is an additional `npm script` that "lints" the readmes for markdown formatting problems. It is currently "experimental", see [this issue](https://github.com/strongloop/loopback.io/issues/49#issuecomment-253672668) for more info.
Expand Down
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ whitelist:

plugins:
- jekyll-redirect-from
- jekyll-relative-links

topnav_title: LoopBack
# this appears on the top navigation bar next to the home button
Expand All @@ -21,6 +22,8 @@ company_name: IBM / StrongLoop
github_editme_path: strongloop/loopback.io/blob/gh-pages/pages
# if you're using Github, provide the basepath to the branch you've created for reviews, following the sample here. if not, leave this value blank.

lb4_editme_path: strongloop/loopback-next/blob/master/docs/site

google_analytics: UA-102515604-1

disqus_shortname:
Expand All @@ -38,6 +41,7 @@ exclude:
- node_modules
- Jenkinsfile
- update-readmes.sh
- update-v4-readmes.sh
# these are the files and directories that jekyll will exclude from the build

feedback_email: [email protected]
Expand Down
14 changes: 0 additions & 14 deletions _includes/content/lb4-artifact-commands.html

This file was deleted.

26 changes: 0 additions & 26 deletions _includes/content/lb4-project-commands.html

This file was deleted.

8 changes: 6 additions & 2 deletions _layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
{% endif %}
<div class="post-header">
<h1 class="post-title-main">{{ page.title }}</h1>
{% if site.github_editme_path and page.layout != 'readme' %}
{% assign edit_url = page.url | remove: "/doc" | remove: ".html" | append: ".md" | prepend: site.github_editme_path %}
{% if site.github_editme_path and page.layout != 'readme' and page.sidebar != 'lb4_sidebar' %}
{% assign edit_url = page.url | remove: "/doc" | remove: ".html" | append: ".md" | prepend: site.github_editme_path %}
<a target="_blank" href="https://github.com/{{edit_url}}" class="btn btn-default githubEditButton" role="button"><i class="fa fa-github fa-lg"></i> Edit this page</a>
{% endif %}
{% if site.lb4_editme_path and page.layout != 'readme' and page.sidebar == 'lb4_sidebar' %}
{% assign edit_url = page.url | remove: "doc/en/lb4" | remove: ".html" | append: ".md" | prepend: site.lb4_editme_path %}
<a target="_blank" href="https://github.com/{{edit_url}}" class="btn btn-default githubEditButton" role="button"><i class="fa fa-github fa-lg"></i> Edit this page</a>
{% endif %}
</div>
Expand Down
Binary file removed images/lb4/10000000.png
Binary file not shown.
Binary file removed images/lb4/10000001.png
Binary file not shown.
Binary file removed images/lb4/10000002.png
Binary file not shown.
Binary file removed images/lb4/loopback-component.png
Binary file not shown.
Binary file removed images/lb4/loopback-composition.png
Binary file not shown.
Binary file removed images/lb4/loopback-ecosystem.png
Binary file not shown.
Binary file removed images/lb4/loopback-extension.png
Binary file not shown.
Binary file removed images/lb4/loopback-ioc.png
Binary file not shown.
Binary file removed images/lb4/loopback-overview.png
Binary file not shown.
Binary file removed images/lb4/loopback-stack.png
Binary file not shown.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"start": "bundle exec jekyll serve --incremental",
"fetch-readmes": "get-readmes --repos=./_data --out=./_includes/readmes",
"lint-readmes": "markdownlint _includes/readmes/",
"postinstall": "node ./api-explorer/upgrade-swagger-ui.js"
"postinstall": "npm run swagger-ui && npm run copydocs",
"swagger-ui": "node ./api-explorer/upgrade-swagger-ui.js",
"copydocs": "node update-lb4-docs.js"
},
"engines": {
"node": ">=8"
Expand All @@ -17,6 +19,7 @@
},
"devDependencies": {
"fs-extra": "^5.0.0",
"@loopback/docs": "latest",
"getreadmes": "github:strongloop/get-readmes",
"markdownlint-cli": "github:sequoia/markdownlint-cli",
"swagger-ui-dist": "^3.4.4"
Expand Down
61 changes: 61 additions & 0 deletions update-lb4-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const fs = require('fs-extra');
const path = require('path');

const srcDocs = path.resolve(__dirname,'node_modules/@loopback/docs/site');
const destDocs = path.resolve(__dirname, 'pages/en/lb4');
const srcSidebars = path.resolve(srcDocs, 'sidebars');
const destSidebars= path.resolve(__dirname, '_data/sidebars');

/**
* Utility function to remove a directory.
* @param {string} dir - The path of the directory to remove.
*/
function removeDir(dir) {
try {
fs.removeSync(dir);
} catch (err) {
console.error('failed to cleanup %s due to %s',
dir, err.stack);
process.exit(1);
}
}
/**
* Utility function to copy contents of a source directory to
* a target directory. If certain files already exist, it will
* overwrite them.
* @param {string} src - The path of the source directory to copy from.
* @param {string} dest - The path of the target directory to copy to.
*/
function copyDocs(src, dest) {
try {
fs.copySync(src, dest, {overwrite: true});
} catch (err) {
console.error('failed to copy latest docs %s from %s', src, err.stack);
process.exit(1);
}
}

// copy the latest docs from @loopback/docs to pages/en/lb4 directory
copyDocs(srcDocs, destDocs);

//copy over sidebar for LoopBack 4
copyDocs(srcSidebars, destSidebars);

//clean up sidebar dir
removeDir(srcSidebars);



const fileToUpdate = path.resolve(destDocs, 'Testing-the-API.md');

// bug in `jekyll-relative-links` plugin; probably safe to remove when
// https://github.com/benbalter/jekyll-relative-links/issues/5
// is resolved
try {
let contents = fs.readFileSync(fileToUpdate, 'utf-8');
contents = contents.replace('include previous.md', 'include previous.html');
fs.writeFileSync(fileToUpdate, contents, 'utf-8');
} catch (err) {
console.error('failed to replace relative link %s', err.stack);
process.exit(1);
}