JuliaDocs / DemoCards.jl

Let's focus on writing demos
MIT License
65 stars 14 forks source link

Don't force root path to be absolute when generating cards #148

Closed adamslc closed 11 months ago

adamslc commented 11 months ago

This was causing the postprocess function to crash when trying to compute the corresponding build dir because the '..' a relative path is lost when making the path absolute.

johnnychen94 commented 11 months ago

Sorry, I'm not very positive about merging this.

My old memory says it's a bit delicate to modify the path. It could possibly break the existing workflows. I had a hard time computing the path so my "solution" is to use abspath everywhere and to use relpath to compute the relative path.

Could relpath meets the need here?

adamslc commented 11 months ago

Some more information: the issue arrises when doing makedemos(../examples), which results in a absolute path that looks like

/home/user/.julia/dev/Package/examples/section/subsection/card.md

The trouble then arrises in get_build_file, where we are trying to construct the path

/home/user/.julia/dev/Package/docs/build/examples/section/subsection/card.md

using only the source path, and the source dir ../examples. I don't believe that there is a way to go from one path to the other in general. Maybe there could be an additional kwarg for makedemos that defaults to the current behavior, and allows the use of relative paths?

johnnychen94 commented 11 months ago

Maybe there could be an additional kwarg for makedemos that defaults to the current behavior, and allows the use of relative paths?

This seems a bit tricky to me...

The generate function has two keywords build and root, would them be useful to parse and reconstruct the paths?

adamslc commented 11 months ago

I believe that this new commit should work. It passes the package tests locally, and it also sucessfully builds the docs for me locally with a package that uses makedemos("../examples").

johnnychen94 commented 11 months ago

I didn't double-check the path calculation; it just looks like what I would write myself. Thanks for the updates.