mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: allow a script to generate release-notes for GitHub (#27596)
`node utils/render_release_notes.mjs js 1.39`
This commit is contained in:
parent
b3bcf1c75a
commit
6b31b30df9
26
packages/playwright-core/types/types.d.ts
vendored
26
packages/playwright-core/types/types.d.ts
vendored
@ -10576,7 +10576,7 @@ export interface Locator {
|
|||||||
* Returns an array of `node.innerText` values for all matching nodes.
|
* Returns an array of `node.innerText` values for all matching nodes.
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert text on the page, prefer
|
* **NOTE** If you need to assert text on the page, prefer
|
||||||
* [locatorAssertions.toHaveText(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text)
|
* [expect(locator).toHaveText(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text)
|
||||||
* with `useInnerText` option to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* with `useInnerText` option to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -10592,7 +10592,7 @@ export interface Locator {
|
|||||||
* Returns an array of `node.textContent` values for all matching nodes.
|
* Returns an array of `node.textContent` values for all matching nodes.
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert text on the page, prefer
|
* **NOTE** If you need to assert text on the page, prefer
|
||||||
* [locatorAssertions.toHaveText(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text)
|
* [expect(locator).toHaveText(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -10898,7 +10898,7 @@ export interface Locator {
|
|||||||
* Returns the number of elements matching the locator.
|
* Returns the number of elements matching the locator.
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert the number of elements on the page, prefer
|
* **NOTE** If you need to assert the number of elements on the page, prefer
|
||||||
* [locatorAssertions.toHaveCount(count[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-count)
|
* [expect(locator).toHaveCount(count[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-count)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -11249,7 +11249,7 @@ export interface Locator {
|
|||||||
* Returns the matching element's attribute value.
|
* Returns the matching element's attribute value.
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert an element's attribute, prefer
|
* **NOTE** If you need to assert an element's attribute, prefer
|
||||||
* [locatorAssertions.toHaveAttribute(name, value[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-attribute)
|
* [expect(locator).toHaveAttribute(name, value[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-attribute)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
* @param name Attribute name to get the value for.
|
* @param name Attribute name to get the value for.
|
||||||
* @param options
|
* @param options
|
||||||
@ -11668,7 +11668,7 @@ export interface Locator {
|
|||||||
* Returns the [`element.innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText).
|
* Returns the [`element.innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText).
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert text on the page, prefer
|
* **NOTE** If you need to assert text on the page, prefer
|
||||||
* [locatorAssertions.toHaveText(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text)
|
* [expect(locator).toHaveText(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text)
|
||||||
* with `useInnerText` option to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* with `useInnerText` option to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
@ -11686,7 +11686,7 @@ export interface Locator {
|
|||||||
* Returns the value for the matching `<input>` or `<textarea>` or `<select>` element.
|
* Returns the value for the matching `<input>` or `<textarea>` or `<select>` element.
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert input value, prefer
|
* **NOTE** If you need to assert input value, prefer
|
||||||
* [locatorAssertions.toHaveValue(value[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-value)
|
* [expect(locator).toHaveValue(value[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-value)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -11717,7 +11717,7 @@ export interface Locator {
|
|||||||
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert that checkbox is checked, prefer
|
* **NOTE** If you need to assert that checkbox is checked, prefer
|
||||||
* [locatorAssertions.toBeChecked([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-checked)
|
* [expect(locator).toBeChecked([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-checked)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -11742,7 +11742,7 @@ export interface Locator {
|
|||||||
* Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled).
|
* Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled).
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert that an element is disabled, prefer
|
* **NOTE** If you need to assert that an element is disabled, prefer
|
||||||
* [locatorAssertions.toBeDisabled([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-disabled)
|
* [expect(locator).toBeDisabled([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-disabled)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -11767,7 +11767,7 @@ export interface Locator {
|
|||||||
* Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable).
|
* Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable).
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert that an element is editable, prefer
|
* **NOTE** If you need to assert that an element is editable, prefer
|
||||||
* [locatorAssertions.toBeEditable([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-editable)
|
* [expect(locator).toBeEditable([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-editable)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -11792,7 +11792,7 @@ export interface Locator {
|
|||||||
* Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled).
|
* Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled).
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert that an element is enabled, prefer
|
* **NOTE** If you need to assert that an element is enabled, prefer
|
||||||
* [locatorAssertions.toBeEnabled([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-enabled)
|
* [expect(locator).toBeEnabled([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-enabled)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -11817,7 +11817,7 @@ export interface Locator {
|
|||||||
* Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible).
|
* Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible).
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert that element is hidden, prefer
|
* **NOTE** If you need to assert that element is hidden, prefer
|
||||||
* [locatorAssertions.toBeHidden([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-hidden)
|
* [expect(locator).toBeHidden([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-hidden)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -11841,7 +11841,7 @@ export interface Locator {
|
|||||||
* Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible).
|
* Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible).
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert that element is visible, prefer
|
* **NOTE** If you need to assert that element is visible, prefer
|
||||||
* [locatorAssertions.toBeVisible([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-visible)
|
* [expect(locator).toBeVisible([options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-visible)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -12445,7 +12445,7 @@ export interface Locator {
|
|||||||
* Returns the [`node.textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent).
|
* Returns the [`node.textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent).
|
||||||
*
|
*
|
||||||
* **NOTE** If you need to assert text on the page, prefer
|
* **NOTE** If you need to assert text on the page, prefer
|
||||||
* [locatorAssertions.toHaveText(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text)
|
* [expect(locator).toHaveText(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text)
|
||||||
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
* to avoid flakiness. See [assertions guide](https://playwright.dev/docs/test-assertions) for more details.
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
|
|||||||
78
packages/playwright/types/test.d.ts
vendored
78
packages/playwright/types/test.d.ts
vendored
@ -623,7 +623,7 @@ interface TestConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration for the
|
* Configuration for the
|
||||||
* [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
* [expect(page).toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
||||||
* method.
|
* method.
|
||||||
*/
|
*/
|
||||||
toHaveScreenshot?: {
|
toHaveScreenshot?: {
|
||||||
@ -666,7 +666,7 @@ interface TestConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration for the
|
* Configuration for the
|
||||||
* [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
|
* [expect(value).toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
|
||||||
* method.
|
* method.
|
||||||
*/
|
*/
|
||||||
toMatchSnapshot?: {
|
toMatchSnapshot?: {
|
||||||
@ -1132,9 +1132,9 @@ interface TestConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This option configures a template controlling location of snapshots generated by
|
* This option configures a template controlling location of snapshots generated by
|
||||||
* [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
* [expect(page).toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
||||||
* and
|
* and
|
||||||
* [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
|
* [expect(value).toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
@ -4594,7 +4594,7 @@ interface AsymmetricMatchers {
|
|||||||
/**
|
/**
|
||||||
* `expect.any()` matches any object instance created from the `constructor` or a corresponding primitive type. Use it
|
* `expect.any()` matches any object instance created from the `constructor` or a corresponding primitive type. Use it
|
||||||
* inside
|
* inside
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* to perform pattern matching.
|
* to perform pattern matching.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -4616,7 +4616,7 @@ interface AsymmetricMatchers {
|
|||||||
any(sample: unknown): AsymmetricMatcher;
|
any(sample: unknown): AsymmetricMatcher;
|
||||||
/**
|
/**
|
||||||
* `expect.anything()` matches everything except `null` and `undefined`. Use it inside
|
* `expect.anything()` matches everything except `null` and `undefined`. Use it inside
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* to perform pattern matching.
|
* to perform pattern matching.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -4634,7 +4634,7 @@ interface AsymmetricMatchers {
|
|||||||
* Note that received array may be a superset of the expected array and contain some extra elements.
|
* Note that received array may be a superset of the expected array and contain some extra elements.
|
||||||
*
|
*
|
||||||
* Use this method inside
|
* Use this method inside
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* to perform pattern matching.
|
* to perform pattern matching.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -4649,9 +4649,9 @@ interface AsymmetricMatchers {
|
|||||||
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
|
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
|
||||||
/**
|
/**
|
||||||
* Compares floating point numbers for approximate equality. Use this method inside
|
* Compares floating point numbers for approximate equality. Use this method inside
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* to perform pattern matching. When just comparing two numbers, prefer
|
* to perform pattern matching. When just comparing two numbers, prefer
|
||||||
* [genericAssertions.toBeCloseTo(expected[, numDigits])](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be-close-to).
|
* [expect(value).toBeCloseTo(expected[, numDigits])](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be-close-to).
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
@ -4669,7 +4669,7 @@ interface AsymmetricMatchers {
|
|||||||
* object. Note that received object may be a superset of the expected object and contain some extra properties.
|
* object. Note that received object may be a superset of the expected object and contain some extra properties.
|
||||||
*
|
*
|
||||||
* Use this method inside
|
* Use this method inside
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* to perform pattern matching. Object properties can be matchers to further relax the expectation. See examples.
|
* to perform pattern matching. Object properties can be matchers to further relax the expectation. See examples.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -4697,7 +4697,7 @@ interface AsymmetricMatchers {
|
|||||||
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
|
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
|
||||||
/**
|
/**
|
||||||
* `expect.stringContaining()` matches a string that contains the expected substring. Use this method inside
|
* `expect.stringContaining()` matches a string that contains the expected substring. Use this method inside
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* to perform pattern matching.
|
* to perform pattern matching.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -4712,7 +4712,7 @@ interface AsymmetricMatchers {
|
|||||||
/**
|
/**
|
||||||
* `expect.stringMatching()` matches a received string that in turn matches the expected pattern. Use this method
|
* `expect.stringMatching()` matches a received string that in turn matches the expected pattern. Use this method
|
||||||
* inside
|
* inside
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* to perform pattern matching.
|
* to perform pattern matching.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -4779,7 +4779,7 @@ interface GenericAssertions<R> {
|
|||||||
toBe(expected: unknown): R;
|
toBe(expected: unknown): R;
|
||||||
/**
|
/**
|
||||||
* Compares floating point numbers for approximate equality. Use this method instead of
|
* Compares floating point numbers for approximate equality. Use this method instead of
|
||||||
* [genericAssertions.toBe(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be)
|
* [expect(value).toBe(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be)
|
||||||
* when comparing floating point numbers.
|
* when comparing floating point numbers.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
@ -4967,10 +4967,10 @@ interface GenericAssertions<R> {
|
|||||||
*
|
*
|
||||||
* For objects, this method recursively checks equality of all fields, rather than comparing objects by reference as
|
* For objects, this method recursively checks equality of all fields, rather than comparing objects by reference as
|
||||||
* performed by
|
* performed by
|
||||||
* [genericAssertions.toContain(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-contain-2).
|
* [expect(value).toContain(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-contain-2).
|
||||||
*
|
*
|
||||||
* For primitive values, this method is equivalent to
|
* For primitive values, this method is equivalent to
|
||||||
* [genericAssertions.toContain(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-contain-2).
|
* [expect(value).toContain(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-contain-2).
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
@ -4992,10 +4992,10 @@ interface GenericAssertions<R> {
|
|||||||
*
|
*
|
||||||
* For objects, this method recursively checks equality of all fields, rather than comparing objects by reference as
|
* For objects, this method recursively checks equality of all fields, rather than comparing objects by reference as
|
||||||
* performed by
|
* performed by
|
||||||
* [genericAssertions.toBe(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be).
|
* [expect(value).toBe(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be).
|
||||||
*
|
*
|
||||||
* For primitive values, this method is equivalent to
|
* For primitive values, this method is equivalent to
|
||||||
* [genericAssertions.toBe(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be).
|
* [expect(value).toBe(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be).
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
@ -5006,29 +5006,29 @@ interface GenericAssertions<R> {
|
|||||||
*
|
*
|
||||||
* **Non-strict equality**
|
* **Non-strict equality**
|
||||||
*
|
*
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* performs deep equality check that compares contents of the received and expected values. To ensure two objects
|
* performs deep equality check that compares contents of the received and expected values. To ensure two objects
|
||||||
* reference the same instance, use
|
* reference the same instance, use
|
||||||
* [genericAssertions.toBe(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be)
|
* [expect(value).toBe(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-be)
|
||||||
* instead.
|
* instead.
|
||||||
*
|
*
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* ignores `undefined` properties and array items, and does not insist on object types being equal. For stricter
|
* ignores `undefined` properties and array items, and does not insist on object types being equal. For stricter
|
||||||
* matching, use
|
* matching, use
|
||||||
* [genericAssertions.toStrictEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-strict-equal).
|
* [expect(value).toStrictEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-strict-equal).
|
||||||
*
|
*
|
||||||
* **Pattern matching**
|
* **Pattern matching**
|
||||||
*
|
*
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
||||||
* can be also used to perform pattern matching on objects, arrays and primitive types, with the help of the following
|
* can be also used to perform pattern matching on objects, arrays and primitive types, with the help of the following
|
||||||
* matchers:
|
* matchers:
|
||||||
* - [genericAssertions.any(constructor)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-any)
|
* - [expect(value).any(constructor)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-any)
|
||||||
* - [genericAssertions.anything()](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-anything)
|
* - [expect(value).anything()](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-anything)
|
||||||
* - [genericAssertions.arrayContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-array-containing)
|
* - [expect(value).arrayContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-array-containing)
|
||||||
* - [genericAssertions.closeTo(expected[, numDigits])](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-close-to)
|
* - [expect(value).closeTo(expected[, numDigits])](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-close-to)
|
||||||
* - [genericAssertions.objectContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-object-containing)
|
* - [expect(value).objectContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-object-containing)
|
||||||
* - [genericAssertions.stringContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-string-containing)
|
* - [expect(value).stringContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-string-containing)
|
||||||
* - [genericAssertions.stringMatching(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-string-matching)
|
* - [expect(value).stringMatching(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-string-matching)
|
||||||
*
|
*
|
||||||
* Here is an example that asserts some of the values inside a complex object:
|
* Here is an example that asserts some of the values inside a complex object:
|
||||||
*
|
*
|
||||||
@ -5062,7 +5062,7 @@ interface GenericAssertions<R> {
|
|||||||
/**
|
/**
|
||||||
* Ensures that property at provided `keyPath` exists on the object and optionally checks that property is equal to
|
* Ensures that property at provided `keyPath` exists on the object and optionally checks that property is equal to
|
||||||
* the `expected`. Equality is checked recursively, similarly to
|
* the `expected`. Equality is checked recursively, similarly to
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal).
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal).
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
@ -5101,7 +5101,7 @@ interface GenericAssertions<R> {
|
|||||||
/**
|
/**
|
||||||
* Compares contents of the value with contents of `expected`, performing "deep equality" check. Allows extra
|
* Compares contents of the value with contents of `expected`, performing "deep equality" check. Allows extra
|
||||||
* properties to be present in the value, unlike
|
* properties to be present in the value, unlike
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal),
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal),
|
||||||
* so you can check just a subset of object properties.
|
* so you can check just a subset of object properties.
|
||||||
*
|
*
|
||||||
* When comparing arrays, the number of items must match, and each item is checked recursively.
|
* When comparing arrays, the number of items must match, and each item is checked recursively.
|
||||||
@ -5127,7 +5127,7 @@ interface GenericAssertions<R> {
|
|||||||
* Compares contents of the value with contents of `expected` **and** their types.
|
* Compares contents of the value with contents of `expected` **and** their types.
|
||||||
*
|
*
|
||||||
* Differences from
|
* Differences from
|
||||||
* [genericAssertions.toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal):
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal):
|
||||||
* - Keys with undefined properties are checked. For example, `{ a: undefined, b: 2 }` does not match `{ b: 2 }`.
|
* - Keys with undefined properties are checked. For example, `{ a: undefined, b: 2 }` does not match `{ b: 2 }`.
|
||||||
* - Array sparseness is checked. For example, `[, 1]` does not match `[undefined, 1]`.
|
* - Array sparseness is checked. For example, `[, 1]` does not match `[undefined, 1]`.
|
||||||
* - Object types are checked to be equal. For example, a class instance with fields `a` and `b` will not equal a
|
* - Object types are checked to be equal. For example, a class instance with fields `a` and `b` will not equal a
|
||||||
@ -5173,7 +5173,7 @@ interface GenericAssertions<R> {
|
|||||||
toThrow(error?: unknown): R;
|
toThrow(error?: unknown): R;
|
||||||
/**
|
/**
|
||||||
* An alias for
|
* An alias for
|
||||||
* [genericAssertions.toThrow([expected])](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-throw).
|
* [expect(value).toThrow([expected])](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-throw).
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
@ -6450,7 +6450,7 @@ interface PageAssertions {
|
|||||||
interface SnapshotAssertions {
|
interface SnapshotAssertions {
|
||||||
/**
|
/**
|
||||||
* **NOTE** To compare screenshots, use
|
* **NOTE** To compare screenshots, use
|
||||||
* [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
* [expect(page).toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
||||||
* instead.
|
* instead.
|
||||||
*
|
*
|
||||||
* Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test
|
* Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test
|
||||||
@ -6504,7 +6504,7 @@ interface SnapshotAssertions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* **NOTE** To compare screenshots, use
|
* **NOTE** To compare screenshots, use
|
||||||
* [pageAssertions.toHaveScreenshot([options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-2)
|
* [expect(page).toHaveScreenshot([options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-2)
|
||||||
* instead.
|
* instead.
|
||||||
*
|
*
|
||||||
* Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test
|
* Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test
|
||||||
@ -6687,7 +6687,7 @@ interface TestProject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration for the
|
* Configuration for the
|
||||||
* [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
* [expect(page).toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
||||||
* method.
|
* method.
|
||||||
*/
|
*/
|
||||||
toHaveScreenshot?: {
|
toHaveScreenshot?: {
|
||||||
@ -6730,7 +6730,7 @@ interface TestProject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration for the
|
* Configuration for the
|
||||||
* [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
|
* [expect(value).toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
|
||||||
* method.
|
* method.
|
||||||
*/
|
*/
|
||||||
toMatchSnapshot?: {
|
toMatchSnapshot?: {
|
||||||
@ -6856,9 +6856,9 @@ interface TestProject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This option configures a template controlling location of snapshots generated by
|
* This option configures a template controlling location of snapshots generated by
|
||||||
* [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
* [expect(page).toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
|
||||||
* and
|
* and
|
||||||
* [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
|
* [expect(value).toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
|
|||||||
137
utils/doclint/linkUtils.js
Normal file
137
utils/doclint/linkUtils.js
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Microsoft Corporation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
// @ts-check
|
||||||
|
const toKebabCase = require('lodash/kebabCase.js')
|
||||||
|
|
||||||
|
const createMarkdownLink = (languagePath, member, text) => {
|
||||||
|
const className = toKebabCase(member.clazz.name);
|
||||||
|
const memberName = toKebabCase(member.name);
|
||||||
|
let hash = null;
|
||||||
|
if (member.kind === 'property' || member.kind === 'method')
|
||||||
|
hash = `${className}-${memberName}`.toLowerCase();
|
||||||
|
else if (member.kind === 'event')
|
||||||
|
hash = `${className}-event-${memberName}`.toLowerCase();
|
||||||
|
return `[${text}](https://playwright.dev${languagePath}/docs/api/class-${member.clazz.name.toLowerCase()}#${hash})`;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} language
|
||||||
|
* @returns {import('../doclint/documentation').Renderer}
|
||||||
|
*/
|
||||||
|
function docsLinkRendererForLanguage(language) {
|
||||||
|
const languagePath = languageToRelativeDocsPath(language);
|
||||||
|
return ({ clazz, member, param, option }) => {
|
||||||
|
if (param)
|
||||||
|
return `\`${param}\``;
|
||||||
|
if (option)
|
||||||
|
return `\`${option}\``;
|
||||||
|
if (clazz)
|
||||||
|
return `{@link ${clazz.name}}`;
|
||||||
|
if (!member || !member.clazz)
|
||||||
|
throw new Error('Internal error');
|
||||||
|
const className = member.clazz.varName === 'playwrightAssertions' ? '' : member.clazz.varName + '.';
|
||||||
|
if (member.kind === 'method')
|
||||||
|
return createMarkdownLink(languagePath, member, `${formatClassName(className, language)}${member.alias}(${renderJSSignature(member.argsArray)})`);
|
||||||
|
if (member.kind === 'event')
|
||||||
|
return createMarkdownLink(languagePath, member, `${className}on('${member.alias.toLowerCase()}')`);
|
||||||
|
if (member.kind === 'property')
|
||||||
|
return createMarkdownLink(languagePath, member, `${className}${member.alias}`);
|
||||||
|
throw new Error('Unknown member kind ' + member.kind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function languageToRelativeDocsPath(language) {
|
||||||
|
if (language === 'js')
|
||||||
|
return '';
|
||||||
|
if (language === 'csharp')
|
||||||
|
return '/dotnet';
|
||||||
|
if (language === 'python')
|
||||||
|
return '/python';
|
||||||
|
if (language === 'java')
|
||||||
|
return '/java';
|
||||||
|
throw new Error('Unexpected language ' + language);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatClassName(className, language) {
|
||||||
|
if (!className.endsWith('Assertions.'))
|
||||||
|
return className;
|
||||||
|
className = className.substring(0, className.length - 1)
|
||||||
|
if (language === 'js')
|
||||||
|
return `expect(${assertionArgument(className)}).`;
|
||||||
|
else if (language === 'csharp')
|
||||||
|
return `Expect(${assertionArgument(className)}).`;
|
||||||
|
else if (language === 'python')
|
||||||
|
return `expect(${assertionArgument(className)}).`;
|
||||||
|
else if (language === 'java')
|
||||||
|
return `assertThat(${assertionArgument(className)}).`;
|
||||||
|
throw new Error('Unexpected language ' + language);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertionArgument(className) {
|
||||||
|
switch (className.toLowerCase()) {
|
||||||
|
case 'locatorassertions': return 'locator';
|
||||||
|
case 'pageassertions': return 'page';
|
||||||
|
case 'genericassertions': return 'value';
|
||||||
|
case 'snapshotassertions': return 'value';
|
||||||
|
case 'apiresponseassertions': return 'response';
|
||||||
|
}
|
||||||
|
throw new Error(`Unexpected assertion class: ${className}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('../doclint/documentation').Member[]} args
|
||||||
|
*/
|
||||||
|
function renderJSSignature(args) {
|
||||||
|
const tokens = [];
|
||||||
|
let hasOptional = false;
|
||||||
|
for (const arg of args) {
|
||||||
|
const name = arg.alias;
|
||||||
|
const optional = !arg.required;
|
||||||
|
if (tokens.length) {
|
||||||
|
if (optional && !hasOptional)
|
||||||
|
tokens.push(`[, ${name}`);
|
||||||
|
else
|
||||||
|
tokens.push(`, ${name}`);
|
||||||
|
} else {
|
||||||
|
if (optional && !hasOptional)
|
||||||
|
tokens.push(`[${name}`);
|
||||||
|
else
|
||||||
|
tokens.push(`${name}`);
|
||||||
|
}
|
||||||
|
hasOptional = hasOptional || optional;
|
||||||
|
}
|
||||||
|
if (hasOptional)
|
||||||
|
tokens.push(']');
|
||||||
|
return tokens.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} content
|
||||||
|
* @param {string} languagePath
|
||||||
|
* @param {string} relativePath
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function renderPlaywrightDevLinks(content, languagePath, relativePath) {
|
||||||
|
return content.replace(/\[([^\]]+)\]\((\.[^\)]+)\)/g, (match, p1, p2) => {
|
||||||
|
return `[${p1}](${new URL(p2.replace('.md', ''), `https://playwright.dev${languagePath}/docs${relativePath}/`).toString()})`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
docsLinkRendererForLanguage,
|
||||||
|
renderPlaywrightDevLinks,
|
||||||
|
languageToRelativeDocsPath,
|
||||||
|
}
|
||||||
@ -25,6 +25,7 @@ const fs = require('fs');
|
|||||||
const { parseOverrides } = require('./parseOverrides');
|
const { parseOverrides } = require('./parseOverrides');
|
||||||
const exported = require('./exported.json');
|
const exported = require('./exported.json');
|
||||||
const { parseApi } = require('../doclint/api_parser');
|
const { parseApi } = require('../doclint/api_parser');
|
||||||
|
const { docsLinkRendererForLanguage, renderPlaywrightDevLinks } = require('../doclint/linkUtils');
|
||||||
|
|
||||||
Error.stackTraceLimit = 50;
|
Error.stackTraceLimit = 50;
|
||||||
|
|
||||||
@ -60,35 +61,7 @@ class TypesGenerator {
|
|||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
async generateTypes(overridesFile) {
|
async generateTypes(overridesFile) {
|
||||||
const createMarkdownLink = (member, text) => {
|
this.documentation.setLinkRenderer(docsLinkRendererForLanguage('js'));
|
||||||
const className = toKebabCase(member.clazz.name);
|
|
||||||
const memberName = toKebabCase(member.name);
|
|
||||||
let hash = null;
|
|
||||||
if (member.kind === 'property' || member.kind === 'method')
|
|
||||||
hash = `${className}-${memberName}`.toLowerCase();
|
|
||||||
else if (member.kind === 'event')
|
|
||||||
hash = `${className}-event-${memberName}`.toLowerCase();
|
|
||||||
return `[${text}](https://playwright.dev/docs/api/class-${member.clazz.name.toLowerCase()}#${hash})`;
|
|
||||||
};
|
|
||||||
this.documentation.setLinkRenderer(item => {
|
|
||||||
const { clazz, member, param, option } = item;
|
|
||||||
if (param)
|
|
||||||
return `\`${param}\``;
|
|
||||||
if (option)
|
|
||||||
return `\`${option}\``;
|
|
||||||
if (clazz)
|
|
||||||
return `{@link ${clazz.name}}`;
|
|
||||||
if (!member || !member.clazz)
|
|
||||||
throw new Error('Internal error');
|
|
||||||
const className = member.clazz.varName === 'playwrightAssertions' ? '' : member.clazz.varName + '.';
|
|
||||||
if (member.kind === 'method')
|
|
||||||
return createMarkdownLink(member, `${className}${member.alias}(${this.renderJSSignature(member.argsArray)})`);
|
|
||||||
if (member.kind === 'event')
|
|
||||||
return createMarkdownLink(member, `${className}on('${member.alias.toLowerCase()}')`);
|
|
||||||
if (member.kind === 'property')
|
|
||||||
return createMarkdownLink(member, `${className}${member.alias}`);
|
|
||||||
throw new Error('Unknown member kind ' + member.kind);
|
|
||||||
});
|
|
||||||
this.documentation.setCodeGroupsTransformer('js', tabs => tabs.filter(tab => tab.value === 'ts').map(tab => tab.spec));
|
this.documentation.setCodeGroupsTransformer('js', tabs => tabs.filter(tab => tab.value === 'ts').map(tab => tab.spec));
|
||||||
this.documentation.generateSourceCodeComments();
|
this.documentation.generateSourceCodeComments();
|
||||||
|
|
||||||
@ -371,9 +344,7 @@ class TypesGenerator {
|
|||||||
pushLine(line);
|
pushLine(line);
|
||||||
}
|
}
|
||||||
comment = out.join('\n');
|
comment = out.join('\n');
|
||||||
comment = comment.replace(/\[([^\]]+)\]\((\.[^\)]+)\)/g, (match, p1, p2) => {
|
comment = renderPlaywrightDevLinks(comment, '', '/api');
|
||||||
return `[${p1}](${new URL(p2.replace('.md', ''), 'https://playwright.dev/docs/api/').toString()})`;
|
|
||||||
});
|
|
||||||
|
|
||||||
parts.push(indent + '/**');
|
parts.push(indent + '/**');
|
||||||
parts.push(...comment.split('\n').map(line => indent + ' * ' + line.replace(/\*\//g, '*\\/')));
|
parts.push(...comment.split('\n').map(line => indent + ' * ' + line.replace(/\*\//g, '*\\/')));
|
||||||
@ -489,33 +460,6 @@ class TypesGenerator {
|
|||||||
return indent;
|
return indent;
|
||||||
return this.writeComment(lines.join('\n'), indent) + '\n' + indent;
|
return this.writeComment(lines.join('\n'), indent) + '\n' + indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {docs.Member[]} args
|
|
||||||
*/
|
|
||||||
renderJSSignature(args) {
|
|
||||||
const tokens = [];
|
|
||||||
let hasOptional = false;
|
|
||||||
for (const arg of args) {
|
|
||||||
const name = arg.alias;
|
|
||||||
const optional = !arg.required;
|
|
||||||
if (tokens.length) {
|
|
||||||
if (optional && !hasOptional)
|
|
||||||
tokens.push(`[, ${name}`);
|
|
||||||
else
|
|
||||||
tokens.push(`, ${name}`);
|
|
||||||
} else {
|
|
||||||
if (optional && !hasOptional)
|
|
||||||
tokens.push(`[${name}`);
|
|
||||||
else
|
|
||||||
tokens.push(`${name}`);
|
|
||||||
}
|
|
||||||
hasOptional = hasOptional || optional;
|
|
||||||
}
|
|
||||||
if (hasOptional)
|
|
||||||
tokens.push(']');
|
|
||||||
return tokens.join('');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(async function () {
|
(async function () {
|
||||||
|
|||||||
76
utils/render_release_notes.mjs
Normal file
76
utils/render_release_notes.mjs
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Microsoft Corporation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
import { parseApi } from './doclint/api_parser.js';
|
||||||
|
import md, { visitAll } from './markdown.js';
|
||||||
|
import { renderPlaywrightDevLinks, docsLinkRendererForLanguage, languageToRelativeDocsPath } from './doclint/linkUtils.js';
|
||||||
|
|
||||||
|
const __dirname = new URL('.', import.meta.url).pathname;
|
||||||
|
|
||||||
|
const PROJECT_DIR = path.join(__dirname, '..');
|
||||||
|
const documentationRoot = path.join(PROJECT_DIR, 'docs', 'src');
|
||||||
|
|
||||||
|
const allowedLanguages = ['js', 'python', 'csharp', 'java'];
|
||||||
|
const [, , language, version] = process.argv;
|
||||||
|
|
||||||
|
if (!allowedLanguages.includes(language) || !version.match(/^\d+\.\d+$/))
|
||||||
|
throw new Error(`Usage: node ${path.basename(process.argv[1])} <language> <version>\n\nWhere <version> is a version tag without v prefix, e.g. 1.45`);
|
||||||
|
|
||||||
|
let documentation = parseApi(path.join(documentationRoot, 'api'));
|
||||||
|
if (language === 'js') {
|
||||||
|
documentation = documentation
|
||||||
|
.mergeWith(parseApi(path.join(documentationRoot, 'test-api'), path.join(documentationRoot, 'api', 'params.md')))
|
||||||
|
.mergeWith(parseApi(path.join(documentationRoot, 'test-reporter-api')));
|
||||||
|
}
|
||||||
|
|
||||||
|
documentation.setLinkRenderer(docsLinkRendererForLanguage(language));
|
||||||
|
const content = fs.readFileSync(path.join(documentationRoot, `release-notes-${language}.md`)).toString();
|
||||||
|
let nodes = md.parse(content);
|
||||||
|
documentation.renderLinksInNodes(nodes);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Reduce by one heading level
|
||||||
|
visitAll(nodes, node => {
|
||||||
|
if (node.type === 'h4')
|
||||||
|
node.type = 'h3';
|
||||||
|
else if (node.type === 'h3')
|
||||||
|
node.type = 'h2';
|
||||||
|
else if (node.type === 'h2')
|
||||||
|
node.type = 'h1';
|
||||||
|
else if (node.type === 'h1')
|
||||||
|
node.type = 'h0';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the version heading and use it as a starting point in the output.
|
||||||
|
{
|
||||||
|
let foundVersion = false;
|
||||||
|
visitAll(nodes, node => {
|
||||||
|
if (node.type === 'h1' && node.text === `Version ${version}`) {
|
||||||
|
nodes = node.children;
|
||||||
|
foundVersion = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!foundVersion)
|
||||||
|
throw new Error(`Could not find version ${version} in release notes.\nUsage: node ${path.basename(process.argv[1])} <language> <version>\n\nWhere <version> is a version tag without v prefix, e.g. 1.45`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = renderPlaywrightDevLinks(md.render(nodes), languageToRelativeDocsPath(language), '');
|
||||||
|
process.stdout.write(output);
|
||||||
Loading…
x
Reference in New Issue
Block a user