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
Conversation
This also splits the template into separate lines.
LGTM |
@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. |
LGTM |
@@ -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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)"); |
There was a problem hiding this comment.
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?
LGTM |
LGTM |
Looks like this was stuck in process. @gyandeeps @platinumazure what are the next steps here? |
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). |
Oops, I was planning to review this but I forgot. I'll finish that up soon. |
There was a problem hiding this 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"); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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)}`); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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`); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}`, |
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
LGTM |
@not-an-aardvark I think I’ve resolved the issues you’ve raised. |
LGTM |
There was a problem hiding this 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}`; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}` : "", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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`); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)}`); |
There was a problem hiding this comment.
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.
4c2ae71
to
6b129e0
Compare
LGTM |
LGTM |
Thanks for contributing! |
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 thenpm run gendocs
script.Note: this is a dependency of eslint/archive-website#367.