vemel / handsdown

Python documentation generator for lazy perfectionists
https://vemel.github.io/handsdown/
MIT License
86 stars 8 forks source link

Bug: Documentation for second level directories and their child dirs fails to link to source code #19

Closed FredHappyface closed 2 years ago

FredHappyface commented 2 years ago

Hi thanks for all your work on this

Describe the bug When running the following for a complex lib, documentation for second level directories and their child dirs fails to link to source code

handsdown --source-code-path ../.. --cleanup

To Reproduce Steps to reproduce the behavior:

  1. Create a python module such that my_module/__init__.py imports from my_module/foo/bar.py
  2. Run handsdown --source-code-path ../.. --cleanup
  3. Result: Viewing source code for my_module/foo/bar.py fails as the link is for ../../my_module/foo/bar.py rather than ../../../my_module/foo/bar.py

Expected behavior Viewing source code for my_module/foo/bar.py succeeds as the link is ../../../my_module/foo/bar.py. I imagine the implementation for this would be similar to linking back to the root MODULES.md (../../MODULES.md#cli2gui-modules) This may change the path passed too as if the repo looks like

my_module/
docs/

Then it would make more sense to run handsdown --source-code-path .. --cleanup in place of handsdown --source-code-path ../.. --cleanup (if --source-code-path is specified the relative paths can be built similarly to how they are to link to MODULES.md)

Screenshots If applicable, add screenshots to help explain your problem.

image

To clarify the screenshot:

Desktop:

Additional context I've included some of this above. Please let me know if you'd like anything clarifying - it's a little late so apologies if any of the above came out as utter nonsense

Thank you for your time :)

vemel commented 2 years ago

Thank you for the report, I will take a look.

FredHappyface commented 2 years ago

Thanks :)

vemel commented 2 years ago

Took me a while to come up with a proper fix, but I got back with good news. The new 1.1.0 release should calculate paths to source code automatically, so you do not have to pass --source-code-path CLI argument. You can still pass it to add a prefix to source code URLs.

Please let me know if the new version works for you as expected.

FredHappyface commented 2 years ago

Hi thanks so much for the quick fix and apologies for the delay in getting back to you - busy weekend!

Works perfectly, thank you ♥