Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/parameterData.json
Original file line number Diff line number Diff line change
Expand Up @@ -4655,6 +4655,10 @@
},
"modify": {
"overloads": [
[
"Function",
"Object?"
],
Comment on lines +4658 to +4661
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameterData.json might be out of date. I think it's nice to have a CI that checks parameterData.json is up-to-date.

[
"Object?"
]
Expand Down
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const commonRules = {
'@stylistic/max-len': [
warn,
{
code: 80,
code: 120,
ignoreComments: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
Expand Down Expand Up @@ -272,4 +272,4 @@ export default defineConfig([
// * contributor_docs/zh-Hans/unit_testing.md 35:1 error Parsing error: Unexpected token
// * rfc_p5js_2.md 205:50 error Parsing error: Binding arguments in strict mode
// ...markdown.configs.processor
]);
]);
22 changes: 11 additions & 11 deletions utils/convert.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ function getParams(entry) {
// string, so we match these params to the Documentation.js-provided `params`
// array and grab the description from those.
return (entry.tags || [])

// Filter out the nested parameters (eg. options.extrude),
// to be treated as part of parent parameters (eg. options)
// and not separate entries
.filter(t => t.title === 'param' && !t.name.includes('.'))
.filter(t => t.title === 'param' && !t.name.includes('.'))
.map(node => {
const param = (entry.params || []).find(param => param.name === node.name);
return {
Expand Down Expand Up @@ -517,13 +517,6 @@ function cleanUpClassItems(data) {
const flattenOverloads = funcObj => {
const result = {};

const processOverload = overload => {
if (overload.params) {
return Object.values(overload.params).map(param => processParam(param));
}
return overload;
}

// To simplify `parameterData.json`, instead of having a separate field for
// optional parameters, we'll add a ? to the end of parameter type to
// indicate that it's optional.
Expand All @@ -536,7 +529,14 @@ function cleanUpClassItems(data) {
type = `...${type}[]`;
}
return type;
}
};

const processOverload = overload => {
if (overload.params) {
return Object.values(overload.params).map(param => processParam(param));
}
return overload;
};
Comment on lines +538 to +543
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint warned that processOverload comes before processParam, thus it might call uninitialized variable. This is why I moved this code.


// In some cases, even when the arguments are intended to mean different
// things, their types and order are identical. Since the exact meaning
Expand All @@ -549,7 +549,7 @@ function cleanUpClassItems(data) {
}
uniqueOverloads.add(overloadString);
return true;
}
};

for (const [key, value] of Object.entries(funcObj)) {
if (value && typeof value === 'object' && value.overloads) {
Expand Down
6 changes: 3 additions & 3 deletions utils/generate-types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import { fileURLToPath } from 'url';
import {
generateTypeDefinitions
} from "./helper.mjs";
} from './helper.mjs';

// Fix for __dirname equivalent in ES modules
const __filename = fileURLToPath(import.meta.url);
Expand All @@ -19,7 +19,7 @@ function findDtsFiles(dir, files = []) {
}

const entries = fs.readdirSync(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
Expand All @@ -44,7 +44,7 @@ export function generateAllDeclarationFiles() {
fileTypes.forEach((content, filePath) => {
const parsedPath = path.parse(filePath);
const relativePath = path.relative(
path.join(__dirname, "../src"),
path.join(__dirname, '../src'),
filePath
);
const dtsPath = path.join(
Expand Down
Loading
Loading