Skip to content

Commit

Permalink
add a script that concatenates changelog_unreleased into a blog post …
Browse files Browse the repository at this point in the history
…draft
  • Loading branch information
thorn0 committed Feb 2, 2020
1 parent 6a497b6 commit 67340eb
Show file tree
Hide file tree
Showing 21 changed files with 1,675 additions and 53 deletions.
2 changes: 1 addition & 1 deletion changelog_unreleased/api/pr-6993.md
@@ -1,4 +1,4 @@
#### Remove deprecated api ([#6993](https://github.com/prettier/prettier/pull/6993) by [@fisker](https://github.com/fisker))
#### Remove deprecated API ([#6993](https://github.com/prettier/prettier/pull/6993) by [@fisker](https://github.com/fisker))

- Parser `typescript-eslint` is removed.

Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/css/pr-6947.md
@@ -1,7 +1,7 @@
#### Don't lowercase element names in CSS selectors ([#6947](https://github.com/prettier/prettier/pull/6947) by [@ark120202](https://github.com/ark120202))

Previously, Prettier already preserved casing of unknown element names, but it did lowercase names of HTML elements.
This caused issues when CSS was applied to a case-sensitive document and an there was an element with the same name as in HTML, which is the case in NativeScript.
This caused issues when CSS was applied to a case-sensitive document and there was an element with the same name as in HTML, which is the case in NativeScript.
Prettier now always preserves original casing.

<!-- prettier-ignore -->
Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/flow/pr-7482.md
@@ -1,4 +1,4 @@
#### Add support for `decorators` ([#7482](https://github.com/prettier/prettier/pull/7482) by [@fisker](https://github.com/fisker))
#### Add support for decorators ([#7482](https://github.com/prettier/prettier/pull/7482) by [@fisker](https://github.com/fisker))

<!-- prettier-ignore -->
```jsx
Expand Down
6 changes: 2 additions & 4 deletions changelog_unreleased/flow/pr-7484.md
@@ -1,9 +1,7 @@
#### Add support for the `ClassPrivateProperty` ([#7484](https://github.com/prettier/prettier/pull/7484) by [@fisker](https://github.com/fisker))

Previously, symbol `#` of `ClassPrivateProperty` is missing, now this bug been fixed.
#### Fix private class field declarations ([#7484](https://github.com/prettier/prettier/pull/7484) by [@fisker](https://github.com/fisker))

<!-- prettier-ignore -->
```jsx
```js
// Input
class Foo {#privateProp: number;}

Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/handlebars/pr-7051.md
@@ -1,4 +1,4 @@
#### Fix superfluous line breaks in ConcatStatement ([#7051](https://github.com/prettier/prettier/pull/7051) by [@dcyriller](https://github.com/dcyriller))
#### Fix superfluous line breaks in `ConcatStatement` ([#7051](https://github.com/prettier/prettier/pull/7051) by [@dcyriller](https://github.com/dcyriller))

<!-- prettier-ignore -->
```hbs
Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/handlebars/pr-7157.md
@@ -1,4 +1,4 @@
#### Improve MustacheStatement printing ([#7157](https://github.com/prettier/prettier/pull/7157) by [@dcyriller](https://github.com/dcyriller))
#### Improve `MustacheStatement` printing ([#7157](https://github.com/prettier/prettier/pull/7157) by [@dcyriller](https://github.com/dcyriller))

<!-- prettier-ignore -->
```hbs
Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/handlebars/pr-7275.md
@@ -1,4 +1,4 @@
#### Glimmer: Add prettier-ignore ([#7275](https://github.com/prettier/prettier/pull/7275) by [@chadian](https://github.com/chadian))
#### Add support for `prettier-ignore` ([#7275](https://github.com/prettier/prettier/pull/7275) by [@chadian](https://github.com/chadian))

<!-- prettier-ignore -->
```hbs
Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/handlebars/pr-7306.md
@@ -1,4 +1,4 @@
#### Support printing inline handlebars in html (through embed function) ([#7306](https://github.com/prettier/prettier/pull/7306) by [@dcyriller](https://github.com/dcyriller))
#### Support printing inline Handlebars in HTML ([#7306](https://github.com/prettier/prettier/pull/7306) by [@dcyriller](https://github.com/dcyriller))

<!-- prettier-ignore -->
```
Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/html/pr-7273.md
@@ -1,6 +1,6 @@
#### Don't treat colons as namespace prefix delimiters in tag names ([#7273](https://github.com/prettier/prettier/pull/7273) by [@fisker](https://github.com/fisker))

In HTML5, colons don't have any special meaning in tag names. Previously, Prettier treated them the XML way, as namespace prefix delimiters, but no more. In practice, this means that tags whose ancestors have colons in their names are now treated as usual HTML tags: if they're known standard tags, their names can be lowercased and assumptions can be made about their whitespace sensitivity; custom elements whose names are unknown to Prettier retain the casing of their names and are treated as inline with `--html-whitespace-sensitivity css`.
In HTML5, colons don't have any special meaning in tag names. Previously, Prettier treated them the XML way, as namespace prefix delimiters, but no more. In practice, this means that tags whose ancestors have colons in their names are now treated as usual HTML tags: if they're known standard tags, their names can be lowercased and assumptions can be made about their whitespace sensitivity; custom elements whose names are unknown to Prettier retain the casing of their names and, if `--html-whitespace-sensitivity` is set to `css`, are treated as inline.

<!-- prettier-ignore -->
```html
Expand Down
4 changes: 2 additions & 2 deletions changelog_unreleased/html/pr-7293.md
@@ -1,10 +1,10 @@
#### Do not throw on broken html ([#7293](https://github.com/prettier/prettier/pull/7293) by [@fisker](https://github.com/fisker))
#### Do not throw on broken HTML ([#7293](https://github.com/prettier/prettier/pull/7293) by [@fisker](https://github.com/fisker))

<!-- prettier-ignore -->
```html
<!-- Input -->
<div><span>
<
<

<!-- Prettier stable -->
TypeError: Cannot read property 'start' of null
Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/html/pr-7461.md
@@ -1,4 +1,4 @@
#### Fix Empty lines unexpectedly added after `table` tags ([#7461](https://github.com/prettier/prettier/pull/7461) by [@ikatyang](https://github.com/ikatyang))
#### Fix empty lines unexpectedly added after `table` tags ([#7461](https://github.com/prettier/prettier/pull/7461) by [@ikatyang](https://github.com/ikatyang))

<!-- prettier-ignore -->
```html
Expand Down
55 changes: 31 additions & 24 deletions changelog_unreleased/javascript/pr-3903.md
Expand Up @@ -2,34 +2,17 @@

Previously, a space would be added after the `function` keyword in function declarations, but not in function expressions. Now, for consistency, a space is always added after the `function` keyword, including in generators. Also, a space is now added between `yield` and `*`, which can help with [catching bugs](https://github.com/prettier/prettier/issues/7028#user-content-bugs).

<!-- prettier-ignore -->
```js
// Input
const identity = function (value) {
return value;
};
function identity (value) {
return value;
}
function * getRawText() {
for (const token of tokens) {
yield* token.getRawText();
}
}
const f = function<T>(value: T) {}
##### Functions

<!-- prettier-ignore -->
```ts
// Prettier stable
const identity = function(value) {
return value;
};
function identity(value) {
return value;
}
function* getRawText() {
for (const token of tokens) {
yield* token.getRawText();
}
}
const f = function<T>(value: T) {};

// Prettier master
Expand All @@ -39,10 +22,34 @@ const identity = function (value) {
function identity(value) {
return value;
}
function *getRawText() {
for (const token of tokens) {
yield *token.getRawText();
const f = function <T>(value: T) {};
```

##### Generators

<!-- prettier-ignore -->
```ts
// Prettier stable
function* foo<T>() {}
class Bar {
static *foo<T>() {
yield* foo<T>();
}
}
baz = {
async *foo<T>() {}
};
f = function*<T>() {};

// Prettier master
function *foo<T>() {}
class Bar {
static *foo<T>() {
yield *foo<T>();
}
}
const f = function <T>(value: T) {};
baz = {
async *foo<T>() {}
};
f = function *<T>() {};
```
4 changes: 1 addition & 3 deletions changelog_unreleased/javascript/pr-6984.md
@@ -1,6 +1,4 @@
#### Fix formatting of labeled statements with comments ([#6984](https://github.com/prettier/prettier/pull/6984) by [@clement26695](https://github.com/clement26695))

Formatting of comments in labeled statements was not stable
#### Fix unstable formatting of labeled statements with comments ([#6984](https://github.com/prettier/prettier/pull/6984) by [@clement26695](https://github.com/clement26695))

<!-- prettier-ignore -->
```jsx
Expand Down
4 changes: 1 addition & 3 deletions changelog_unreleased/javascript/pr-7011.md
@@ -1,6 +1,4 @@
#### Preserve parentheses for JSDoc type casting with extra spaces and asterisk at end ([#7011](https://github.com/prettier/prettier/pull/7011) by [@evilebottnawi](https://github.com/evilebottnawi))

Formatting of comments in labeled statements was not stable
#### Preserve parentheses for JSDoc type casting with extra trailing spaces and asterisks ([#7011](https://github.com/prettier/prettier/pull/7011) by [@evilebottnawi](https://github.com/evilebottnawi))

<!-- prettier-ignore -->
```javascript
Expand Down
6 changes: 3 additions & 3 deletions changelog_unreleased/javascript/pr-7367.md
@@ -1,10 +1,10 @@
#### Fix: remove unnecessary parens when yielding jsx ([#7367](https://github.com/prettier/prettier/pull/7367) by [@cola119](https://github.com/cola119))
#### Fix: remove unnecessary parens when yielding JSX ([#7367](https://github.com/prettier/prettier/pull/7367) by [@cola119](https://github.com/cola119))

<!-- prettier-ignore -->
```jsx
// Input
function* f() {
yield <div>generator</div>
yield <div>generator</div>;
}

// Prettier stable
Expand All @@ -14,6 +14,6 @@ function* f() {

// Prettier master
function* f() {
yield <div>generator</div>
yield <div>generator</div>;
}
```
4 changes: 2 additions & 2 deletions changelog_unreleased/markdown/pr-7181.md
@@ -1,6 +1,6 @@
#### fix HTML formatting broken if the beginning tag starts after a list item ([#7181](https://github.com/prettier/prettier/pull/7181) by [@sasurau4](https://github.com/sasurau4), [#7220](https://github.com/prettier/prettier/pull/7220) by [@sasurau4](https://github.com/sasurau4))
#### Fix HTML formatting broken if the beginning tag starts after a list item ([#7181](https://github.com/prettier/prettier/pull/7181) and [#7220](https://github.com/prettier/prettier/pull/7220) by [@sasurau4](https://github.com/sasurau4))

Previously, when Prettier format the html tag that starts after a list item, it would insert indent and break the relationship of open and close tag. Now, Prettier no longer change anything.
Previously, when Prettier formatted an HTML tag placed just after a list item, it would insert indent and break the relationship of open and close tag. Now, Prettier no longer changes anything.

<!-- prettier-ignore -->
```md
Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/mdx/pr-6398.md
@@ -1,4 +1,4 @@
#### Fix JSX Fragment format incorrectly ([#6398](https://github.com/prettier/prettier/pull/6398) by [@JounQin](https://github.com/JounQin))
#### Add support for JSX fragments ([#6398](https://github.com/prettier/prettier/pull/6398) by [@JounQin](https://github.com/JounQin))

Previous versions format JSX Fragment incorrectly in mdx, this has been fixed in this version.

Expand Down
4 changes: 2 additions & 2 deletions changelog_unreleased/mdx/pr-6949.md
@@ -1,4 +1,4 @@
#### Fix MDX html parsing errors ([#6949](https://github.com/prettier/prettier/pull/6949) by [@Tigge](https://github.com/Tigge) & [@thorn0](https://github.com/thorn0))
#### Fix JSX parsing bugs introduced in Prettier 1.19 ([#6949](https://github.com/prettier/prettier/pull/6949) by [@Tigge](https://github.com/Tigge) & [@thorn0](https://github.com/thorn0))

MDX parsing for JSX failed when encountering JSX elements that where not
parsable as HTML. Such as `<Tag value={{a: 'b'}}>test</Tag>`
Expand All @@ -23,7 +23,7 @@ parsable as HTML. Such as `<Tag value={{a: 'b'}}>test</Tag>`
SyntaxError: Unexpected closing tag "Tag". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (1:35)
> 1 | <Tag value={ {a : 'b' } }>test</ Tag>
| ^
2 |
2 |
3 | <Foo bg={ 'red' } >
4 | <div style={{ display: 'block'} }>
```
Expand Down
2 changes: 2 additions & 0 deletions changelog_unreleased/typescript/pr-7020.md
@@ -1,5 +1,7 @@
#### Print JSDoc-only types as is instead of throwing strange errors ([#7020](https://github.com/prettier/prettier/pull/7020) by [@thorn0](https://github.com/thorn0))

Another fix related to error recovery. Should come in handy to those who migrate from Flow to TypeScript.

<!-- prettier-ignore -->
```jsx
// Input
Expand Down
89 changes: 89 additions & 0 deletions scripts/draft-blog-post.js
@@ -0,0 +1,89 @@
#!/usr/bin/env node

"use strict";

const fs = require("fs");
const path = require("path");

const changelogUnreleasedDir = path.join(__dirname, "../changelog_unreleased");
const blogDir = path.join(__dirname, "../website/blog");

const version = require("../package.json").version.replace(/-.+/, "");
const versionShort = version.replace(/\.0$/, "");

const categories = [
{ dir: "javascript", title: "JavaScript" },
{ dir: "typescript", title: "TypeScript" },
{ dir: "flow", title: "Flow" },
{ dir: "json", title: "JSON" },
{ dir: "css", title: "CSS" },
{ dir: "scss", title: "SCSS" },
{ dir: "less", title: "Less" },
{ dir: "html", title: "HTML" },
{ dir: "vue", title: "Vue" },
{ dir: "angular", title: "Angular" },
{ dir: "lwc", title: "LWC" },
{ dir: "handlebars", title: "Handlebars" },
{ dir: "graphql", title: "GraphQL" },
{ dir: "markdown", title: "Markdown" },
{ dir: "mdx", title: "MDX" },
{ dir: "yaml", title: "YAML" },
{ dir: "api", title: "API" },
{ dir: "cli", title: "CLI" }
];

const categoriesByDir = categories.reduce((result, category) => {
result[category.dir] = category;
return result;
}, {});

const dirs = fs
.readdirSync(changelogUnreleasedDir, { withFileTypes: true })
.filter(entry => entry.isDirectory());

for (const dir of dirs) {
const dirPath = path.join(changelogUnreleasedDir, dir.name);
const category = categoriesByDir[dir.name];

if (!category) {
throw new Error("Unknown category: " + dir.name);
}

category.entries = fs
.readdirSync(path.join(changelogUnreleasedDir, dir.name))
.filter(fileName => /^pr-\d+\.md$/.test(fileName))
.map(fileName =>
fs
.readFileSync(path.join(dirPath, fileName), "utf8")
.trim()
.replace(/^#### [a-z]/, s => s.toUpperCase())
);
}

const result = [
`---
author: "🚧"
authorURL: "https://github.com/🚧"
title: "Prettier ${versionShort}: 🚧"
---`,
"🚧 Write an introduction here.",
"<!--truncate-->",
"## Highlights",
"🚧 Move the most interesting changes here.",
"## Other changes"
];

for (const category of categories) {
if (!category.entries || category.entries.length === 0) {
continue;
}

result.push("### " + category.title);

result.push(...category.entries);
}

fs.writeFileSync(
path.join(blogDir, `${new Date().getFullYear()}-00-00-${version}.md`),
result.join("\n\n") + "\n"
);

0 comments on commit 67340eb

Please sign in to comment.