Skip to content

Add helper function to re-route missing references - #1

Merged
inducer merged 3 commits into
inducer:mainfrom
alexfikl:hack-missing-refs
Jul 29, 2025
Merged

Add helper function to re-route missing references#1
inducer merged 3 commits into
inducer:mainfrom
alexfikl:hack-missing-refs

Conversation

@alexfikl

Copy link
Copy Markdown
Contributor

xref: inducer/modepy#130

This also:

  • Adds types (like suggested in the modepy PR) to linkcode_resolve also.
  • Switches to ruff for linting and cleans up some small random things.

Comment thread sphinxconfig.py Outdated
Comment on lines +116 to +124
if module:
node.attributes["py:module"] = module

# FIXME: this is probably very brittle. do we need more info to rename?
target = target.split(".")[-1]
if "." not in module:
target = f"{module}.{target}"

node.attributes["reftarget"] = target

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't have much faith in this module renaming here. It seemed to work in modepy, but I'll try to do another lib (pymbolic?) to see what else would be needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reworked this to be less weird, so hopefully it's fine now. I'll still try doing pymbolic as well.

Comment thread sphinxconfig.py Outdated
Comment thread sphinxconfig.py Outdated
.. code:: python

autodoc_missing_reference_aliases = {
"numpy.float64": ("numpy", "numpy", "attr"),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know if it's worth making this smarter?

We could probably get away with setting it to something like py:attr:numpy.float64 and start checking if it's in an intersphinx inventory, parsing the module name, etc.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm OK leaving it to be as smart as it is now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and made this a string to parse.. mostly because autodoc_type_aliases seems to work like that.

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks!

Comment thread pyproject.toml
Comment thread sphinxconfig.py Outdated
.. code:: python

autodoc_missing_reference_aliases = {
"numpy.float64": ("numpy", "numpy", "attr"),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm OK leaving it to be as smart as it is now.

Comment thread sphinxconfig.py Outdated
Comment thread sphinxconfig.py Outdated
@alexfikl
alexfikl force-pushed the hack-missing-refs branch 3 times, most recently from 4e10e38 to c53265d Compare July 29, 2025 17:40
@inducer

inducer commented Jul 29, 2025

Copy link
Copy Markdown
Owner

@alexfikl

alexfikl commented Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

I have a lovely use case for this FWIW: inducer/pytential/actions/runs/16602951915/job/46967330727?pr=267

😁

Switched the modepy PR inducer/modepy#130 to this and it seems to be working nicely! 🎉
Let me know if there's any issue in pytential.

@inducer

inducer commented Jul 29, 2025

Copy link
Copy Markdown
Owner

Heh. I just hit the bug you just fixed in pytential! 👍

This works nicely for me, I'd say it's ready to roll.

@alexfikl
alexfikl marked this pull request as ready for review July 29, 2025 19:14
@alexfikl

Copy link
Copy Markdown
Contributor Author

This works nicely for me, I'd say it's ready to roll.

Seems good to me too! pymbolic is also working as far as I can tell (just need to fix pyright 😁).

@inducer
inducer merged commit 849e15b into inducer:main Jul 29, 2025
2 checks passed
@inducer

inducer commented Jul 29, 2025

Copy link
Copy Markdown
Owner

Thanks for making this happen!

@alexfikl
alexfikl deleted the hack-missing-refs branch July 29, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants