Skip to content

Commit

Permalink
[release notes] extract "dev docs" comment too (elastic#79351) (elast…
Browse files Browse the repository at this point in the history
…ic#79944)

Co-authored-by: spalger <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: spalger <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
3 people authored Oct 7, 2020
1 parent 7b5ef20 commit 35dbb66
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/developer/contributing/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The Release Notes summarize what the PRs accomplish in language that is meaningf

The text that appears in the Release Notes is pulled directly from your PR title, or a single paragraph of text that you specify in the PR description.

To use a single paragraph of text, enter `Release note:` or a `## Release note` header in the PR description, followed by your text. For example, refer to this https://github.com/elastic/kibana/pull/65796[PR] that uses the `## Release note` header.
To use a single paragraph of text, enter a `Release note:` or `## Release note` header in the PR description ("dev docs" works too), followed by your text. For example, refer to this https://github.com/elastic/kibana/pull/65796[PR] that uses the `## Release note` header.

When you create the Release Notes text, use the following best practices:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ it('extracts expected components from html', () => {
## Release Note:
Checkout this feature
`)
`),
'release note'
)
).toMatchInlineSnapshot(`"Checkout this feature"`);

Expand All @@ -46,10 +47,11 @@ it('extracts expected components from html', () => {
Fixes: #1234
#### Release Note:
#### Dev docs:
We fixed an issue
`)
`),
'dev docs'
)
).toMatchInlineSnapshot(`"We fixed an issue"`);

Expand All @@ -60,8 +62,9 @@ it('extracts expected components from html', () => {
Fixes: #1234
Release note: Checkout feature foo
`)
OTHER TITLE: Checkout feature foo
`),
'other title'
)
).toMatchInlineSnapshot(`"Checkout feature foo"`);

Expand All @@ -73,7 +76,8 @@ it('extracts expected components from html', () => {
My PR description
release note : bar
`)
`),
'release note'
)
).toMatchInlineSnapshot(`"bar"`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

import cheerio from 'cheerio';

export function getNoteFromDescription(descriptionHtml: string) {
export function getNoteFromDescription(descriptionHtml: string, header: string) {
const re = new RegExp(`^(\\s*${header.toLowerCase()}(?:s)?\\s*:?\\s*)`, 'i');
const $ = cheerio.load(descriptionHtml);
for (const el of $('p,h1,h2,h3,h4,h5').toArray()) {
const text = $(el).text();
const match = text.match(/^(\s*release note(?:s)?\s*:?\s*)/i);
const match = text.match(re);

if (!match) {
continue;
Expand Down
4 changes: 3 additions & 1 deletion packages/kbn-release-notes/src/lib/pr_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ export class PrApi {
versions: labels
.map((l) => Version.fromLabel(l))
.filter((v): v is Version => v instanceof Version),
note: getNoteFromDescription(node.bodyHTML),
note:
getNoteFromDescription(node.bodyHTML, 'release note') ||
getNoteFromDescription(node.bodyHTML, 'dev docs'),
};
}

Expand Down

0 comments on commit 35dbb66

Please sign in to comment.