docify icon indicating copy to clipboard operation
docify copied to clipboard

git integration

Open kianenigma opened this issue 1 year ago • 3 comments

end goal:

#[doc = docify::embed!(git: "github.com/paritytech/polkadot-sdk.git", path: "substrate/frame/examples/basic/src/lib.rs", item: my_cool_item)]

kianenigma avatar Oct 16 '23 15:10 kianenigma

another thing I'm contemplating here is being able to specify at the crate level a fallback git url to use for relative paths, so at the beginning of lib.rs you could specify something like:

docify::set_git_fallback!(git: "github.com/paritytech/polkadot-sdk.git", base_path: "path/to/current/crate");

And then any embeds that fail, it will use that git repo and path as the fallback and will try to find things from within there. So this way you could still use your relative paths and they will work normally 99% of the time, and then in that weird scenario where they don't work because of cargo publish shenanigans, it will use this fallback.

But the basic git feature is also something I want to do anyway because there are some scenarios where that is the only way to do something

sam0x17 avatar Oct 19 '23 17:10 sam0x17

IF and when you would use git, it would be cool if you could enable in option that would also put a permalink to the line of code as a comment in the first line of the snippet. So you would see the code, then you could also click on this link and see it in the original context.

kianenigma avatar Oct 19 '23 21:10 kianenigma

yeah was thinking about having something like a shields.io button to the permalink or something but yeah this is also in my mental scaffold for this

sam0x17 avatar Oct 20 '23 01:10 sam0x17

one key thing when implementing this: need to make sure to use some sort of crate that provides git cloning, since it is likely that the git cli is not available on the crates.io runners

sam0x17 avatar Oct 22 '24 19:10 sam0x17

one key thing when implementing this: need to make sure to use some sort of crate that provides git cloning, since it is likely that the git cli is not available on the crates.io runners

How about just raw GET requests to raw.githubuserconent.com and so on and so forth?

kianenigma avatar Oct 23 '24 10:10 kianenigma

one key thing when implementing this: need to make sure to use some sort of crate that provides git cloning, since it is likely that the git cli is not available on the crates.io runners

How about just raw GET requests to raw.githubuserconent.com and so on and so forth?

could, but would be better to operate at the git level i.e. for people who use non-github git hosting

sam0x17 avatar Oct 23 '24 14:10 sam0x17

Let's see if there is an option. If not, I think gh-only is a reasonable compromise.

kianenigma avatar Oct 23 '24 15:10 kianenigma

yeah looking into it

sam0x17 avatar Oct 24 '24 18:10 sam0x17