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

Build: Edit link in rule docs #9049

Merged
merged 9 commits into from Aug 26, 2017

Conversation

j-f1
Copy link
Contributor

@j-f1 j-f1 commented Jul 31, 2017

What is the purpose of this pull request?
To add metadata to the rule docs, specifying the edit link for the rules

What changes did you make? (Give an overview)

I added an edit_link key to the YAML front matter of the generated website docs. Additionally, I added progress logging to the npm run gendocs script.

Note: this is a dependency of eslint/archive-website#367.

@eslintbot
Copy link

LGTM

@mention-bot
Copy link

@j-f1, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nzakas, @mysticatea and @kaicataldo to be potential reviewers.

j-f1 added a commit to j-f1/forked-eslint.github.io that referenced this pull request Jul 31, 2017
@j-f1 j-f1 changed the title Edit link in rule docs Build: Edit link in rule docs Jul 31, 2017
@eslintbot
Copy link

LGTM

@not-an-aardvark not-an-aardvark added build This change relates to ESLint's build process documentation Relates to ESLint's documentation labels Aug 1, 2017
@@ -668,7 +671,11 @@ target.gensite = function(prereleaseVersion) {
const FIXABLE_TEXT = "\n\n(fixable) The `--fix` option on the [command line](../user-guide/command-line-interface#fix) can automatically fix some of the problems reported by this rule.";

// 4. Loop through all files in temporary directory
find(TEMP_DIR).forEach(filename => {
process.stdout.write("> Updating files (Steps 4-9): 0/... - ...\r");
Copy link
Member

Choose a reason for hiding this comment

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

why not use echo here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

echo adds a \n to the end, which causes the status to extend to multiple lines, which doesn’t provide a very nice experience. Additionally, echo("-n", "foo") doesn’t work.

Makefile.js Outdated
}

// 14. Create Example Formatter Output Page
echo("> Creating the formatter examples (Step 13)");
Copy link
Member

Choose a reason for hiding this comment

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

Should this be Step 14?

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@nzakas
Copy link
Member

nzakas commented Aug 23, 2017

Looks like this was stuck in process. @gyandeeps @platinumazure what are the next steps here?

@ilyavolodin
Copy link
Member

I think @not-an-aardvark was saying that he things there's a bug in this implementation (that's why we didn't merge it in before the last release).

@not-an-aardvark
Copy link
Member

Oops, I was planning to review this but I forgot. I'll finish that up soon.

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request! I left a few questions.

Makefile.js Outdated
"<!-- Note: No pull requests accepted for this file. See README.md in the root directory for details. -->",
"",
text
].filter(x => x).join("\n");
Copy link
Member

Choose a reason for hiding this comment

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

Why is .filter(x => x) used here? It seems like this will result in the "" on line 714 getting removed, which seems redundant.

Makefile.js Outdated
"<!-- Note: No pull requests accepted for this file. See README.md in the root directory for details. -->",
"",
text
].filter(x => x).join("\n");
Copy link
Member

Choose a reason for hiding this comment

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

Why is .filter(x => x) used here? It seems like this will result in the "" on line 733 getting removed, which seems redundant.

@@ -745,8 +772,10 @@ target.gensite = function(prereleaseVersion) {
}
});
JSON.stringify(versions).to("./versions.json");
echo(`> Updating files (Steps 4-9)${" ".repeat(50)}`);
Copy link
Member

Choose a reason for hiding this comment

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

Why is " ".repeat(50) printed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It overwrites any file name contents so they don’t appear after the message.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks. To me, It seems undesirable to have a hardcoded value of 50 there (since it will probably cause a bug if we ever add a filepath with length longer than 50), but it's a very small issue either way, so I'm fine with leaving it for now.

Makefile.js Outdated
@@ -680,6 +687,8 @@ target.gensite = function(prereleaseVersion) {
let text = cat(filename),
title;

process.stdout.write(`> Updating files (Steps 4-9): ${i}/${length} - ${sourcePath + " ".repeat(30)}\r`);
Copy link
Member

Choose a reason for hiding this comment

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

Why is \r used here instead of \n?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It resets to the beginning of the line, instead of spamming the terminal with lots and lots of lines.

Copy link
Member

Choose a reason for hiding this comment

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

Neat, TIL

Makefile.js Outdated
"---",
`title: ${title}`,
"layout: doc",
`edit_link: https://github.com/eslint/eslint/edit/master/${baseName}`,
Copy link
Member

Choose a reason for hiding this comment

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

Should this use filename instead of baseName? Otherwise, I think a file like docs/about/index.md will map to a link like https://github.com/eslint/eslint/edit/master/index.md, resulting in a 404.

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

My concerns are addressed, very sorry for not following up sooner. Thanks for contributing!

@eslintbot
Copy link

LGTM

@j-f1
Copy link
Contributor Author

j-f1 commented Aug 25, 2017

@not-an-aardvark I think I’ve resolved the issues you’ve raised.

@eslintbot
Copy link

LGTM

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good to me. I have a few more questions, but none of them are blockers for merging this.

Makefile.js Outdated
text = `---\ntitle: ${ruleName} - Rules\nlayout: doc\n---\n<!-- Note: No pull requests accepted for this file. See README.md in the root directory for details. -->\n\n${text}`;
title = `${ruleName} - Rules`;

editLink = `https://github.com/eslint/eslint/edit/master/docs/rules/${baseName}`;
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Is it necessary to assign editLink separately when the page is in the rules directory? Wouldn't `https://github.com/eslint/eslint/edit/master/${filePath}` work in both cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome! I didn’t notice that.

Makefile.js Outdated
"---",
`title: ${title}`,
"layout: doc",
editLink ? `edit_link: ${editLink}` : "",
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Will editLink ever be falsy here? It seems like it gets assigned on every code path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You’re right, removed the conditional.

Makefile.js Outdated
title,
editLink;

process.stdout.write(`> Updating files (Steps 4-9): ${i}/${length} - ${filePath + " ".repeat(30)}\n`);
Copy link
Member

Choose a reason for hiding this comment

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

I noticed you changed this back to \n rather than \r -- was that intentional? If so, should the " ".repeat(30) be removed?

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 changed it for testing the update, but I forgot to change it back. Fixed!

@@ -745,8 +772,10 @@ target.gensite = function(prereleaseVersion) {
}
});
JSON.stringify(versions).to("./versions.json");
echo(`> Updating files (Steps 4-9)${" ".repeat(50)}`);
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks. To me, It seems undesirable to have a hardcoded value of 50 there (since it will probably cause a bug if we ever add a filepath with length longer than 50), but it's a very small issue either way, so I'm fine with leaving it for now.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@not-an-aardvark not-an-aardvark merged commit e6b115c into eslint:master Aug 26, 2017
@not-an-aardvark
Copy link
Member

Thanks for contributing!

@j-f1 j-f1 deleted the edit-link-in-rule-docs branch August 26, 2017 21:45
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 23, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion build This change relates to ESLint's build process documentation Relates to ESLint's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants