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

ATEAM-266: Move docs script out of gulpfile #68

Conversation

jakejrichards
Copy link
Contributor

The first step toward removing gulp and cleaning up the build process is to move the individual scripts out of the gulpfile. This PR just moves the build docs script to its own individual script file that can still be run via "npm run docs".

@jakejrichards jakejrichards changed the title Feature/ATEAM-266: Move docs script out of gulpfile ATEAM-266: Move docs script out of gulpfile Jun 4, 2020
}

let relativeLinkExtension = '.md';
if (docMdOutputFormat === PC_DEV_CENTER_FORMAT) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

KRAMDOWN is legacy and we can probably remove at this point. But, if we want to remove that in a sep PR, we should add it here as it was technically a bridge to an HTML format. i.e., it should have html links and probably should have been better named than KRAMDOWN

// If invoked via "npm run docs" or "node scripts/build-docs.js" run immediately
const calledFromCli = !module.parent;
if (calledFromCli) {
buildDocs();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts on adding a catch handler here, log to the console, and then process.exit(1). This will decouple the impl of buildDocs from it's invoking context.

process.exit(1);
}

let relativeLinkExtension = '.md';
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit, this should be linkExtension since it's global in this context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the "relative" here applied to the fact that they were relative links. But then I see that I named it linkExtension in the helper 🙃

return Promise.all(docPromises);
}).catch(reason => {
let errMsg = 'Documentation generation failed';
console.error(errMsg, reason);
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we could reject here with an object. maybe something like {msg, reason}. This lets the caller deal with how to handle ... logging (and which logger to use) and/or process.exit.

This is related to the cli handler comment above.

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 think it makes sense then to not catch the error at all, and just leave it up to the caller to handle the error, right?

Copy link
Collaborator

@justinaray justinaray Jun 4, 2020

Choose a reason for hiding this comment

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

yeah, i think that makes sense here since we'll mostly just catch and log it anyway. if it was an api, maybe we'd come up with a few types of errors (enum) and throw that so callers could handle without being exposed to impl details.

mostly this will just get rid of a log statement here in case it is handled by the caller and the log would be a red herring.

@justinaray
Copy link
Collaborator

Thanks for tackling this! very cool!

I diffed the dist from master and this branch and they are identical ... accept for the fixed links and return type of course.

@@ -0,0 +1,155 @@
/* eslint-env node */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts on adding a shebang and making this script executable? Of course, we could do this later when removing gulp or not do it at all if we want to ask users to call through npm run which makes sense as well.

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 just googled this and didn't even know it was a thing! I figured the only way to do it was an npm script. We can always come back and add it later if it's something we feel we need. I'll note it.

});

gulp.task('clean', function () {
return del([DEST_DIR]);
});

gulp.task('build', build);
gulp.task('docs', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This name change would change contributing.md. But, we're dumping gulp soon enough and you've got it removed in a later commit, so no need to make that change here.

@jakejrichards jakejrichards merged commit 5b669ce into bugfix/ATEAM-253_fix-broken-docs-links Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants