Skip to content

Conversation

@b-admike
Copy link
Contributor

@b-admike b-admike commented Mar 9, 2018

Connect to loopbackio/loopback-next#843. This script copies over the doc files for LoopBack 4 content into this repo, and reverts some linking changes made in loopback-next in order to render it properly when Jekyll is run. Mad credits to @rmg for essentially writing the script! The script is intended to demonstrate how to achieve the proposal in the spike, so it would probably need to be modified if we are to use this approach.

EDIT The script now utilizes @loopback/docs to pull in the latest changes from loopback-next for LoopBack 4 docs and jekyll-relative-links plugin to handle .md links (with one exception). It also provides a Travis config to deploy to GitHub Pages whenever there are new changes.

@b-admike b-admike requested a review from bschrammIBM as a code owner March 9, 2018 18:32
@b-admike b-admike changed the title pull lb4 doc updates from loopback-next Pull LoopBack 4 doc updates from loopback-next Mar 9, 2018
@b-admike b-admike force-pushed the pull-monorepo-docs branch 5 times, most recently from 5e74638 to 6f23a25 Compare March 9, 2018 19:00
@rmg
Copy link
Contributor

rmg commented Mar 9, 2018

Your update-lb4-docs.sh needs a shebang at the top (#!/bin/bash) to ensure that it is executed with the correct interpreter instead of relying on /bin/sh being the default.

| tar --strip-components 1 -C $tmp -xzf- '*.md'
cp -R $tmp/packages $target/readmes/$repo
#rename relative link extensions from md to html
sed -E -i 's/\(([^(]+)\.md/(\1.html)/g' $tmp/docs/*.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have:

s/\(([^(]+)\.md/(\1.html)/g

It should be this:

s/\(([^(]+)\.md\)/(\1.html)/g

You need to match the closing ) literal otherwise it doesn't get replaced by the ) literal in the replacement and you end up with double )) on the output - and also incorrectly matching:
(index.md other stuff) -> (index.html) other stuff)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Actually I wanted to include the cases where .md is followed by # and left out the literal match for ). I will remove it from the replacement as well.

@b-admike b-admike force-pushed the pull-monorepo-docs branch from 5b86ea9 to 2287b46 Compare March 9, 2018 20:10
Copy link
Contributor

@bschrammIBM bschrammIBM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@b-admike b-admike changed the title Pull LoopBack 4 doc updates from loopback-next [WIP] Pull LoopBack 4 doc updates from loopback-next Mar 9, 2018
@b-admike b-admike force-pushed the pull-monorepo-docs branch 2 times, most recently from 4c54f77 to 9931ef0 Compare March 12, 2018 16:21
@kjdelisle kjdelisle force-pushed the pull-monorepo-docs branch from 9931ef0 to 482420b Compare March 12, 2018 17:00
Copy link
Contributor

@shimks shimks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but one comment

curl -L https://github.com/$ORG/$REPO/archive/$COMMIT.tar.gz | tar --strip-components 1 -C "$DOCS" --wildcards \
-xzf- "$ARCHIVE_NAME/docs/*.md" "$ARCHIVE_NAME/packages/*.md" "$ARCHIVE_NAME/docs/*.png"

# cp -R $DOCS/packages $DOCS/readmes/$REPO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this meant to be commented out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

ORG=strongloop
REPO=loopback-next
DOCS=./pages/en/lb4
COMMIT=893d68547766fc41d8bca82425645416e357d052
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be hard-coded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; it's supposed to be master.

curl -L https://github.com/$ORG/$REPO/archive/$COMMIT.tar.gz | tar --strip-components 1 -C "$DOCS" --wildcards \
-xzf- "$ARCHIVE_NAME/docs/*.md" "$ARCHIVE_NAME/packages/*.md" "$ARCHIVE_NAME/docs/*.png"

# cp -R $DOCS/packages $DOCS/readmes/$REPO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@b-admike b-admike force-pushed the pull-monorepo-docs branch 3 times, most recently from 6fb79d5 to eee1484 Compare March 12, 2018 19:52
}
stage('download updates') {
sh './update-readmes.sh'
sh './update-v4-readmes.sh'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should keep sh './update-v4-readmes.sh' here as it's used to pull in README files. Even after we move docs to the monorepo, we might continue to pull in README files.

mkdir -p $DOCS
# pull down all the markdown files (reserving dir structure)
# given the GitHub ORG, REPO, and COMMIT
curl -L https://github.com/$ORG/$REPO/archive/$COMMIT.tar.gz | tar --strip-components 1 -C "$DOCS" --wildcards \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, it's probably better to switch to npm install

@kjdelisle kjdelisle force-pushed the pull-monorepo-docs branch from 24c7c8c to 5d44653 Compare March 12, 2018 20:06
@b-admike b-admike force-pushed the pull-monorepo-docs branch from f7de9ec to 678a0d2 Compare March 12, 2018 20:14
@b-admike b-admike force-pushed the pull-monorepo-docs branch from 678a0d2 to 73d54a1 Compare March 12, 2018 20:52
# -xzvf- "$ARCHIVE_NAME/docs/*.md" "$ARCHIVE_NAME/packages/*.md"
# "$ARCHIVE_NAME/docs/*.png"
npm i @loopback/docs --prefix $DOCS
mv $DOCS/node_modules/@loopback/docs $DOCS/monorepo-docs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is /monorepo-docs needed? Or can we just move the docs fo $DOCS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The site/* should be copied into pages/en/lb4/.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just using it as a placeholder, before we implement changes that override the current doc contents, but yeah it should be site/*.

@raymondfeng
Copy link
Contributor

I just published @loopback/docs@0.1.2, which has all related files under site directory.

#curl -L https://github.com/$ORG/$REPO/archive/$BRANCH.tar.gz | tar --strip-components 1 -C "$DOCS" --wildcards \
# -xzvf- "$ARCHIVE_NAME/docs/*.md" "$ARCHIVE_NAME/packages/*.md"
# "$ARCHIVE_NAME/docs/*.png"
npm i @loopback/docs --prefix $DOCS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be further simplified if we add @loopback/docs as a dependency in package.json of loopback.io. This way, npm install at the root level will pull in node_modules/@loopback/docs and we can add a post-install script to copy them to the right place.
_

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked to @rmg and if we aim to do that, then we should probably introduce Travis to this repo since the Jenkins pipeline is

running directly on the Jenkins master and that server doesn't have any external executors

and doesn't have node/npm installed. It would be a hassle to install them there. Also,

all GitHub Pages does is run Jekyll and upload the generated _site directory (or whatever it is..) to S3

const destImages = path.resolve(__dirname, 'images', 'lb4');

function copyDocs(src, dest) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we should use two spaces for indentation.

@b-admike b-admike force-pushed the pull-monorepo-docs branch from 19493fd to aae94cf Compare March 20, 2018 19:23
{% 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 %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation?

Jenkinsfile Outdated

env.CHANGE_BRANCH = env.CHANGE_BRANCH ?: env.BRANCH_NAME


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a random whitespace change was accidentally left in.

.travis.yml Outdated
- npm test
email: slnode@ca.ibm.com
name: StrongLoop Bot

No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think there's some extra empty space here.

@rmg
Copy link
Contributor

rmg commented Mar 23, 2018

Travis has been configured

@b-admike b-admike force-pushed the pull-monorepo-docs branch 2 times, most recently from 37ab270 to a563306 Compare March 23, 2018 20:26
@b-admike b-admike force-pushed the pull-monorepo-docs branch 12 times, most recently from ac9f169 to 2f5382f Compare March 26, 2018 18:19
@b-admike
Copy link
Contributor Author

Unfortunately, we can't use custom commit messages for the commits made by Travis on successful builds, but the feature might come soon https://github.com/travis-ci/travis-ci/issues/9287.

@b-admike b-admike force-pushed the pull-monorepo-docs branch 3 times, most recently from 5f23fcb to 5daa9ae Compare March 26, 2018 18:59
Add a script to copy over loopback-next docs using
@loopback/docs. Add Travis config to pick up the
changes and deploy to GitHub Pages upon a successful
build. Run README update scripts from Travis as well
and remove Jenkinsfile which did the same thing with
Jenkins.
@b-admike b-admike force-pushed the pull-monorepo-docs branch from e8f7b01 to 09d4ef6 Compare March 26, 2018 19:41
@b-admike b-admike merged commit fa3608c into gh-pages Mar 26, 2018
@b-admike b-admike deleted the pull-monorepo-docs branch March 26, 2018 19:41
@b-admike b-admike restored the pull-monorepo-docs branch March 26, 2018 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants