Javascript is restricted from accessing the user's folders, as it should be, but I am working on a plugin for Docsify that will allow dynamic creation of documentation from comments in application *.js files -- I would like to extend this to HTML files but I need to accomplish this first.
I have two problems:
- How do I read a folder from my root and turn the filenames therein into strings?
- How do I read a file from the folder mentioned above and turn that into a string so I can process it?
From my scouring of Mozilla MDN it looks like all of the file APIs are for users uploading files for processing.
My Folder Structure
So pretending objects are folders and files are contents of arrays.
root:{
docs:[
docsifyFilesAndFolders.ext
],
targetJSFolder:[
target1.js,
target2.js
],
rootFiles: [
applicationRootFiles.ext
]
}
My Goal
So what I would like to do is something like this:
const Functions: {
folderProcessor: (folderPath) => {
var files = [
./target1.js,
./target2.js
];
forEach( file in Files ){
Functions.extractTaggedComments();
}
},
extractTaggedComments: (filePath) => {
var comments = TurnCommentsIntoArrays();
var result = new Object();
forEach(comment in comments){
findTag();
createStringInMarkdownFormat();
result.tagAndReference = comment;
}
return result;
},
createMDFile= (extractedComments) => {
var formattedMDText = actions();
return formattedMDText;
}
}
Eventually, I will be creating ./docs/options.html
where the user will be able to see the files and folders inside ./
and decide which ones to present in the documentation with checkboxes.
I think eventually I might have to store the ${fileContents}
into a server of some sort, but I would prefer to avoid that if possible.