1

I am currently writing a small documentation on Github Wiki. I have a repo for my example codes and would like to cite some lines from examples codes in my wiki.

Rather than writing a code block statically, I simply want to "get 1st to 5th lines of code from this file", so when ever I update the an example code, the codes in the wiki will be updated.

Is it possible?

For example (in Wiki):

github.com/username/repo/main.cpp :

#include "test.h"

int main(){

}

In wiki: (Get the first line of ../main.cpp)

#include "test.h"
Boris Modylevsky
  • 3,029
  • 1
  • 26
  • 42
pmundt
  • 57
  • 9

2 Answers2

3

You can reference your code using permalink feature in GitHub. For example reference looks like this:

https://github.com/git/git/blob/master/README#L18-L20

Here is the full answer:

How to link to specific line number on github

Boris Modylevsky
  • 3,029
  • 1
  • 26
  • 42
2

This isn't really possible, since the Wiki is statically generated content. There's no option to my mind to add dynamic content in this fashion.

This does force the developer to keep well on top of their documentation, however.

Makoto
  • 104,088
  • 27
  • 192
  • 230