mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(api.json): do not copy documentation from base class members (#4048)
This commit is contained in:
parent
e214f795e0
commit
fbe0fb2977
@ -322,9 +322,10 @@ class MDOutline {
|
||||
/**
|
||||
* @param {!Page} page
|
||||
* @param {!Array<!Source>} sources
|
||||
* @param {!boolean} copyDocsFromSuperClasses
|
||||
* @return {!Promise<{documentation: !Documentation, errors: !Array<string>}>}
|
||||
*/
|
||||
module.exports = async function(page, sources) {
|
||||
module.exports = async function(page, sources, copyDocsFromSuperClasses) {
|
||||
const classes = [];
|
||||
const errors = [];
|
||||
for (const source of sources) {
|
||||
@ -334,7 +335,7 @@ module.exports = async function(page, sources) {
|
||||
}
|
||||
const documentation = new Documentation(classes);
|
||||
|
||||
|
||||
if (copyDocsFromSuperClasses) {
|
||||
// Push base class documentation to derived classes.
|
||||
for (const [name, clazz] of documentation.classes.entries()) {
|
||||
clazz.validateOrder(errors, clazz);
|
||||
@ -354,5 +355,6 @@ module.exports = async function(page, sources) {
|
||||
clazz.membersArray = [...clazz.membersArray, ...superClass.membersArray];
|
||||
clazz.index();
|
||||
}
|
||||
}
|
||||
return { documentation, errors };
|
||||
};
|
||||
|
||||
@ -29,7 +29,7 @@ const EXCLUDE_PROPERTIES = new Set([
|
||||
* @return {!Promise<!Array<!Message>>}
|
||||
*/
|
||||
module.exports = async function lint(page, mdSources, jsSources) {
|
||||
const mdResult = await mdBuilder(page, mdSources);
|
||||
const mdResult = await mdBuilder(page, mdSources, true);
|
||||
const jsResult = jsBuilder.checkSources(jsSources);
|
||||
const jsDocumentation = filterJSDocumentation(jsSources, jsResult.documentation);
|
||||
const mdDocumentation = mdResult.documentation;
|
||||
|
||||
@ -63,7 +63,7 @@ async function testMDBuilder(name) {
|
||||
it(name, async({page}) => {
|
||||
const dirPath = path.join(__dirname, name);
|
||||
const sources = await Source.readdir(dirPath, '.md');
|
||||
const {documentation} = await mdBuilder(page, sources);
|
||||
const {documentation} = await mdBuilder(page, sources, true);
|
||||
expect(serialize(documentation)).toBe(fs.readFileSync(path.join(dirPath, 'result.txt')).toString());
|
||||
});
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ const PROJECT_DIR = path.join(__dirname, '..', '..');
|
||||
const api = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'api.md'));
|
||||
const browser = await playwright.chromium.launch();
|
||||
const page = await browser.newPage();
|
||||
const { documentation } = await mdBuilder(page, [api]);
|
||||
const { documentation } = await mdBuilder(page, [api], false);
|
||||
const result = serialize(documentation);
|
||||
console.log(JSON.stringify(result));
|
||||
await browser.close();
|
||||
@ -39,6 +39,8 @@ function serialize(documentation) {
|
||||
|
||||
function serializeClass(clazz) {
|
||||
const result = { name: clazz.name };
|
||||
if (clazz.extends)
|
||||
result.extends = clazz.extends;
|
||||
result.members = {};
|
||||
for (const member of clazz.membersArray)
|
||||
result.members[member.name] = serializeMember(member);
|
||||
|
||||
@ -36,7 +36,7 @@ let documentation;
|
||||
const browser = await chromium.launch();
|
||||
const page = await browser.newPage();
|
||||
const api = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'api.md'));
|
||||
const {documentation: mdDocumentation} = await require('../doclint/check_public_api/MDBuilder')(page, [api]);
|
||||
const {documentation: mdDocumentation} = await require('../doclint/check_public_api/MDBuilder')(page, [api], true);
|
||||
await browser.close();
|
||||
const sources = await Source.readdir(path.join(PROJECT_DIR, 'src', 'client'), '', []);
|
||||
const {documentation: jsDocumentation} = await require('../doclint/check_public_api/JSBuilder').checkSources(sources);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user