fullproject support
This commit is contained in:
parent
dcb12a29b4
commit
30c3115bfe
93
docs/src/test-api/class-fullproject.md
Normal file
93
docs/src/test-api/class-fullproject.md
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
# class: FullProject
|
||||
* since: v1.10
|
||||
* langs: js
|
||||
|
||||
## property: FullProject.dependencies
|
||||
* since: v1.31
|
||||
- type: ?<[Array]<[string]>>
|
||||
|
||||
See [`property: TestProject.dependencies`].
|
||||
|
||||
## property: FullProject.grep
|
||||
* since: v1.10
|
||||
- type: ?<[RegExp]|[Array]<[RegExp]>>
|
||||
|
||||
See [`property: TestProject.grep`].
|
||||
|
||||
## property: FullProject.grepInvert
|
||||
* since: v1.10
|
||||
- type: ?<[RegExp]|[Array]<[RegExp]>>
|
||||
|
||||
See [`property: TestProject.grepInvert`].
|
||||
|
||||
## property: FullProject.metadata
|
||||
* since: v1.10
|
||||
- type: ?<[Metadata]>
|
||||
|
||||
See [`property: TestProject.metadata`].
|
||||
|
||||
## property: FullProject.name
|
||||
* since: v1.10
|
||||
- type: ?<[string]>
|
||||
|
||||
See [`property: TestProject.name`].
|
||||
|
||||
## property: FullProject.snapshotDir
|
||||
* since: v1.10
|
||||
- type: ?<[string]>
|
||||
|
||||
See [`property: TestProject.snapshotDir`].
|
||||
|
||||
## property: FullProject.outputDir
|
||||
* since: v1.10
|
||||
- type: ?<[string]>
|
||||
|
||||
See [`property: TestProject.outputDir`].
|
||||
|
||||
## property: FullProject.repeatEach
|
||||
* since: v1.10
|
||||
- type: ?<[int]>
|
||||
|
||||
See [`property: TestProject.repeatEach`].
|
||||
|
||||
## property: FullProject.retries
|
||||
* since: v1.10
|
||||
- type: ?<[int]>
|
||||
|
||||
See [`property: TestProject.retries`].
|
||||
|
||||
## property: FullProject.teardown
|
||||
* since: v1.34
|
||||
- type: ?<[string]>
|
||||
|
||||
See [`property: TestProject.teardown`].
|
||||
|
||||
## property: FullProject.testDir
|
||||
* since: v1.10
|
||||
- type: ?<[string]>
|
||||
|
||||
See [`property: TestProject.testDir`].
|
||||
|
||||
## property: FullProject.testIgnore
|
||||
* since: v1.10
|
||||
- type: ?<[string]|[RegExp]|[Array]<[string]|[RegExp]>>
|
||||
|
||||
See [`property: TestProject.testIgnore`].
|
||||
|
||||
## property: FullProject.testMatch
|
||||
* since: v1.10
|
||||
- type: ?<[string]|[RegExp]|[Array]<[string]|[RegExp]>>
|
||||
|
||||
See [`property: TestProject.testMatch`].
|
||||
|
||||
## property: FullProject.timeout
|
||||
* since: v1.10
|
||||
- type: ?<[int]>
|
||||
|
||||
See [`property: TestProject.timeout`].
|
||||
|
||||
## property: FullProject.use
|
||||
* since: v1.10
|
||||
- type: <[Fixtures]>
|
||||
|
||||
See [`property: TestProject.use`].
|
||||
|
|
@ -19,34 +19,20 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const PROJECT_DIR = path.join(__dirname, '..', '..');
|
||||
const md = require('../markdown');
|
||||
|
||||
const allowList = [
|
||||
'forbidOnly',
|
||||
'fullyParallel',
|
||||
'globalSetup',
|
||||
'globalTeardown',
|
||||
'globalTimeout',
|
||||
'grep',
|
||||
'grepInvert',
|
||||
'maxFailures',
|
||||
'metadata',
|
||||
'version',
|
||||
'preserveOutput',
|
||||
'projects',
|
||||
'reporter',
|
||||
'reportSlowTests',
|
||||
'rootDir',
|
||||
'quiet',
|
||||
'shard',
|
||||
'updateSnapshots',
|
||||
'workers',
|
||||
'webServer',
|
||||
'configFile',
|
||||
];
|
||||
const allowedNames = new Set(allowList);
|
||||
function generateFullConfigClass(fromClassName, toClassName, allowList) {
|
||||
const allowedNames = new Set(allowList);
|
||||
|
||||
const content = fs.readFileSync(path.join(PROJECT_DIR, 'docs/src/test-api/class-testconfig.md')).toString();
|
||||
const content = fs.readFileSync(path.join(PROJECT_DIR, `docs/src/test-api/class-${fromClassName.toLowerCase()}.md`)).toString();
|
||||
let sections = content.split('\n## ');
|
||||
sections = filterAllowedSections(sections, allowedNames);
|
||||
if (allowedNames.size)
|
||||
console.log(`Undocumented properties for ${fromClassName}:\n ${[...allowedNames].join('\n ')}`);
|
||||
sections = changeClassName(sections, fromClassName, toClassName);
|
||||
sections = replacePropertyDescriptions(sections, fromClassName);
|
||||
const fullconfig = sections.join('\n## ');
|
||||
fs.writeFileSync(path.join(PROJECT_DIR, `docs/src/test-api/class-${toClassName.toLowerCase()}.md`), fullconfig);
|
||||
}
|
||||
|
||||
function propertyNameFromSection(section) {
|
||||
section = section.split('\n')[0];
|
||||
|
|
@ -56,32 +42,80 @@ function propertyNameFromSection(section) {
|
|||
return match[1];
|
||||
}
|
||||
|
||||
let sections = content.split('\n## ');
|
||||
sections = sections.filter(section => {
|
||||
section = section.split('\n')[0];
|
||||
const name = propertyNameFromSection(section);
|
||||
if (!name)
|
||||
return true;
|
||||
return allowedNames.has(name);
|
||||
});
|
||||
function filterAllowedSections(sections, allowedNames) {
|
||||
return sections.filter(section => {
|
||||
section = section.split('\n')[0];
|
||||
const name = propertyNameFromSection(section);
|
||||
if (!name)
|
||||
return true;
|
||||
return allowedNames.delete(name);
|
||||
});
|
||||
}
|
||||
|
||||
// Change class name to FullConfig.
|
||||
sections = sections.map(section => {
|
||||
const lines = section.split('\n');
|
||||
lines[0] = lines[0].replace('TestConfig', 'FullConfig');
|
||||
return lines.join('\n');
|
||||
});
|
||||
function changeClassName(sections, from, to) {
|
||||
return sections.map(section => {
|
||||
const lines = section.split('\n');
|
||||
lines[0] = lines[0].replace(from, to);
|
||||
return lines.join('\n');
|
||||
});
|
||||
}
|
||||
|
||||
// Replace description.
|
||||
sections = sections.map(section => {
|
||||
const parts = section.split('\n\n');
|
||||
section = parts[0];
|
||||
const name = propertyNameFromSection(section);
|
||||
console.log(name)
|
||||
if (!name)
|
||||
return `${section}\n`;
|
||||
return `${section}\n\nSee [\`property: TestConfig.${name}\`].\n`;
|
||||
});
|
||||
function replacePropertyDescriptions(sections, configClassName) {
|
||||
return sections.map(section => {
|
||||
const parts = section.split('\n\n');
|
||||
section = parts[0];
|
||||
const name = propertyNameFromSection(section);
|
||||
if (!name)
|
||||
return `${section}\n`;
|
||||
return `${section}\n\nSee [\`property: ${configClassName}.${name}\`].\n`;
|
||||
});
|
||||
}
|
||||
|
||||
const fullconfig = sections.join('\n## ');
|
||||
fs.writeFileSync(path.join(PROJECT_DIR, 'docs/src/test-api/class-fullconfig.md'), fullconfig);
|
||||
function generateFullConfig() {
|
||||
generateFullConfigClass('TestConfig', 'FullConfig', [
|
||||
'forbidOnly',
|
||||
'fullyParallel',
|
||||
'globalSetup',
|
||||
'globalTeardown',
|
||||
'globalTimeout',
|
||||
'grep',
|
||||
'grepInvert',
|
||||
'maxFailures',
|
||||
'metadata',
|
||||
'version',
|
||||
'preserveOutput',
|
||||
'projects',
|
||||
'reporter',
|
||||
'reportSlowTests',
|
||||
'rootDir',
|
||||
'quiet',
|
||||
'shard',
|
||||
'updateSnapshots',
|
||||
'workers',
|
||||
'webServer',
|
||||
'configFile',
|
||||
]);
|
||||
}
|
||||
|
||||
function generateFullProject() {
|
||||
generateFullConfigClass('TestProject', 'FullProject', [
|
||||
'grep',
|
||||
'grepInvert',
|
||||
'metadata',
|
||||
'name',
|
||||
'dependencies',
|
||||
'snapshotDir',
|
||||
'outputDir',
|
||||
'repeatEach',
|
||||
'retries',
|
||||
'teardown',
|
||||
'testDir',
|
||||
'testIgnore',
|
||||
'testMatch',
|
||||
'timeout',
|
||||
'use',
|
||||
]);
|
||||
}
|
||||
|
||||
generateFullConfig();
|
||||
generateFullProject();
|
||||
|
|
|
|||
Loading…
Reference in a new issue