You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issues @ailiop mentioned it would be nice to have example programs residing in a place where we can include their code in the relevant articles instead of copying and pasting. I verified this is possible, as documented here.
Additional discussion
The solution uses Eleventy's include, which means that the example programs should live somewhere inside the /src/_includes folder of the website repo. I think that presents us with the main design decision -- how exactly to organize our code files in that location.
We might put all our examples into /src/_includes/code. Then we could use an example /src/_includes/code/dummy.c by adding the following within the markdown body of an article
I think this is a fine initial setup, thank you @behoppe.
Some thoughts:
In some cases, such as nontrivial codes for tutorials or blog posts, it may be beneficial to use page-specific subdirectories with Makefiles etc, to make it easier to review/validate/update the page contents if necessary.
It could be handy if the include shortcode accepted optional arguments with start/end line numbers. For example, this could facilitate showing the code for some function() but not for a test rig in main(), etc.
Once we agree on a specific coding style, we can use an appropriate .clang-format config file to make sure our codes are formatted accordingly. Moreover, I wonder if we could have some GitHub CI action do that automatically for all C/C++ files in src/_includes/code/.
Thanks @ailiop. I think we can add subdirectories as we need them.
I consider this item done (with #148), with these two "cans" getting "kicked":
include is built into the template language, and it does not support line numbers. Perhaps it's possible to write a separate shortcode that can encapsulate anything (e.g., include) and crop it? I leave that to a separate project.
I am glad to hear about .clang-format and look forward to how we use it to roll out a standard. Why don't we leave that for another project as well.
Issues
@ailiop mentioned it would be nice to have example programs residing in a place where we can
include
their code in the relevant articles instead of copying and pasting. I verified this is possible, as documented here.Additional discussion
The solution uses Eleventy's
include
, which means that the example programs should live somewhere inside the/src/_includes
folder of the website repo. I think that presents us with the main design decision -- how exactly to organize our code files in that location.We might put all our examples into
/src/_includes/code
. Then we could use an example/src/_includes/code/dummy.c
by adding the following within the markdown body of an articleThis would show up as pictured below (in a silly example).
@ailiop shall I set up a folder
/src/_includes/code
? Or are there other possible configurations we'd like to consider?The text was updated successfully, but these errors were encountered: