Skip to content

Commit

Permalink
docs: inline superclass toc into classes for convenience (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored and yury-s committed Jan 27, 2020
1 parent c850430 commit 5a5016f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,15 @@ ElementHandle instances can be used as arguments in [`page.$eval()`](#pageevalse
- [elementHandle.type(text[, options])](#elementhandletypetext-options)
- [elementHandle.visibleRatio()](#elementhandlevisibleratio)
<!-- GEN:stop -->
<!-- GEN:toc-extends-JSHandle -->
- [jsHandle.asElement()](#jshandleaselement)
- [jsHandle.dispose()](#jshandledispose)
- [jsHandle.evaluate(pageFunction[, ...args])](#jshandleevaluatepagefunction-args)
- [jsHandle.evaluateHandle(pageFunction[, ...args])](#jshandleevaluatehandlepagefunction-args)
- [jsHandle.getProperties()](#jshandlegetproperties)
- [jsHandle.getProperty(propertyName)](#jshandlegetpropertypropertyname)
- [jsHandle.jsonValue()](#jshandlejsonvalue)
<!-- GEN:stop -->

#### elementHandle.$(selector)
- `selector` <[string]> A selector to query element for
Expand Down Expand Up @@ -3468,6 +3477,15 @@ await browser.stopTracing();
- [chromiumBrowser.targets(context)](#chromiumbrowsertargetscontext)
- [chromiumBrowser.waitForTarget(predicate[, options])](#chromiumbrowserwaitfortargetpredicate-options)
<!-- GEN:stop -->
<!-- GEN:toc-extends-Browser -->
- [event: 'disconnected'](#event-disconnected)
- [browser.browserContexts()](#browserbrowsercontexts)
- [browser.close()](#browserclose)
- [browser.defaultContext()](#browserdefaultcontext)
- [browser.disconnect()](#browserdisconnect)
- [browser.isConnected()](#browserisconnected)
- [browser.newContext(options)](#browsernewcontextoptions)
<!-- GEN:stop -->

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

Firefox browser instance does not expose Firefox-specific features.

<!-- GEN:toc-extends-Browser -->
- [event: 'disconnected'](#event-disconnected)
- [browser.browserContexts()](#browserbrowsercontexts)
- [browser.close()](#browserclose)
- [browser.defaultContext()](#browserdefaultcontext)
- [browser.disconnect()](#browserdisconnect)
- [browser.isConnected()](#browserisconnected)
- [browser.newContext(options)](#browsernewcontextoptions)
<!-- GEN:stop -->

### class: WebKitBrowser

* extends: [Browser]

WebKit browser instance does not expose WebKit-specific features.

<!-- GEN:toc-extends-Browser -->
- [event: 'disconnected'](#event-disconnected)
- [browser.browserContexts()](#browserbrowsercontexts)
- [browser.close()](#browserclose)
- [browser.defaultContext()](#browserdefaultcontext)
- [browser.disconnect()](#browserdisconnect)
- [browser.isConnected()](#browserisconnected)
- [browser.newContext(options)](#browsernewcontextoptions)
<!-- GEN:stop -->

### Working with selectors

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).
Expand Down
14 changes: 14 additions & 0 deletions utils/doclint/preprocessor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ module.exports.runCommands = function(sources, version) {
newText = generateTableOfContents(command.source.text(), command.to, false /* topLevelOnly */);
else if (command.name === 'toc-top-level')
newText = generateTableOfContents(command.source.text(), command.to, true /* topLevelOnly */);
else if (command.name.startsWith('toc-extends-'))
newText = generateTableOfContentsForSuperclass(command.source.text(), 'class: ' + command.name.substring('toc-extends-'.length));
if (newText === null)
messages.push(Message.error(`Unknown command 'gen:${command.name}'`));
else if (applyCommand(command, newText))
Expand Down Expand Up @@ -152,3 +154,15 @@ function generateTableOfContents(text, offset, topLevelOnly) {
return `${padding}${prefix} [${entry.name}](#${entry.id})`;
}).join('\n') + '\n';
}

function generateTableOfContentsForSuperclass(text, name) {
const allTocEntries = getTOCEntriesForText(text);

for (const tocEntry of allTocEntries) {
if (tocEntry.name !== name)
continue;
const offset = text.indexOf('<!-- GEN:stop -->', tocEntry.offset);
return generateTableOfContents(text, offset, false);
}
return text;
}

0 comments on commit 5a5016f

Please sign in to comment.