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

Add Automated updated of autocomplete-css completions.json #398

Merged
merged 33 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2a5fafb
Initial Setup and parsing of data
confused-Techie Feb 22, 2023
34b22ae
Final touches, and lots of them
confused-Techie Feb 24, 2023
6758361
Fixed type in `completions.json` Removed unneeded files
confused-Techie Feb 24, 2023
9af1375
Spelling fix `seperators` -> `separators`
confused-Techie Feb 24, 2023
e3b63ef
Merge branch 'master' into update-autocomplete-css
confused-Techie Feb 25, 2023
9137f9d
Allow manual HTML tags replacement from MDN docs
confused-Techie Feb 25, 2023
705e0d9
Ensure `getValuesOfProp()` properly receives full `css` object rather…
confused-Techie Feb 25, 2023
2c5ecd0
Fixed parts of `update.js`, and fixed some tests, broke others
confused-Techie Feb 25, 2023
3570e56
Update packages/autocomplete-css/update.js
confused-Techie Feb 25, 2023
0b6fd03
Large rewrite to specs to allow for expansion and change of the autoc…
confused-Techie Feb 25, 2023
b15410e
Added implicitly defined keywords to `completions.js`
confused-Techie Feb 25, 2023
b9acc26
Last `completions.json` agnostic test
confused-Techie Feb 25, 2023
d4ebeec
Update README.md for new update process
confused-Techie Feb 25, 2023
7a746a7
Rename variables within `isValueInCompletions()`
confused-Techie Mar 2, 2023
1ad19ce
autocomplete-css: Run `node update.js`
DeeDeeG Mar 4, 2023
4eb9758
autocomplete-css: Put implicit values last
DeeDeeG Mar 4, 2023
a163e38
autocomplete-css: Refresh package-lock.json
DeeDeeG Mar 4, 2023
ebdd711
autocomplete-css: Handle recursion for appending implicit values
DeeDeeG Mar 4, 2023
1024076
autocomplete-css: Handle more recursion
DeeDeeG Mar 4, 2023
0ab4f7d
Update packages/autocomplete-css/update.js
confused-Techie Mar 5, 2023
7c1e1d3
Resolve the initial blank descriptions
confused-Techie Mar 5, 2023
732a353
Protect against collecting warnings and notices as descriptions
confused-Techie Mar 5, 2023
a2237f3
Also add checks to `svg/elements` to collect missing `marker`
confused-Techie Mar 7, 2023
f34341b
First manual property description, and implementation of it's functio…
confused-Techie Mar 7, 2023
0411904
Add all legacy alias' and more
confused-Techie Mar 7, 2023
b79cc7b
Add other alias' and property mappings
confused-Techie Mar 7, 2023
828f326
Add in stroke spec properties
confused-Techie Mar 7, 2023
46f96db
Many many others
confused-Techie Mar 7, 2023
e7feeac
Add manual property descriptions to reduce empties to 17
confused-Techie Mar 10, 2023
a27b70b
Finish adding all manual properties
confused-Techie Mar 10, 2023
2a3afcb
Resolve failing spec
confused-Techie Mar 11, 2023
39dcbd2
Revert "Resolve failing spec"
confused-Techie Mar 11, 2023
804bbda
Update packages/autocomplete-css/update.js
confused-Techie Mar 15, 2023
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
2 changes: 1 addition & 1 deletion packages/autocomplete-css/completions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7290,7 +7290,7 @@
"initial",
"unset"
],
"description": ""
"description": "The shape-subtract property allows one to exclude part of the content area form the wrapping area. The excluded area is the addition of all the areas defined in a list of CSS basic shapes and/or SVG shapes."
},
"text-anchor": {
"values": [
Expand Down
6 changes: 6 additions & 0 deletions packages/autocomplete-css/manual-property-desc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"shape-subtract": {
"desc": "The shape-subtract property allows one to exclude part of the content area form the wrapping area. The excluded area is the addition of all the areas defined in a list of CSS basic shapes and/or SVG shapes.",
confused-Techie marked this conversation as resolved.
Show resolved Hide resolved
"spec": "https://svgwg.org/svg2-draft/text.html#TextShapeSubtract"
}
}
46 changes: 43 additions & 3 deletions packages/autocomplete-css/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
Within `content/files/en-us/web/css` is a directory of folders titled
by the name of properties.

The last important thing to note here:
MDN doesn't have docs on everything. And that's a good thing. But it means
many of our items don't have any kind of description. For this situation
we have `manual-property-desc.json` which is a list of manually updated
descriptions for properties where there are none. This was a last resort
intended to provide the highest quality of completions possible.
Overtime many items on this list will likely be able to be removed just as
new ones are added. After running the update script you'll see a warning
saying how many properties are without completions that would then need to
be added to the JSON file.

"spec-shortname": {
"spec": {
"title": "",
Expand Down Expand Up @@ -77,8 +88,9 @@
const css = require("@webref/css");
const fs = require("fs");
const CSSParser = require("./cssValueDefinitionSyntaxExtractor.js");
const manualPropertyDesc = require("./manual-property-desc.json");

async function update() {
async function update(params) {
const parsedFiles = await css.listAll();

const properties = await buildProperties(parsedFiles);
Expand All @@ -94,7 +106,30 @@ async function update() {
// Now to write out our updated file
fs.writeFileSync("completions.json", JSON.stringify(completions, null, 2));

// Now to determine how many properties have empty descriptions.

let count = 0;
let showEmpty = false;

for (const param of params) {
if (param === "--show-empty") {
showEmpty = true;
}
}

for (const prop in completions.properties) {
if (completions.properties[prop].description === "") {
if (showEmpty) {
console.log(prop);
}
count ++;
}
}

console.log("Updated all `autocomplete-css` completions.");
console.log(`Total Completion Properties without a description: ${count}!`);
console.log("It is not required to fix the above empty completions issue.");
console.log("Use `node update.js --show-empty` to show the empty property names.");
}

async function buildProperties(css) {
Expand Down Expand Up @@ -185,7 +220,12 @@ async function getDescriptionOfProp(name) {
}
}
} else {
// A document doesn't yet exist. Let's return an empty value.
// A document doesn't yet exist, let's ensure it's not in our manual list first
if (manualPropertyDesc[name]) {
return manualPropertyDesc[name].desc;
}
// A document doesn't yet exist. And it's not in our manual list
// Let's return an empty value.
return "";
}
}
Expand Down Expand Up @@ -323,4 +363,4 @@ function dedupPropValues(values) {
return out;
}

update();
update(process.argv.slice(2));