Skip to content
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

Using custom edit link #2012

Merged
merged 24 commits into from
Apr 26, 2023
Merged

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Apr 23, 2023

Fixing links in examples.

I also added a hack where everytime you click on "edit on Github" button in a page generated using _autosummary directive, it will take you to a github search page which follow the following approach:

Given chain_commands:
https://mapdl.docs.pyansys.com/version/stable/api/_autosummary/ansys.mapdl.core.Mapdl.chain_commands.html#chain-commands

The button will generate the following github search query:

https://github.com/search?q=repo%3Apyansys%2Fpymapdl+path%3A**%2Fansys%2Fmapdl%2Fcore%2FMapdl.py+chain_commands+def+class&type=code

where:

  • repo%3Apyansys%2Fpymapdl: is to search only in PyMAPDL repo
  • path%3A**%2Fansys%2Fmapdl%2Fcore%2FMapdl.py is to search in the file mapdl.py in ansys/mapdl/core which is read from the object definition ansys.mapdl.core.mapdl.chain_commands.
  • chain_commands+def+class: extra keywords to increase the possibilities to hit the definition line.
  • type=code: to specify to search in code only

Caveats:

  1. The path part is not very reliable. For example, it will fail with launch_mapdl because it is defined in launcher.py but imported at the root level (__init__.py).

Fix #2006

References:

@github-actions github-actions bot added the Documentation Documentation related (improving, adding, etc) label Apr 23, 2023
@codecov
Copy link

codecov bot commented Apr 23, 2023

Codecov Report

Merging #2012 (ed7ca5a) into main (a25fa9e) will decrease coverage by 3.47%.
The diff coverage is 93.66%.

@@            Coverage Diff             @@
##             main    #2012      +/-   ##
==========================================
- Coverage   82.98%   79.51%   -3.47%     
==========================================
  Files          44       45       +1     
  Lines        7932     7917      -15     
==========================================
- Hits         6582     6295     -287     
- Misses       1350     1622     +272     

Fixing also main methods (from autosummary) links
@germa89 germa89 requested a review from akaszynski April 23, 2023 11:55
@germa89
Copy link
Collaborator Author

germa89 commented Apr 23, 2023

Pinging @Revathyvenugopal162 and @jorgepiloto because I think the approach developed here can be useful to implement in the ansys-sphinx theme, especially the part for the examples (which is completely robust).

@germa89
Copy link
Collaborator Author

germa89 commented Apr 23, 2023

Mitigated Caveat 1 by replacing all the ansys.mapdl.core.launch_mapdl references by ansys.mapdl.core.launcher.launch_mapdl.

@akaszynski
Copy link
Collaborator

@germa89, I had struggled with this for a while and I really like how you implemented it. I also implemented it in pyvista/pyvista#4320, and was able to resolve the "hack" by resolving the location of the object within GitHub's path. This greatly simplified the code.

I recommend you implement the following:

  • Move html_page_context to a ansys.mapdl.core.docs module. This will help us prepare for a potential improvement in ansys-sphinx-theme.
  • Copy/paste linkcode_resolve and change the module and url. I already borrowed this from mne.

@germa89
Copy link
Collaborator Author

germa89 commented Apr 24, 2023

I had struggled with this for a while and I really like how you implemented it.

doc/source/conf.py Outdated Show resolved Hide resolved
doc/source/conf.py Outdated Show resolved Hide resolved
doc/source/conf.py Outdated Show resolved Hide resolved
@germa89 germa89 self-assigned this Apr 26, 2023
@germa89 germa89 requested a review from akaszynski April 26, 2023 07:00
Copy link
Contributor

@clatapie clatapie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@akaszynski
Copy link
Collaborator

Merging and ignoring codecov. It's close enough.

@akaszynski akaszynski merged commit a0d9e6e into main Apr 26, 2023
21 of 24 checks passed
@akaszynski akaszynski deleted the doc/fixing-edit-button-link-on-examples branch April 26, 2023 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Documentation related (improving, adding, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edit on GitHub for gallery
3 participants