Closed agroden closed 1 year ago
Digging in a bit more I see the relative_path
here will need to be sanitized as well since it could be several directories in. Rather than the aforementioned fix, you could get away with a simple sanitation one-liner for any output of the _get_src_path
function. This following should work:
def _get_src_path(self, obj: Any, append_base: bool = True, as_url=False) -> str:
# ...everything else stays the same
# change the last line to:
return "/".join(s.strip("/") for s in relative_path.split(os.path.sep))
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days
Describe the bug:
When generating documentation the source badge creates non-compliant URLs. Specifically, when combining value provided by
-src-base-url
with the path, it seems to use the OS specific path separator. This results in URLs that look like:Expected behaviour:
I would expect this to function correctly on any operating system. Rather than the incorrect URL above, the source badge should use the correct path separator:
Steps to reproduce the issue:
Run lazydocs on Windows with virtually any configuration. I run it specifying an output path and base url for the source.
Technical details:
Possible Fix:
In
generation.py
rather thanos.path.join
I would suggest usingurljoin
fromurllib
. Example:Additional context: https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin