-
Notifications
You must be signed in to change notification settings - Fork 16
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
docs: add docs attribution statement, purge the readme content #1111
base: main
Are you sure you want to change the base?
Conversation
ui docs preview (Available for 14 days) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably remove the no longer used images as well.
my_input = ui_input() | ||
``` | ||
|
||
![Text field.](_assets/text_field.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of these images are no longer referenced and can be removed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, AI is pretty handy. Would have taken some effort to do manually, can instead just ask AI write me a on-off script to do it, that way I didn't have to check if any of the docs proper used any of the images either.
/**
* This node script reads all the files in the ./_assets directory and then reads all the .md files
* in the current directory recusively and then checks if the file is used in any of the .md files
*
* If the file is not used in any of the .md files, it will be deleted.
*
* Compare only the file name and extension, not the path.
*/
const path = require('path');
const fs = require('fs');
function getAllMdFiles(dir, fileList = []) {
const files = fs.readdirSync(dir);
files.forEach(file => {
const filePath = path.join(dir, file);
const stat = fs.statSync(filePath);
if (stat.isDirectory()) {
getAllMdFiles(filePath, fileList);
} else if (filePath.endsWith('.md')) {
fileList.push(filePath);
}
});
return fileList;
}
function isAssetUsedInMd(assetName, mdFiles) {
return mdFiles.some(mdFile => {
const content = fs.readFileSync(mdFile, 'utf8');
const isUsed = content.includes(assetName);
if (isUsed) {
console.log(`Asset ${assetName} is used in ${mdFile}`);
}
return isUsed;
});
}
(function purgeUnusedAssets() {
const assetDir = path.join(__dirname, '_assets');
if (!fs.existsSync(assetDir)) {
console.log(`No _assets directory found at ${assetDir}`);
return;
}
const mdFiles = getAllMdFiles(__dirname, []);
const assets = fs.readdirSync(assetDir);
assets.forEach(asset => {
const assetName = asset; // match just the filename
console.log(`Checking asset: ${assetName}`);
if (!isAssetUsedInMd(assetName, mdFiles)) {
const assetPath = path.join(assetDir, assetName);
console.log(`Removing unused asset: ${assetPath}`);
fs.unlinkSync(assetPath);
}
});
console.log('Purge complete.');
})();
ui docs preview (Available for 14 days) |
No description provided.