docs-parser icon indicating copy to clipboard operation
docs-parser copied to clipboard

[Bug]: [Electron.d.ts][gn-typescript-definitions][Invalid type annotations] Electron.PrintToPDFOptions > Margins

Open eezz4 opened this issue 1 year ago • 2 comments

Preflight Checklist

Electron Version

28.1.2

What operating system are you using?

Windows

Operating System Version

all

What arch are you using?

x64

Last Known Working Electron version

~28.1.2~

Expected Behavior

Electron.PrintToPDFOptions > Margins

web-contents.md, webview-tag.md file

#### `contents.print([options], [callback])`
### `<webview>.print([options])`
* `options` Object (optional)
  * `margins` Object (optional)
    * `marginType` string (optional) - Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen, you will also need to specify `top`, `bottom`, `left`, and `right`.
    * `top` number (optional) - The top margin of the printed web page, in pixels.
    * `bottom` number (optional) - The bottom margin of the printed web page, in pixels.
    * `left` number (optional) - The left margin of the printed web page, in pixels.
    * `right` number (optional) - The right margin of the printed web page, in pixels.
#### `contents.printToPDF(options)`
### `<webview>.printToPDF(options)`
* `options` Object
  * `marginsToPDF` Object (optional)
    * `top` number (optional) - Top margin in inches. Defaults to 1cm (~0.4 inches).
    * `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
    * `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
    * `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).

Actual Behavior

The docs are different, the gn-typescript-definitions script only creates one 'Margins'.

  interface WebContentsPrintOptions {
    ...
    margins?: Margins;
    ...
  }
  interface PrintToPDFOptions {
    ...
    margins?: Margins;
    ...
  }
  interface WebviewTagPrintOptions {
    ...
    margins?: Margins;
    ...
  }

  interface Margins {
    /**
     * Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
     * you will also need to specify `top`, `bottom`, `left`, and `right`.
     */
    marginType?: ('default' | 'none' | 'printableArea' | 'custom');
    /**
     * The top margin of the printed web page, in pixels.
     */
    top?: number;
    /**
     * The bottom margin of the printed web page, in pixels.
     */
    bottom?: number;
    /**
     * The left margin of the printed web page, in pixels.
     */
    left?: number;
    /**
     * The right margin of the printed web page, in pixels.
     */
    right?: number;
  }

Testcase Gist URL

No response

Additional Information

No response

eezz4 avatar Jan 20 '24 11:01 eezz4

@eezz4 the issue originates here so i've gone ahead and transferred it. Just to confirm - you put the erring version as 28.1.2 and the last working version as 28.1.2; they shouldn't be the same as one indicates the last version it worked and one the verrsion it's not working. Did this ever generate expected documentation?

codebytere avatar Jan 29 '24 14:01 codebytere

@codebytere

Sorry, I was wrong about the Last Known Working Electron version!

When I analyzed the gn-typescript-definitions script, it seems to be parsing the doc to create electron.d.ts.

It appears that docs-parser doesn't support this case of duplication.

eezz4 avatar Jan 29 '24 15:01 eezz4