question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[docs] [sphinx] need to resolve cross-references for inherited/mixin methods

See original GitHub issue

🚀 Feature request

T5ForConditionalGeneration inherits generate from PreTrainedModel via GenerationMixin.

Currently in our docs if we write:

for more info see :meth:`transformers.T5ForConditionalGeneration.generate`

it doesn’t get resolved in the html docs (it doesn’t get a xref link, but leaves it as a text)

Neither transformers.PreTrainedModel.generate gets resolved - which is the super-class that has this method.

But since it’s a mixin and actually comes from transformers.generation_utils.GenerationMixin the only way to get the cross-reference turned into a working link is to write:

for more info see :meth:`transformers.generation_utils.GenerationMixin.generate`

which is slow and complicated to figure out and non-intuitive. And this was just one example.

Both @sgugger and I tried to find a sphinx configuration to make it resolve transformers.T5ForConditionalGeneration.generate to transformers.generation_utils.GenerationMixin.generate and point to the right doc entry, but didn’t succeed.

This could be related to the fact that we don’t generate docs for inherited methods and only document them in the parent class. We want to keep it that way but to be able to cross-reference the inherited methods in the docstrings.

If you perhaps have an expertise in sphinx and could help us resolve this it’d be absolutely amazing!

T5 was just an example, this is needed for dozens of models.

If there is no way to currently do it you could also submit a feature request with sphinx and take a lead on following through for this new feature to be added.

Bonus:

As explained above we don’t duplicate inherited methods docs, but it’d be really useful to list the inherited methods which didn’t get documented in the sub-classes, e.g.: https://huggingface.co/transformers/model_doc/t5.html#tft5forconditionalgeneration could have a brief entry:

Inherited methods: generate, greedy_search, sample, beam_search, beam_sample, group_beam_search

with cross-references to the corresponding full doc entries in the super-class. Of course, while this could be created manually, it’d be very difficult to maintain - so we need to this to be autogenerated.

Thank you!

Related issues/prs:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
01-vyomcommented, May 5, 2021

@stas00 Sorry, I won’t be able to work on this issue as I am working on some other problems. You can review any other PR for this issue.

1reaction
stas00commented, Apr 28, 2021

I don’t know where @frankhart2018 is with his experiments, as 3 weeks have passed, so probably there is no harm in having another person try to solve this. So please go for it, @01-vyom. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cross-referencing with Sphinx - Read the Docs
You can cross reference more than just pages and section headers. This page describes some best-practices for cross-referencing with Sphinx with two markup ......
Read more >
Cross referencing breaks for inherited objects imported and ...
I'm trying to get my Sphinx documentation build correctly and have cross-references (including those from inherited relations) work right.
Read more >
Sphinx cross referencing breaks for inherited objects imported ...
If I look at the generated documentation for class B , then I verify it is not properly linked against class A ,...
Read more >
Sphinx Documentation - Read the Docs
Sphinx Documentation, Release 1.7.9. And now, you can write a cross-reference like :py:func:`io.open`. Any cross-reference that has no.
Read more >
Domains - Sphinx documentation
Directive and role names in a domain have names like domain:name ... For cross-reference roles provided by domains, the same facilities exist as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found