mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 13:45:36 +03:00
docs: sort all enums in doclint (#3488)
Currently, the order depends on some internals of typescript compiler and changes from time to time. Sorting makes it stable.
This commit is contained in:
parent
3aae8c6be1
commit
5aa4116204
@ -197,11 +197,16 @@ function checkSources(sources) {
|
||||
return new Documentation.Type('Object', properties);
|
||||
}
|
||||
if (type.isUnion() && (typeName.includes('|') || type.types.every(type => type.isStringLiteral() || type.intrinsicName === 'number'))) {
|
||||
const types = type.types
|
||||
.filter(isNotUndefined)
|
||||
.map(type => serializeType(type, circular));
|
||||
const name = types.map(type => type.name).join('|');
|
||||
const properties = [].concat(...types.map(type => type.properties));
|
||||
const types = type.types.filter(isNotUndefined).map((type, index) => {
|
||||
return { isLiteral: type.isStringLiteral(), serialized: serializeType(type, circular), index };
|
||||
});
|
||||
types.sort((a, b) => {
|
||||
if (!a.isLiteral || !b.isLiteral)
|
||||
return a.index - b.index;
|
||||
return a.serialized.name.localeCompare(b.serialized.name);
|
||||
});
|
||||
const name = types.map(type => type.serialized.name).join('|');
|
||||
const properties = [].concat(...types.map(type => type.serialized.properties));
|
||||
return new Documentation.Type(name.replace(/false\|true/g, 'boolean'), properties);
|
||||
}
|
||||
if (type.typeArguments && type.symbol) {
|
||||
|
@ -53,7 +53,12 @@ class MDOutline {
|
||||
const ul = clone.querySelector(':scope > ul');
|
||||
const str = parseComment(extractSiblingsIntoFragment(clone.firstChild, ul));
|
||||
const name = str.substring(0, str.indexOf('<')).replace(/\`/g, '').trim();
|
||||
const type = findType(str);
|
||||
let type = findType(str);
|
||||
const literals = type.match(/("[^"]+"(\|"[^"]+")*)/);
|
||||
if (literals) {
|
||||
const sorted = literals[1].split('|').sort((a, b) => a.localeCompare(b)).join('|');
|
||||
type = type.substring(0, literals.index) + sorted + type.substring(literals.index + literals[0].length);
|
||||
}
|
||||
const properties = [];
|
||||
let comment = str.substring(str.indexOf('<') + type.length + 2).trim();
|
||||
const hasNonEnumProperties = type.split('|').some(part => {
|
||||
|
Loading…
Reference in New Issue
Block a user