-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
link to github source w/ line number? #202
Comments
The viewcode support has to do something similar. You should be able to adapt what it does to work for the linkcode extension: sphinx-autoapi/autoapi/extension.py Lines 245 to 249 in b52378f
What it does isn't exactly part of the public API of AutoAPI but it'll do what you want. Let me know how you get on. |
In case that helps, I implemented a version this here: https://github.com/aaugustin/websockets/blob/main/docs/conf.py#L61-L105 This implementation supports functions, classes, and methods, which is all I care about here. |
aaugustin 's solution is pretty elegent. It is just the link appears to be out-of-date due to code changes. The permalink is here: https://github.com/aaugustin/websockets/blob/778a1ca6936ac67e7a3fe1bbe585db2eafeaa515/docs/conf.py#L100-L134 |
@aaugustin's solution worked great! I just had to add that the object should be unwrapped, which I learned from sklearn here. Add obj = inspect.unwrap(obj) right before getting the object's sourcefile Edit: a hack I had to for my directory structure was file = file.lstrip('../') right before returning. I identified the issue by inspecting the source for the [source] link, which was missing the branch name 'main' |
This replaces the viewcode extension to use the linkcode extension. Instead of showing the code on the docs, the `source` link will redirect to the github code. Based on readthedocs/sphinx-autoapi#202
This replaces the viewcode extension to use the linkcode extension. Instead of showing the code on the docs, the `source` link will redirect to the github code. Based on readthedocs/sphinx-autoapi#202
Is it possible to use https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html to generate a github link including the specific line numbers for each function? Currently I've got it working more or less, but every function links to the github page for that module's source. I'm wondering if it is possible to have autoapi figure out the corresponding line in the file so I can include that in the github link.
Essentially in
which is the example from the above link, I guess
info
would have to include the line numberingThanks!
The text was updated successfully, but these errors were encountered: