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.

Fix hyperlink rendering in Optax API docs on ReadTheDocs

See original GitHub issue

Currently, the Markdown-flavored links (inside Python files) in Optax API docs (from Python doc strings) appear to not render well on the ReadTheDocs site.

For example, this (source: https://github.com/deepmind/optax/tree/master/optax/_src/alias.py#L322#L374):

def rmsprop(
      ...
) -> base.GradientTransformation:
  """A flexible RMSProp optimiser.
  ...
  References:
    [Tieleman and Hinton, 2012](
        www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf)
    [Graves, 2013](https://arxiv.org/abs/1308.0850)
    ...

translates into this (source: https://optax.readthedocs.io/en/latest/api.html#rmsprop):

image

Potential solutions:

  • Try reStructuredText-flavored formatting for links (since Sphinx likes rST) and see if this fixes the rendering:
`Text <URL>`_

(Source: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#hyperlinks)

  • Alternatively, avoid introducing rST in Python files and, instead, remove Markdown-flavored links ([text](URL)) to keep things simple, like in Haiku docs, since most links are from arXiv and they are quite short:
- [Graves, 2013](https://arxiv.org/abs/1308.0850)
+ Graves, 2013 https://arxiv.org/abs/1308.0850

which is similar to https://dm-haiku.readthedocs.io/en/latest/api.html#id1:

class Linear(hk.Module):
  """Linear module."""

  def __init__(
      ...
  ):
    """Constructs the Linear module.
    Args:
      ...
      w_init: Optional initializer for weights. By default, uses random values
        from truncated normal, with stddev ``1 / sqrt(fan_in)``. See
        https://arxiv.org/abs/1502.03167v3.
image

LMKWYT @mtthss

I can open a PR 👍

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mkuneschcommented, Oct 26, 2021

Since this has been fixed in #126 I’m closing this issue for now. Thanks for reporting!

0reactions
8bitmp3commented, May 22, 2021

@mtthss Let’s try this - from StackOverflow:

  References:
-     Tieleman and Hinton, 2012:
-         www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf
+     Tieleman and Hinton, 2012: www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf # pylint: disable=line-too-long

which should disable pylint=max-line-length=80 for one line only.

https://github.com/deepmind/optax/blob/823af5810cf6af2ee4913771792f42fe24449ee0/.pylintrc#L265

It might help with this TODO: https://github.com/deepmind/optax/blob/823af5810cf6af2ee4913771792f42fe24449ee0/.pylintrc#L267

Also, for multiple lines, this solution could work (based on StackOverflow):

# Disable `pylint` for several lines via `disable` and `enable`: 
# pylint: disable=line-too-long
a_very_long_variable = "Our experiments show that the combination provides state-of-the-art performance on the Atari 2600 benchmark, both in terms of data efficiency and final performance."
another_long_variable = "Pop-Art normalization (van Hasselt et al. 2016) al- lows reward clipping to be removed, while preserving a similar level of performance."
# pylint: enable=line-too-long
Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions - Read the Docs
Frequently Asked Questions¶. My project isn't building correctly¶. First, you should check out the Builds tab of your project. That records all of...
Read more >
Read the Docs Documentation
Read the Docs simplifies software documentation by building, versioning, and hosting of your docs, automatically.
Read more >
optax | Read the Docs
Versions · Repository · Project Slug · Last Built · Maintainers · Badge · Tags · Short URLs.
Read more >
Read the Docs Documentation
This quick start will walk you through creating the basic configuration; in most cases, you can just accept the defaults.
Read more >
NumPyro Documentation - Read the Docs
The model code should look very similar to Pyro except for some minor differences between PyTorch and Numpy's API. See the example below....
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