Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TDKorn committed Jan 21, 2024
1 parent a9a72a4 commit 86cc376
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sphinx_github_style/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def linkcode_resolve(domain, info):

try:
modpath = inspect.getsourcefile(inspect.unwrap(obj))
print(f"MODPATH: {modpath}")
filepath = os.path.relpath(modpath, repo_dir)
if filepath is None:
return
Expand All @@ -213,7 +214,9 @@ def linkcode_resolve(domain, info):
linestart, linestop = lineno, lineno + len(source) - 1

# Fix links with "../../../" or "..\\..\\..\\"
print(f"FILEPATH: {filepath}")
filepath = Path(filepath).as_posix().lstrip('../')
print(f"FILEPATH FIXED: {filepath}")

# Example: https://github.com/TDKorn/my-magento/blob/docs/magento/models/model.py#L28-L59
final_link = linkcode_url.format(
Expand Down

0 comments on commit 86cc376

Please sign in to comment.