ansys / ansys-sphinx-theme

PyData-based Sphinx theme from the PyAnsys community
https://sphinxdocs.ansys.com
MIT License
22 stars 5 forks source link

autoapi class.rst doesn't render multiple return types #323

Open pkrull-ansys opened 10 months ago

pkrull-ansys commented 10 months ago

🔍 Before submitting the issue

🐞 Description of the bug

    @property
    def geometry(self) -> StlFile | BuildFile:
        """Part geometry."""
        return self._geometry

renders as image

📝 Steps to reproduce

Write a class property or method that returns multiple possible types and annotate it using 3.10+ annotation style. Generate documentation using autoapi and ansys-sphinx-theme. Only the last return type is shown in the generated docs.

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

24.1

🐍 Which Python version are you using?

3.9

📦 Installed packages

ansys-api-additive==1.4.1
ansys-api-platform-instancemanagement==1.0.0
ansys-platform-instancemanagement==1.1.2
ansys-templates==1.7.0
arrow==1.3.0
binaryornot==0.4.4
bleach==6.1.0
bokeh==3.3.0
cachetools==5.3.2
certifi==2023.7.22
cfgv==3.4.0
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
contourpy==1.1.1
cookiecutter==2.2.3
coverage==7.3.2
dill==0.3.7
distlib==0.3.7
exceptiongroup==1.1.3
filelock==3.13.1
google-api-core==2.12.0
google-api-python-client==2.106.0
google-auth==2.23.4
google-auth-httplib2==0.1.1
googleapis-common-protos==1.61.0
grpcio==1.59.2
grpcio-health-checking==1.48.2
httplib2==0.22.0
identify==2.5.31
idna==3.4
importlib-metadata==6.8.0
iniconfig==2.0.0
isort==5.12.0
Jinja2==3.1.2
linkify-it-py==2.0.2
Markdown==3.5.1
markdown-it-py==3.0.0
MarkupSafe==2.1.3
mdit-py-plugins==0.4.0
mdurl==0.1.2
nodeenv==1.8.0
numpy==1.26.1
packaging==23.2
pandas==2.1.2
panel==1.3.1
param==2.0.0
Pillow==10.1.0
platformdirs==3.11.0
plotly==5.18.0
pluggy==1.3.0
pre-commit==3.5.0
protobuf==3.20.3
pyasn1==0.5.0
pyasn1-modules==0.3.0
pyparsing==3.1.1
pyproject-api==1.6.1
pytest==7.4.3
pytest-cov==4.1.0
python-dateutil==2.8.2
python-slugify==8.0.1
pytz==2023.3.post1
pyviz_comms==3.0.0
PyYAML==6.0.1
requests==2.31.0
rsa==4.9
six==1.16.0
tenacity==8.2.3
text-unidecode==1.3
tomli==2.0.1
tornado==6.3.3
tox==4.11.3
tqdm==4.66.1
types-python-dateutil==2.8.19.14
typing_extensions==4.8.0
tzdata==2023.3
uc-micro-py==1.0.2
uritemplate==4.1.1
urllib3==2.0.7
virtualenv==20.24.6
webencodings==0.5.1
xyzservices==2023.10.1
zipp==3.17.0
RobPasMue commented 10 months ago

This is more of a sphinx-autoapi issue if I am not mistaken. Assigning to @jorgepiloto

jorgepiloto commented 10 months ago

Thanks for the ping. Roberto is right, we need to check if this comes from our class.rst template or it originates in the internals of sphinx-autoapi.

jorgepiloto commented 7 months ago

I thought the | symbol for representing a union was only supported in Python 3.10+. Could you try using:

from typing import Union

  @property
    def geometry(self) -> Union[StlFile, BuildFile]:
        """Part geometry."""
        return self._geometry

This also ensures compatibility with 3.9.

pkrull-ansys commented 7 months ago

@jorgepiloto The source file contains from __future__ import annotations. I'd prefer to keep the 3.10+ type specifications if possible.