I am a member of the Algonquian Components Project, a National Science Foundationβfunded database of morphological components in Algonquian languages, which uses the Digital Linguistics infrastructure.
Overview: You'll be writing a function called createIndexPage, which uses the file src/index.hbs as a template, and creates a new file in the out folder called index.html.
Detailed steps are below. Please check off each item once it's done. Don't forget to test your code each step of the way too. If you get stuck or run into trouble on any part, and can't find the answer online, just comment here and I'll reply ASAP.
P.S. As you work through this, spend some time learning more about Atom too. Here's the help documentation for it. Eventually you should read everything in Chapter 2: Using Atom (except for the Version Control section). Keep learning new keyboard shortcuts and using the ones you already know too.
P.P.S. You can click on the links below to take you to the particular sections of code I'm talking about.
P.P.P.S. I created a script that will generate example documentation, so you can use this to test your code. Instead of running jschemer <filename> in node, now you can just run the command npm run example. This will create a folder called example and output the documentation there. So running this command is an easy way to test your code as you go.
We'll be following these steps as we work together on this code. Reading this will help you know what's coming, and understanding why we're doing each step as we do it.
Create a new branch called generate-index (because the code you're writing will be generating the index.html page).
You'll make all your changes on this branch. When you're done, I'll merge your changes into the master branch. This allows you to make changes without worrying about accidentally breaking code in the master branch.
You should sync your changes to this branch frequently as you work. Don't worry if the code isn't working right. That's what branches are for - to mess around with code until you've got it the way you want. Usually, nobody else even looks at your code until it's time to merge your changes into the master branch.
Look at the code to understand how your createIndexPage function fits into the larger jschemer function.
Use the fs module to read the contents of src/index.hbs.
index.hbs contains the template you'll be using in the next step.
Compile the template using Handlebars, and save the resulting function to a variable called convert.
Next, you need to tell your convert function what data to use when it converts the template to HTML. In your learning folder, you did this by reading the file called data.json, and passing its contents to convert. This time, instead of reading the data from a file, you're just going to create the data object yourself, and it'll be called context this time instead of data.
Create an object called context with 3 properties:
css - Set this equal to the cssPath variable (see here)
nav - Set this equal to the nav variable (see here)
readme - Set this equal to the readme variable, which is passed to your function as an argument (see here)
Call the convert function on your context object and save the result to a variable called html.
Create a file called index.html in the out folder with html as its contents.
Update your generate-index branch with the latest changes from the master branch, then sync your code.
Open a pull request to merge your changes into the master branch.
Celebrate with your drink of choice π· πΊ π» πΈ πΉ
Once you've made the pull request, I'll see it and review your code. I'll ask you to make various revisions, then we'll merge your code into the master branch.
This would allow someone to provide a base filepath, against which relative paths in $ref keywords could be defined. jschemer.js would then need to synchronously read the file at that location, and Object.assign the properties from the local definition onto the external definition, then update the local definition with the external one.