This PR cherry-picks the following commits:
- 599ae30313
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
6eec55cffd
commit
b8b1c40cf3
|
|
@ -638,28 +638,11 @@ Optional response body as raw bytes.
|
||||||
|
|
||||||
### option: Route.fulfill.json
|
### option: Route.fulfill.json
|
||||||
* since: v1.29
|
* since: v1.29
|
||||||
* langs: js, python
|
* langs: js, python, csharp
|
||||||
- `json` <[Serializable]>
|
- `json` <[Serializable]>
|
||||||
|
|
||||||
JSON response. This method will set the content type to `application/json` if not set.
|
JSON response. This method will set the content type to `application/json` if not set.
|
||||||
|
|
||||||
### option: Route.fulfill.json
|
|
||||||
* since: v1.29
|
|
||||||
* langs: csharp
|
|
||||||
- `json` <[JsonElement]>
|
|
||||||
|
|
||||||
JSON response. This method will set the content type to `application/json` if not set.
|
|
||||||
|
|
||||||
**Usage**
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
await page.RouteAsync("https://dog.ceo/api/breeds/list/all", async route =>
|
|
||||||
{
|
|
||||||
var json = /* JsonElement with test payload */;
|
|
||||||
await route.FulfillAsync(new () { Json: json });
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### option: Route.fulfill.path
|
### option: Route.fulfill.path
|
||||||
* since: v1.8
|
* since: v1.8
|
||||||
- `path` <[path]>
|
- `path` <[path]>
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ function _wrapAndEscape(node, maxColumns = 0) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let text = node.text;
|
let text = (node.text || '').replace(/↵/g, ' ');
|
||||||
text = text.replace(/\[([^\]]*)\]\((.*?)\)/g, (match, linkName, linkUrl) => {
|
text = text.replace(/\[([^\]]*)\]\((.*?)\)/g, (match, linkName, linkUrl) => {
|
||||||
const isInternal = !linkUrl.startsWith('http://') && !linkUrl.startsWith('https://');
|
const isInternal = !linkUrl.startsWith('http://') && !linkUrl.startsWith('https://');
|
||||||
if (isInternal)
|
if (isInternal)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ const fs = require('fs');
|
||||||
const { parseApi } = require('./api_parser');
|
const { parseApi } = require('./api_parser');
|
||||||
const { Type } = require('./documentation');
|
const { Type } = require('./documentation');
|
||||||
const { EOL } = require('os');
|
const { EOL } = require('os');
|
||||||
const { execSync } = require('child_process');
|
|
||||||
|
|
||||||
const maxDocumentationColumnWidth = 80;
|
const maxDocumentationColumnWidth = 80;
|
||||||
Error.stackTraceLimit = 100;
|
Error.stackTraceLimit = 100;
|
||||||
|
|
@ -91,10 +90,10 @@ classNameMap.set('Readable', 'Stream');
|
||||||
*
|
*
|
||||||
* @param {string} kind
|
* @param {string} kind
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @param {Documentation.MarkdownNode[]} spec
|
* @param {Documentation.MarkdownNode[]|null} spec
|
||||||
* @param {string[]} body
|
* @param {string[]} body
|
||||||
* @param {string} folder
|
* @param {string} folder
|
||||||
* @param {string} extendsName
|
* @param {string|null} extendsName
|
||||||
*/
|
*/
|
||||||
function writeFile(kind, name, spec, body, folder, extendsName = null) {
|
function writeFile(kind, name, spec, body, folder, extendsName = null) {
|
||||||
const out = [];
|
const out = [];
|
||||||
|
|
@ -144,10 +143,19 @@ function renderClass(clazz) {
|
||||||
renderMember(member, clazz, {}, body);
|
renderMember(member, clazz, {}, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type {Documentation.MarkdownNode[]} */
|
||||||
|
const spec = [];
|
||||||
|
if (clazz.deprecated)
|
||||||
|
spec.push({ type: 'text', text: '**DEPRECATED** ' + clazz.deprecated });
|
||||||
|
if (clazz.discouraged)
|
||||||
|
spec.push({ type: 'text', text: clazz.discouraged });
|
||||||
|
if (clazz.spec)
|
||||||
|
spec.push(...clazz.spec);
|
||||||
|
|
||||||
writeFile(
|
writeFile(
|
||||||
'public partial interface',
|
'public partial interface',
|
||||||
name,
|
name,
|
||||||
clazz.spec,
|
spec,
|
||||||
body,
|
body,
|
||||||
apiDir,
|
apiDir,
|
||||||
clazz.extends ? `I${toTitleCase(clazz.extends)}` : null);
|
clazz.extends ? `I${toTitleCase(clazz.extends)}` : null);
|
||||||
|
|
@ -278,7 +286,22 @@ function renderConstructors(name, type, out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param {Documentation.Member} member
|
||||||
|
* @param {string[]} out
|
||||||
|
*/
|
||||||
|
function renderMemberDoc(member, out) {
|
||||||
|
/** @type {Documentation.MarkdownNode[]} */
|
||||||
|
const nodes = [];
|
||||||
|
if (member.deprecated)
|
||||||
|
nodes.push({ type: 'text', text: '**DEPRECATED** ' + member.deprecated });
|
||||||
|
if (member.discouraged)
|
||||||
|
nodes.push({ type: 'text', text: member.discouraged });
|
||||||
|
if (member.spec)
|
||||||
|
nodes.push(...member.spec);
|
||||||
|
out.push(...XmlDoc.renderXmlDoc(nodes, maxDocumentationColumnWidth));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @param {Documentation.Member} member
|
* @param {Documentation.Member} member
|
||||||
* @param {Documentation.Class|Documentation.Type} parent
|
* @param {Documentation.Class|Documentation.Type} parent
|
||||||
* @param {{nojson?: boolean, trimRunAndPrefix?: boolean}} options
|
* @param {{nojson?: boolean, trimRunAndPrefix?: boolean}} options
|
||||||
|
|
@ -296,8 +319,7 @@ function renderMember(member, parent, options, out) {
|
||||||
if (!member.type)
|
if (!member.type)
|
||||||
throw new Error(`No Event Type for ${name} in ${parent.name}`);
|
throw new Error(`No Event Type for ${name} in ${parent.name}`);
|
||||||
out.push('');
|
out.push('');
|
||||||
if (member.spec)
|
renderMemberDoc(member, out);
|
||||||
out.push(...XmlDoc.renderXmlDoc(member.spec, maxDocumentationColumnWidth));
|
|
||||||
if (member.deprecated)
|
if (member.deprecated)
|
||||||
out.push(`[System.Obsolete]`);
|
out.push(`[System.Obsolete]`);
|
||||||
out.push(`event EventHandler<${type}> ${name};`);
|
out.push(`event EventHandler<${type}> ${name};`);
|
||||||
|
|
@ -314,8 +336,7 @@ function renderMember(member, parent, options, out) {
|
||||||
const { name, jsonName } = overload;
|
const { name, jsonName } = overload;
|
||||||
let { type } = overload;
|
let { type } = overload;
|
||||||
out.push('');
|
out.push('');
|
||||||
if (member.spec)
|
renderMemberDoc(member, out);
|
||||||
out.push(...XmlDoc.renderXmlDoc(member.spec, maxDocumentationColumnWidth));
|
|
||||||
if (!member.clazz)
|
if (!member.clazz)
|
||||||
out.push(`${member.required ? '[Required]\n' : ''}[JsonPropertyName("${jsonName}")]`);
|
out.push(`${member.required ? '[Required]\n' : ''}[JsonPropertyName("${jsonName}")]`);
|
||||||
if (member.deprecated)
|
if (member.deprecated)
|
||||||
|
|
@ -623,7 +644,7 @@ function renderMethod(member, parent, name, options, out) {
|
||||||
|
|
||||||
if (!explodedArgs.length) {
|
if (!explodedArgs.length) {
|
||||||
if (!options.nodocs) {
|
if (!options.nodocs) {
|
||||||
out.push(...XmlDoc.renderXmlDoc(member.spec, maxDocumentationColumnWidth));
|
renderMemberDoc(member, out);
|
||||||
paramDocs.forEach((value, i) => printArgDoc(i, value, out));
|
paramDocs.forEach((value, i) => printArgDoc(i, value, out));
|
||||||
}
|
}
|
||||||
if (member.deprecated)
|
if (member.deprecated)
|
||||||
|
|
@ -633,7 +654,7 @@ function renderMethod(member, parent, name, options, out) {
|
||||||
let containsOptionalExplodedArgs = false;
|
let containsOptionalExplodedArgs = false;
|
||||||
explodedArgs.forEach((explodedArg, argIndex) => {
|
explodedArgs.forEach((explodedArg, argIndex) => {
|
||||||
if (!options.nodocs)
|
if (!options.nodocs)
|
||||||
out.push(...XmlDoc.renderXmlDoc(member.spec, maxDocumentationColumnWidth));
|
renderMemberDoc(member, out);
|
||||||
const overloadedArgs = [];
|
const overloadedArgs = [];
|
||||||
for (let i = 0; i < args.length; i++) {
|
for (let i = 0; i < args.length; i++) {
|
||||||
const arg = args[i];
|
const arg = args[i];
|
||||||
|
|
@ -662,7 +683,7 @@ function renderMethod(member, parent, name, options, out) {
|
||||||
if (containsOptionalExplodedArgs) {
|
if (containsOptionalExplodedArgs) {
|
||||||
const filteredArgs = args.filter(x => x !== 'OPTIONAL_EXPLODED_ARG');
|
const filteredArgs = args.filter(x => x !== 'OPTIONAL_EXPLODED_ARG');
|
||||||
if (!options.nodocs)
|
if (!options.nodocs)
|
||||||
out.push(...XmlDoc.renderXmlDoc(member.spec, maxDocumentationColumnWidth));
|
renderMemberDoc(member, out);
|
||||||
filteredArgs.forEach(arg => {
|
filteredArgs.forEach(arg => {
|
||||||
if (arg === 'EXPLODED_ARG')
|
if (arg === 'EXPLODED_ARG')
|
||||||
throw new Error(`Unsupported required union arg combined an optional union inside ${member.name}`);
|
throw new Error(`Unsupported required union arg combined an optional union inside ${member.name}`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue