0

I'm aware of how to exclude files from Sphinx.

However, a handful of my code uses the standard pattern of:

import torch.tensor as T

T then ends up getting the torch tensor documentation in my modules. How can I avoid this?

I am using these sphinx extensions:

extensions = [
    "sphinx.ext.autodoc",
    "sphinx.ext.intersphinx",
    "sphinx_rtd_theme",
]

Here are example warnings from make html:

/Users/joseph/dev/torchsynth/torchsynth/parameter.py:docstring of torchsynth.parameter.T:1: WARNING: Inline emphasis start-string without end-string.
/Users/joseph/dev/torchsynth/torchsynth/util.py:docstring of torchsynth.util.T:1: WARNING: Inline emphasis start-string without end-string.

For example, in torchsynth/parameter.py the imports are

from typing import Optional

import torch
import torch.nn as nn
from torch import tensor as T

This is the sphinx branch in github. We just started writing our sphinx docs, so please be gentle.

Our rst files right now are just skeletons. For example, module.rst is:

torchsynth
==========

.. toctree::
   :maxdepth: 4

   torchsynth

You can see other rsts here in the branch.

Attached is a screenshot of my py-modindex.py:

enter image description here

You can see the floating 't' at the top left. The plus/minus button is overly scaled, I think I need to adjust the theme, but that's not my issue.

Joseph Turian
  • 15,430
  • 14
  • 47
  • 62
  • Which Sphinx extension are you using that yield this result? autogen, autodoc, autosummary, something else? Your question lacks sufficient information to replicate your issue. – Steve Piercy Mar 11 '21 at 04:47
  • I have edited my comment with the sphinx extensions I am using – Joseph Turian Mar 11 '21 at 05:28
  • autodoc is the sphinx extension I'm using but I'm open to alternatives – Joseph Turian Mar 11 '21 at 05:29
  • 1
    I don't understand what you mean by *"T then ends up getting the torch tensor documentation in my modules"*. Can you post an MRE? An example `.rst` and `.py` preferably showing the output HTML? – bad_coder Mar 11 '21 at 05:36
  • @bad_coder I have updated the question with more information and a link to our documentation branch. – Joseph Turian Mar 12 '21 at 07:36
  • Putting docstrings at the start of the file might be the reason you get the warnings. Try using Python comment instead. After that, I am with @bad_coder in that I do not understand your statement, even after you have updated your question. It makes no sense. – Steve Piercy Mar 12 '21 at 12:34
  • @StevePiercy I have removed the docstrings at the top and rebuilt, but I still have the issue. I will attach a screenshot. – Joseph Turian Mar 12 '21 at 18:43

0 Answers0