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
Is there a way of embedding code using some kind of markers instead of line numbers?
Let's say I have this file:
import sth
import sth not important
fun myFun() {
stuff here
stuff here
}
I've embedded the myFun() part: L4-L7
fun myFun() {
stuff here
stuff here
}
Afterward I've noticed one of the imports is not important, so I delete it from the code base,
import sth
fun myFun() {
stuff here
stuff here
}
but forget to update the embedded line numbers, so the embedded part looks like this:
stuff here
stuff here
}
I'm aware that instead of pointing to a branch, I can point to a commit/permalink, which won't change. But this is also a disadvantage, since the code samples would show something outdated.
I was thinking if there is a way to embed code using some kind of markers. I've tried googling it, but no luck so far. Maybe you could point me to something useful.
The text was updated successfully, but these errors were encountered:
The scene you describe is interesting. But sorry I can't find an elegant way to do it after googling either.
I believe there should be roughly two ways to implement the feature:
on the script side: specifing the contents of the start line and end line, instead of the line numbers. Say using the regex: start=fun myFun\(\) \{\n, end= stuff here\n\}.
on the code side: changing the original code by adding some special tokens in comments. For example,
// emgithub: start-next-line
fun myFun() { // or, emgithub: start-this-line
stuff here
stuff here
} // or, emgithub: end-this-line
// emgithub: end-last-line
Personally I prefer the second way. The first way may encounter some problems, say if there are multiple lines with the same contents. The second way is more precise in locating code, although we have to pollute the original code.
However both of them are somewhat dirty and may not be implemented in the main repo. You can try forking the repo and implement it to fit your specific needs.
Anyway I'll mark this as help-wanted. In case someone come up with an elegant way, we can do it in the main repo.
Is there a way of embedding code using some kind of markers instead of line numbers?
Let's say I have this file:
I've embedded the myFun() part: L4-L7
Afterward I've noticed one of the imports is not important, so I delete it from the code base,
but forget to update the embedded line numbers, so the embedded part looks like this:
I'm aware that instead of pointing to a branch, I can point to a commit/permalink, which won't change. But this is also a disadvantage, since the code samples would show something outdated.
I was thinking if there is a way to embed code using some kind of markers. I've tried googling it, but no luck so far. Maybe you could point me to something useful.
The text was updated successfully, but these errors were encountered: