-
Notifications
You must be signed in to change notification settings - Fork 135
Using custom edit link #2012
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
Merged
Merged
Using custom edit link #2012
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
09b6060
Using custom edit link
germa89 1fac75f
Using an approach based on editting the main sphin app.
germa89 25a5723
Reorg a bit the docs.
germa89 1a83dd7
Fixing wrong reference
germa89 49a8df1
Resetting cache
germa89 d633488
fixing conf.py
germa89 3c82bd5
Using linkcode_resolve
germa89 3045f88
fixing linkcheck
germa89 21767c7
fixing always getting mapdl
germa89 04e93cd
Apply suggestions from code review
germa89 b69566d
Improving comment
germa89 2f498ae
Merge branch 'doc/fixing-edit-button-link-on-examples' of https://git…
germa89 93bf3d8
Removing unused import
germa89 40dd35c
Merge branch 'main' into doc/fixing-edit-button-link-on-examples
germa89 bedc8f9
fixing find
germa89 25d46e2
Adding tests and solving import issue
germa89 41e176d
Improving tests
germa89 77ee837
fixing tests
germa89 6fa75f7
fixing tests
germa89 2bc068c
fix tests
germa89 976286d
another attemp
germa89 d4f36f6
adding logger
germa89 55901e9
Fixing links
germa89 ed7ca5a
Merge branch 'main' into doc/fixing-edit-button-link-on-examples
germa89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% if sourcename is defined and theme_use_edit_page_button and page_source_suffix %} | ||
{% set src = sourcename.split('.') %} | ||
<div class="tocsection editthispage"> | ||
<a href="{{ fix_edit_link_button(get_edit_provider_and_url()[1]) }}"> | ||
<i class="fa-solid fa-pencil"></i> | ||
{% set provider = get_edit_provider_and_url()[0] %} | ||
{% block edit_this_page_text %} | ||
{% if provider %} | ||
{% trans provider=provider %}Edit on {{ provider }}{% endtrans %} | ||
{% else %} | ||
{% trans %}Edit{% endtrans %} | ||
{% endif %} | ||
{% endblock %} | ||
</a> | ||
</div> | ||
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import inspect | ||
import sys | ||
|
||
|
||
def linkcode_resolve(domain, info, edit=False): | ||
"""Determine the URL corresponding to a Python object. | ||
|
||
Parameters | ||
---------- | ||
domain : str | ||
Only useful when 'py'. | ||
|
||
info : dict | ||
With keys "module" and "fullname". | ||
|
||
edit : bool, default=False | ||
Jump right to the edit page. | ||
|
||
Returns | ||
------- | ||
url : str | ||
The code URL. | ||
|
||
Notes | ||
----- | ||
This has been adapted to deal with our "verbose" decorator. | ||
|
||
Adapted from mne (mne/utils/docs.py), which was adapted from SciPy (doc/source/conf.py). | ||
""" | ||
import ansys.mapdl.core as pymapdl | ||
|
||
if domain != "py": | ||
return None | ||
|
||
modname = info["module"] | ||
fullname = info["fullname"] | ||
|
||
submod = sys.modules.get(modname) | ||
if submod is None: | ||
return None | ||
|
||
obj = submod | ||
for part in fullname.split("."): | ||
try: | ||
obj = getattr(obj, part) | ||
except AttributeError: | ||
pass | ||
|
||
# deal with our decorators properly | ||
while hasattr(obj, "fget"): | ||
obj = obj.fget | ||
|
||
try: | ||
fn = inspect.getsourcefile(obj) | ||
except Exception: # pragma: no cover | ||
fn = None | ||
|
||
if not fn: # pragma: no cover | ||
try: | ||
fn = inspect.getsourcefile(sys.modules[obj.__module__]) | ||
except Exception: | ||
return None | ||
return None | ||
|
||
repo_path = pymapdl.__file__ | ||
repo_path = repo_path[: repo_path.index("src")] | ||
fn = fn.replace(repo_path, "") | ||
|
||
try: | ||
source, lineno = inspect.getsourcelines(obj) | ||
except Exception: # pragma: no cover | ||
lineno = None | ||
|
||
if lineno and not edit: | ||
linespec = f"#L{lineno}-L{lineno + len(source) - 1}" | ||
else: | ||
linespec = "" | ||
|
||
if "dev" in pymapdl.__version__: | ||
kind = "main" | ||
else: # pragma: no cover | ||
kind = f"release/{'.'.join(pymapdl.__version__.split('.')[:2])}" | ||
|
||
blob_or_edit = "edit" if edit else "blob" | ||
|
||
return f"http://github.com/pyansys/pymapdl/{blob_or_edit}/{kind}/{fn}{linespec}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.