-
Notifications
You must be signed in to change notification settings - Fork 0
PoC for code-snippets-in-markdown system #14
Comments
Did a bit of research on this. Looked for some rust tutorials to see if any are using a similar system, and can't find any. Some examples:
These are all md-books style stuff, and are all copy-past-ing code around. |
I think @jonnysmillie may have some insight here based on stuff we were working on a while ago. |
There is definitely the possibility of extracting lines of code out of files from github repos and inserting them into markdown documents. Something like this came up in a quick search for Gatsby solutions, specifically, albeit it's not well maintained, but there are probably other implementations. I think what is novel in what you propose is the moving forward by applying In regards, to making a CI/CD process for incomplete code snippets, that's more of a challenge. Perhaps we design a GH Action that pulls the code snippet from each stage, applies the |
I had a good chat about this with @sam0x17 and we identified that all existing solutions seem to be "permalinks on steroids", meaning that end of the day, you are referencing some lines of code. This is great, and let's already explore the feasibility. But, as the saying goes, if you are a hammer, you see everything as nails. In the case of me and @sam0x17, we have a tendency to solve all things with Rust/Macro solutions 😅. The idea would be to write a rust-markdown-processor that would parse some markdown, and parse some rust-files, and replace a special annotation in the markdown files with the associated Rust item. The cool thing about this is that you can reference any item, not just lines of code. In other words, a snippet could import a function, with its entire signature, into the markdown file. This has an edge over permalink, as you don't need to worry about breaking the line numbers. Imagine if a big file is used in many places, and we suddenly move everything to one line below because of adding a new import 🤦 Before doing this, we should ensure it does not exist. This is really only possible with Rust, because of |
I think this is a really interesting idea, but I'm focusing in on this sentence from your comment above intentionally. I want to propose a two-phased process here: First, create a quality master tutorial that lives on an easy to navigate usable doc site. I think you can approach the docs creation process as an engineer or as a technical writer. The technical writer wants to produce the best doc possible, and the engineer wants to create the best solution for implementation possible. Both can be done, of course as they should be, yet I think some prioritization is necessary here. It is a well known solution to use line numbers in markdown docs sites to pull in code from GitHub. It is definitely more brittle as you identify, but because it is so well known it'll allow us to move faster towards a finished v1 product before the next PBA, which I believe is your deadline, since there are so many ways to implement it. At the same time, @sam0x17 and yourself and others (maybe even me, I really like the idea!) can work on building the new rust-markdown-processor as a separate crate. In short, I think it's important to identify the minimal viable product for the v1 of the master tutorial and docs, then aim to achieve that before PBA. Then, we need to identify devex and other improvements we want to achieve in iterations of that v1 and a priority order of which one comes first. Personally, I'd recommend this markdown processor idea to be one of the early improvements on the first release. |
It seems @sam0x17 has made my last comment irrelevant by building this thing over the weekend. The idea I stated still stands but in practice is no longer relevant for this conversation :) |
So where we stand right now is I have an unpublished feature for docify that can take in a single markdown file or a directory (recursively) containing many markdown files and it will process them, which involves going through each one, looking for a comment like my vision for how this would be used was:
Based on our discussion, the following would be desirable:
|
@sam0x17 This sounds fantastic, and super helpful. |
btw, this feature (markdown dirs) is live as of late last week. If anyone encounters any issues let me know! |
This is issue is in itself closed now as @sam0x17 built |
Recall:
We need a system to build this,
using Gatsby.Note that some more details might change as we flesh out how the master tutorial is being built. Perhaps, if we use
diff
files to denote each step of the tutorial, the snippets must come not from a permalink, but instead from a diff file.Moreover, we should also explore embedding pieces from
docs.rs
.The text was updated successfully, but these errors were encountered: