Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing javadoc parsing of fetch with parsing package #16

Open
vzhang03 opened this issue Aug 1, 2024 · 0 comments
Open

Replacing javadoc parsing of fetch with parsing package #16

vzhang03 opened this issue Aug 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@vzhang03
Copy link
Collaborator

vzhang03 commented Aug 1, 2024

private parseJavadocString(script: string) {
const dataString = script.match(/data:\s*{([\s\S]*?)};\s*/).join();
const result = {};
// Regular expression to match each variable block
const varRegex = /\/\*\*\s*([\s\S]*?)\s*\*\/\s*(\w+):\s*{\s*([\s\S]*?)\s*},?/gs;
const propRegex = /\s*(\w+):\s*([^,\s]+)/g;
// Match each variable block
let match;
while ((match = varRegex.exec(dataString)) !== null) {
let [, description, varName, props] = match;
description = description.trim().replace(/\s+/g, " "); // Clean up description
const propsObj = {};
let propMatch;
while ((propMatch = propRegex.exec(props)) !== null) {
let [, propName, propValue] = propMatch;
propsObj[propName] = propValue;
}
result[varName] = {
description: description,
...propsObj, // Add all additional properties to the result object
};
}
return result;
}
}

Currently the metadata module parses the javadoc using a prewritten and defined function. Because the structure of javascript or how plugins are written may change in the future, this may invalidate the package in its current form. To prevent this, would be good to replace this with a javadoc scraping package that is maintained.

@vzhang03 vzhang03 added the enhancement New feature or request label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant