-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add option matlab_auto_link
#183
Conversation
It would be great if you could extend a class in for instance Also consider other valid "See Also" uses. Functions on the next line.
Napoleon style docstrings: https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html, i.e
|
Do you think it's ready for merging? It look okay to me. |
I don't think we're quite ready, even with the basic "see also" functionality. And there are definitely additional considerations, especially with auto-linking more than "see also" elements. But first, it currently has issues if And, sure enough, if you open Any suggestions for how to fix this? Should I be searching for something other than the key? |
Other considerations, in no particular order ...
|
Ok, I think I fixed this problem. It was an issue with my regex, not what I thought. It was autolinking twice (e.g. once for
... into ...
|
I'm working on refactoring the "see also" autolinking to search the However, I'm not sure I understand the entries in the
But I think the link that works has to be |
So in
It depends, in https://github.com/sphinx-contrib/matlabdomain/blob/81f5f17f6306b2b56a743cb67e9f12a97c710596/sphinxcontrib/mat_documenters.py#LL769C20-L769C20 Maybe this can help you? |
Ah yes, that link about Sphinx cross-referencing is very helpful. I was not aware of that flexibility. And seeing how you handled base class links is helpful too. I'm thinking I might even break some of that code out into its own method so I can reuse it. But the first step for me is to be able to reliably look up an entity given a name, presumably a name in the form that would be used to display it. I think that means:
I think the first two are easy, since the name should already be a key in the Any suggestions? |
The approach I took is to build a dictionary mapping the names without But it appears to work. |
Great job so far. I saw that you had the long names in the |
I believe it does work both ways, depending on the setting of the Would you like me to turn |
Currently just True or False, default is False. In the future we may want to change this to a string with possible values like "see_also", "all" and maybe something inbetween,
Returns a string with the role to be used for references to this type of object (e.g. "class", "func", "meth", "attr").
Changed `matlab_auto_link` option to string value, currently with "see_also" or "all" as valid options.
…Methods:". These are headings in class docstrings that are recognized by MATLAB's `help` and `doc`.
Add negative look-ahead for ` or . or + Avoids turning ... :class:`target.myClass` ... into... :class:`target.:class:`myClass`` etc.
…ink is not None." This reverts commit 9174642.
Look for each entity on “see also” line in the table, rather than the other way around. Adds double-backquoting of unknown entities.
To clarify, currently both the long names and the short names get wrapped with |
…irst. ... including wrapping unknown names in double-backquotes.
I think I know how to do this now, so I'm planning to take a crack at it. This would give us 3 independent types of auto-linking:
How do you think we should structure the options for the user? We could use three individual options, but I can't imagine using the 3rd one and not the first two. Do you have a preference? |
I think a single option to encompass them all would be preferable. We already have lots of options, and documenting them all takes time and effort. Plus, there may be combination that we don't test. I think your suggestion to use: Looking forward when you get further. Keep up the good work :) |
- auto_link_see_also() - auto_link_all()
- fullname() - link()
Only affects names in lines following "<class> Properties:" or "<class> Methods:"
…thin existing links.
…d names in class docstrings.
I think this is pretty much ready for a thorough review. It now has 3 possible values for
I also have an identical branch that has been re-based on the current master. Would you like me to force-push that here? |
Requires matlab_auto_link = "all" and the method name must appear with a trailing () to be auto-linked.
This affected both base class links and auto-linking. The issue was that package names were not being included in the link target.
Ok, I've added a 4th type of auto-linking, included when I could do something similar with property names, but I think it would need some sort of required markup (like the |
On another note, since I was getting some broken links (both base class links and auto-links) with I also fixed the bug that was causing the broken links. We are currently using class links of the form:
But shouldn't the
Then I think I'll really be done with this PR. Once again, is it ok with you for me to force-push a version of this branch that's been rebased on the current master? (I've always preferred rebasing before doing a merge so that all merges are fast-forward.) |
This makes the visible names consistent with the `matlab_short_links` and `matlab_keep_package_prefix` options.
This is excellent work. I'm really impressed :). And yes please force push the branch you want me to merge into master. I'll have time to review it in detail on Tuesday. |
👍 Thanks. |
This is preliminary work to address #178.
As stated there, currently:
matlab_auto_link
config option that currently takes 2 options,"see_also"
and"all"
.ref_role()
method toMatObject
types to return the role to use for references to each type of object.myClass
andmyClassFoo
, it will replacemyClassFoo
with:class:`myClass`Foo
, which isn't quite what we're looking for.