Skip to content

Commit 5a5016f

Browse files
pavelfeldmanyury-s
authored andcommitted
docs: inline superclass toc into classes for convenience (#663)
1 parent c850430 commit 5a5016f

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

docs/api.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,15 @@ ElementHandle instances can be used as arguments in [`page.$eval()`](#pageevalse
675675
- [elementHandle.type(text[, options])](#elementhandletypetext-options)
676676
- [elementHandle.visibleRatio()](#elementhandlevisibleratio)
677677
<!-- GEN:stop -->
678+
<!-- GEN:toc-extends-JSHandle -->
679+
- [jsHandle.asElement()](#jshandleaselement)
680+
- [jsHandle.dispose()](#jshandledispose)
681+
- [jsHandle.evaluate(pageFunction[, ...args])](#jshandleevaluatepagefunction-args)
682+
- [jsHandle.evaluateHandle(pageFunction[, ...args])](#jshandleevaluatehandlepagefunction-args)
683+
- [jsHandle.getProperties()](#jshandlegetproperties)
684+
- [jsHandle.getProperty(propertyName)](#jshandlegetpropertypropertyname)
685+
- [jsHandle.jsonValue()](#jshandlejsonvalue)
686+
<!-- GEN:stop -->
678687

679688
#### elementHandle.$(selector)
680689
- `selector` <[string]> A selector to query element for
@@ -3468,6 +3477,15 @@ await browser.stopTracing();
34683477
- [chromiumBrowser.targets(context)](#chromiumbrowsertargetscontext)
34693478
- [chromiumBrowser.waitForTarget(predicate[, options])](#chromiumbrowserwaitfortargetpredicate-options)
34703479
<!-- GEN:stop -->
3480+
<!-- GEN:toc-extends-Browser -->
3481+
- [event: 'disconnected'](#event-disconnected)
3482+
- [browser.browserContexts()](#browserbrowsercontexts)
3483+
- [browser.close()](#browserclose)
3484+
- [browser.defaultContext()](#browserdefaultcontext)
3485+
- [browser.disconnect()](#browserdisconnect)
3486+
- [browser.isConnected()](#browserisconnected)
3487+
- [browser.newContext(options)](#browsernewcontextoptions)
3488+
<!-- GEN:stop -->
34713489

34723490
#### event: 'targetchanged'
34733491
- <[Target]>
@@ -3626,12 +3644,32 @@ Identifies what kind of target this is. Can be `"page"`, [`"background_page"`](h
36263644

36273645
Firefox browser instance does not expose Firefox-specific features.
36283646

3647+
<!-- GEN:toc-extends-Browser -->
3648+
- [event: 'disconnected'](#event-disconnected)
3649+
- [browser.browserContexts()](#browserbrowsercontexts)
3650+
- [browser.close()](#browserclose)
3651+
- [browser.defaultContext()](#browserdefaultcontext)
3652+
- [browser.disconnect()](#browserdisconnect)
3653+
- [browser.isConnected()](#browserisconnected)
3654+
- [browser.newContext(options)](#browsernewcontextoptions)
3655+
<!-- GEN:stop -->
3656+
36293657
### class: WebKitBrowser
36303658

36313659
* extends: [Browser]
36323660

36333661
WebKit browser instance does not expose WebKit-specific features.
36343662

3663+
<!-- GEN:toc-extends-Browser -->
3664+
- [event: 'disconnected'](#event-disconnected)
3665+
- [browser.browserContexts()](#browserbrowsercontexts)
3666+
- [browser.close()](#browserclose)
3667+
- [browser.defaultContext()](#browserdefaultcontext)
3668+
- [browser.disconnect()](#browserdisconnect)
3669+
- [browser.isConnected()](#browserisconnected)
3670+
- [browser.newContext(options)](#browsernewcontextoptions)
3671+
<!-- GEN:stop -->
3672+
36353673
### Working with selectors
36363674

36373675
Selector describes an element in the page. It can be used to obtain `ElementHandle` (see [page.$()](#pageselector) for example) or shortcut element operations to avoid intermediate handle (see [page.click()](#pageclickselector-options) for example).

utils/doclint/preprocessor/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ module.exports.runCommands = function(sources, version) {
7272
newText = generateTableOfContents(command.source.text(), command.to, false /* topLevelOnly */);
7373
else if (command.name === 'toc-top-level')
7474
newText = generateTableOfContents(command.source.text(), command.to, true /* topLevelOnly */);
75+
else if (command.name.startsWith('toc-extends-'))
76+
newText = generateTableOfContentsForSuperclass(command.source.text(), 'class: ' + command.name.substring('toc-extends-'.length));
7577
if (newText === null)
7678
messages.push(Message.error(`Unknown command 'gen:${command.name}'`));
7779
else if (applyCommand(command, newText))
@@ -152,3 +154,15 @@ function generateTableOfContents(text, offset, topLevelOnly) {
152154
return `${padding}${prefix} [${entry.name}](#${entry.id})`;
153155
}).join('\n') + '\n';
154156
}
157+
158+
function generateTableOfContentsForSuperclass(text, name) {
159+
const allTocEntries = getTOCEntriesForText(text);
160+
161+
for (const tocEntry of allTocEntries) {
162+
if (tocEntry.name !== name)
163+
continue;
164+
const offset = text.indexOf('<!-- GEN:stop -->', tocEntry.offset);
165+
return generateTableOfContents(text, offset, false);
166+
}
167+
return text;
168+
}

0 commit comments

Comments
 (0)