(sidebars: any)
| 27 | * @param {object} sidebars website/sidebars |
| 28 | */ |
| 29 | export function generateProtocolDocs (sidebars: any) { |
| 30 | fs.mkdir(API_DOCS_ROOT_DIR, { recursive: true }, (err) => console.error(err)) |
| 31 | const protocolDocs: any = {} |
| 32 | |
| 33 | const protocolDocEntry = { |
| 34 | type: 'category', |
| 35 | label: 'Protocols', |
| 36 | link: { |
| 37 | type: 'doc', |
| 38 | id: 'api/protocols' |
| 39 | }, |
| 40 | items: [] as any[] |
| 41 | } |
| 42 | |
| 43 | for (const [protocolName, definition] of Object.entries(PROTOCOLS)) { |
| 44 | const protocol = PROTOCOL_NAMES[protocolName as unknown as keyof typeof PROTOCOL_NAMES] as string |
| 45 | |
| 46 | for (const [, methods] of Object.entries(definition)) { |
| 47 | for (const [, description] of Object.entries(methods) as any) { |
| 48 | description.paramTags = [...(description.variables || []).map((variable: any) => { |
| 49 | return Object.assign(variable, { required: true, type: 'String' }) |
| 50 | }), ...description.parameters || []] |
| 51 | |
| 52 | description.hasHeader = true |
| 53 | description.paramString = description.paramTags.map((param: any) => param.name).join(', ') |
| 54 | description.examples = (description.examples || []).map((example: any) => { |
| 55 | return { |
| 56 | code: Array.isArray(example) ? example.join('\n') : example, |
| 57 | format: 'js' |
| 58 | } |
| 59 | }) |
| 60 | description.returnTags = [] // tbd |
| 61 | description.throwsTags = [] // tbd |
| 62 | description.exampleReferences = description.exampleReferences || [] |
| 63 | description.isMobile = MOBILE_PROTOCOLS.includes(protocolName) |
| 64 | description.customEditUrl = `${repoUrl}/edit/main/packages/wdio-protocols/src/protocols/${protocolName}.ts` |
| 65 | |
| 66 | let protocolNote |
| 67 | if (VENDOR_PROTOCOLS.includes(protocolName)) { |
| 68 | protocolNote = `Non official and undocumented ${protocol} command.` |
| 69 | if (description.ref) { |
| 70 | protocolNote += ` More about this command can be found [here](${description.ref}).` |
| 71 | } |
| 72 | } else { |
| 73 | protocolNote = `${protocol} command. More details can be found in the [official protocol docs](${description.ref}).` |
| 74 | } |
| 75 | |
| 76 | if (description.description) { |
| 77 | description.description += `<br /><br />${protocolNote}` |
| 78 | } else { |
| 79 | description.description = protocolNote |
| 80 | } |
| 81 | |
| 82 | if (description.deprecated) { |
| 83 | description.deprecated = `This protocol command is deprecated<br />${description.deprecated}` |
| 84 | } |
| 85 | |
| 86 | const markdown = eta.render('./template', { ...description, path }) |
no test coverage detected
searching dependent graphs…