Sphinx: Regression: autodoc Dataclass variables reference target not found

Created on 8 Jul 2020  路  3Comments  路  Source: sphinx-doc/sphinx

Describe the bug

When I use sphinx.ext.autodoc and nitpicky = True with my code which includes a dataclass with a variable of a custom type, I get a warning.

To Reproduce

Open the attached project sphinx-example.zip.
Install Sphinx.
Run sphinx-build -M html source/ build/.

Expected behavior

I expect there to be no warning, or a clear message saying how I can avoid this warning.

Your project

sphinx-example.zip

Environment info

macOS latest
Python 3.7.7
Sphinx 3.1.2 (reproducible also with 3.1.0 but not 3.0.4)

bug py

Most helpful comment

A Dockerfile to reproduce the error:

FROM python:3.7-slim

RUN apt update; apt install -y build-essential curl git make unzip vim
RUN curl -LO https://github.com/sphinx-doc/sphinx/files/4890646/sphinx-example.zip
RUN unzip sphinx-example.zip
WORKDIR /sphinx-example
RUN pip install -U sphinx
RUN sphinx-build -NTvv source/ build/html/

All 3 comments

Thank you for reporting.

Note: Internally, the autodoc generates the following code:

.. py:module:: example


.. py:class:: Report(status: example.Statuses)
   :module: example


   .. py:attribute:: Report.status
      :module: example
      :type: Statuses


.. py:class:: Statuses()
   :module: example

It seems the intermediate code is good. But py:attribute class does not process :type: Statuses option well.

A Dockerfile to reproduce the error:

FROM python:3.7-slim

RUN apt update; apt install -y build-essential curl git make unzip vim
RUN curl -LO https://github.com/sphinx-doc/sphinx/files/4890646/sphinx-example.zip
RUN unzip sphinx-example.zip
WORKDIR /sphinx-example
RUN pip install -U sphinx
RUN sphinx-build -NTvv source/ build/html/

@tk0miya - It is great to see such open and quick progress. Thank you for your hard work on this.

Was this page helpful?
0 / 5 - 0 ratings