Skip to content

Commit

Permalink
chore: clean up pre-build scripts and content (#704)
Browse files Browse the repository at this point in the history
q
  • Loading branch information
erickzhao authored Dec 11, 2024
1 parent c11a8bf commit d13d1e7
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 91 deletions.
6 changes: 3 additions & 3 deletions docs/latest/api/base-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const child = new BaseWindow({ parent, modal: true })

## Resource management

When you add a [`WebContentsView`](latest/api/web-contents-view.md) to a `BaseWindow` and the `BaseWindow`
is closed, the [`webContents`](latest/api/web-contents.md) of the `WebContentsView` are not destroyed
When you add a [`WebContentsView`](web-contents-view.md) to a `BaseWindow` and the `BaseWindow`
is closed, the [`webContents`](web-contents.md) of the `WebContentsView` are not destroyed
automatically.

It is your responsibility to close the `webContents` when you no longer need them, e.g. when
Expand All @@ -93,7 +93,7 @@ win.on('closed', () => {
})
```

Unlike with a [`BrowserWindow`](latest/api/browser-window.md), if you don't explicitly close the
Unlike with a [`BrowserWindow`](browser-window.md), if you don't explicitly close the
`webContents`, you'll encounter memory leaks.

## Class: BaseWindow
Expand Down
2 changes: 1 addition & 1 deletion docs/latest/api/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Pops up this menu as a context menu in the [`BaseWindow`](base-window.md).

#### `menu.closePopup([window])`

* `browserWindow` [BaseWindow](base-window.md) (optional) - Default is the focused window.
* `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.

Closes the context menu in the `window`.

Expand Down
4 changes: 2 additions & 2 deletions docs/latest/api/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The `session` module has the following methods:
* `partition` string
* `options` Object (optional)
* `cache` boolean - Whether to enable cache. Default is `true` unless the
[`--disable-http-cache` switch](latest/api/command-line-switches.md#--disable-http-cache) is used.
[`--disable-http-cache` switch](command-line-switches.md#--disable-http-cache) is used.

Returns `Session` - A session instance from `partition` string. When there is an existing
`Session` with the same `partition`, it will be returned; otherwise a new
Expand All @@ -55,7 +55,7 @@ of an existing `Session` object.
* `path` string
* `options` Object (optional)
* `cache` boolean - Whether to enable cache. Default is `true` unless the
[`--disable-http-cache` switch](latest/api/command-line-switches.md#--disable-http-cache) is used.
[`--disable-http-cache` switch](command-line-switches.md#--disable-http-cache) is used.

Returns `Session` - A session instance from the absolute path as specified by the `path`
string. When there is an existing `Session` with the same absolute path, it
Expand Down
53 changes: 0 additions & 53 deletions scripts/process-posts.ts

This file was deleted.

31 changes: 1 addition & 30 deletions scripts/tasks/md-fixers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,12 @@ import path from 'node:path';

import globby from 'globby';

/**
* RegExp use to match the old markdown format for fiddle
* in `fiddleTransformer`.
*/
const fiddleRegex = /^```javascript fiddle='docs\/(\S+)?'$/;
const fiddlePathFixRegex = /```fiddle docs\//;

/**
* Updates the markdown fiddle format from:
* ```
* ```javascript fiddle='docs/fiddles/screen/fit-screen'
* ```
* To
* ```
* ```fiddle docs/latest/fiddles/example
* ```
* @param line
*/
const fiddleTransformer = (line: string) => {
const matches = fiddleRegex.exec(line);
const hasNewPath = fiddlePathFixRegex.test(line);

if (matches) {
return `\`\`\`fiddle docs/latest/${matches[1]}`;
} else if (hasNewPath) {
if (hasNewPath) {
return (
line
.replace(fiddlePathFixRegex, '```fiddle docs/latest/')
Expand Down Expand Up @@ -145,16 +126,6 @@ export const fixContent = async (root: string, version = 'latest') => {
cwd: root,
});

/**
* Filenames in Electron docs are usually unique so best effort
* consist on using the filename (basename) to identify the right
* place where it should point.
*/
const linksMaps = new Map();
for (const filePath of files) {
linksMaps.set(path.basename(filePath), filePath);
}

for (const filePath of files) {
const fullFilePath = path.join(root, filePath);
const content = await fs.readFile(fullFilePath, 'utf-8');
Expand Down
2 changes: 0 additions & 2 deletions src/components/APIStructurePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import clsx from 'clsx';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import usePortal from 'react-useportal';
import { toHtml } from 'hast-util-to-html';
import { toHast } from 'mdast-util-to-hast';
import { sanitize } from 'hast-util-sanitize';

import styles from './APIStructurePreview.module.scss';

Expand Down

0 comments on commit d13d1e7

Please sign in to comment.