Skip to content

[WIP] Generate options.md and README.md#Options#2937

Closed
azz wants to merge 11 commits intoprettier:masterfrom
azz:auto-options
Closed

[WIP] Generate options.md and README.md#Options#2937
azz wants to merge 11 commits intoprettier:masterfrom
azz:auto-options

Conversation

@azz
Copy link
Member

@azz azz commented Sep 30, 2017

This is super-early progress on #2825.

I'm open to ideas on where to put all the existing documentation for each option. Maybe we could add a JSDoc comment to each option in cli-constant.js and use that? We could keep it simple and use template strings but that's code that we ship. We could also put it in a separate file as yml.

value: "typescript",
description: "https://github.com/eslint/typescript-eslint-parser"
},
{ value: "css", description: "https://github.com/postcss/postcss" },
Copy link
Member

Choose a reason for hiding this comment

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

This description is incorrect. We don’t use the postcss parser (and never have). The "css" option tries to use postcss-less first, and if that fails, postcss-scss (unless a regex says to flip the order).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, thanks for catching that.


// https://github.com/chjj/marked/issues/285
function backtick(string) {
if (string.indexOf("|") > -1) {
Copy link
Member

Choose a reason for hiding this comment

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

Pro-tip: There’s String.prototype.includes (and, yes, it is supported on Node.js 4).

Copy link
Member Author

Choose a reason for hiding this comment

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

Every now and then I get it confused with Array.prototype.includes which isn't supported by node v4.

Copy link
Member

Choose a reason for hiding this comment

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

So do I!

Copy link
Member

Choose a reason for hiding this comment

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

Always get confused with these two:

* `babylon` https://github.com/babel/babylon
* `typescript` https://github.com/eslint/typescript-eslint-parser
* `css` https://github.com/postcss/postcss
* `css` scientifically try both postcss-less and postcss-scss
Copy link
Member

Choose a reason for hiding this comment

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

I love this new description! 😆

@azz
Copy link
Member Author

azz commented Sep 30, 2017

I implemented docblock parsing... Not because it is necessarily a good idea but I felt like the challenge. Now the source of truth for documentation is in one place.

module.exports = {
"bracket-spacing": {
type: "boolean",
category: categories.FORMAT,
Copy link
Member

Choose a reason for hiding this comment

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

Early on in one of the CLI refactor PRs, the categories used to be specified as string literals each time, such as category: "format". Then I changed to category: CATEGORY_FORMAT. I thought about making a categories object like you have here, but settled on all those separate variables because then ESLint catches typos for us. Now, that “security” is lost. But I guess the tests would catch an unexpected "Undefined options:" line in the --help output.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooh that's a good point. I only moved it because it is depended on in two files, and it would have been a circular dependency otherwise. But yes, the tests should catch this.

features (including Flow). Prettier automatically infers the parser from the
input file path, so you shouldn't have to change this setting.

Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but if you manage to figure out where these trailing spaces come from it would be nice if we could remove them :)

Copy link
Member Author

Choose a reason for hiding this comment

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

That's just my naive docblock regex, I realized that require('jest-docblock').parseWithComments() does a .trim() which removes wanted left-padding. I'll probably do a PR there to fix that.

Copy link
Member Author

Choose a reason for hiding this comment

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

@azz
Copy link
Member Author

azz commented Oct 6, 2017

I'm thinking this PR is being a bit too smart and maybe we should just use markdown-magic to sync across the contents of options.md to the main README.md.

@azz azz changed the title WIP: Generate options.md and README.md#Options [WIP] Generate options.md and README.md#Options Oct 22, 2017
@azz
Copy link
Member Author

azz commented Oct 29, 2017

See #3116

@azz azz closed this Oct 29, 2017
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants