Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning about unparseable C++ cross-reference when #499

Open
arwedus opened this issue Oct 30, 2024 · 1 comment
Open

Warning about unparseable C++ cross-reference when #499

arwedus opened this issue Oct 30, 2024 · 1 comment
Labels
Needed: Reproduction Case This issue needs a small test case to reproduce the issue before it can be worked on

Comments

@arwedus
Copy link

arwedus commented Oct 30, 2024

When I parse a function that's including a custom type based on enum.IntEnum with sphinx-autoapi,

I get this warning:

/workspace/docstring of converters.ros_streamer.VerbosityLevel:1: WARNING: Unparseable C++ cross-reference: 'enum.IntEnum'
Error in cross-reference.
If shorthand ref:
  Invalid C++ declaration: Expected identifier in nested name, got keyword: enum [error at 4]
    enum.IntEnum
    ----^
If full function ref:
  Error when parsing function declaration.
  If the function has no return type:
    Error in declarator or parameters-and-qualifiers
    Invalid C++ declaration: Expected identifier in nested name, got keyword: enum [error at 4]
      enum.IntEnum
      ----^
  If the function has a return type:
    Invalid C++ declaration: Expected identifier in nested name. [error at 4]
      enum.IntEnum
      ----^

The code looks like this:

.. autoapifunction:: converters.ros_converter.ros_to_hdf


.. autoapimodule:: converters.containers
   :members:
   :undoc-members:
# ros_converter.py
from containers import VerbosityLevel

def ros_to_hdf(
    bag,
    hdf_file=None,
    verbosity=VerbosityLevel.NONE,
    topics=None,
):
    pass
# containers.py
from enum import IntEnum

class VerbosityLevel(IntEnum):
    """Defines verbosity levels."""

    NONE = 0
    LOW = 1
    HIGH = 2
    DEBUG = 3

Version info

Python: 3.8
Sphinx: 7.1.2
sphinx-autoapi: 3.3.2

config

# conf.py

# I'm configuring autoapi_dirs to include the referenced code directory...

autoapi_generate_api_docs = False
autoapi_python_use_implicit_namespaces = True
autoapi_python_class_content = "both"
autodoc_typehints = "description"
@AWhetter
Copy link
Collaborator

Do you have primary_domain set to cpp?
Without being able to see the docstring of converters.ros_streamer.VerbosityLevel, I'm guessing it's doing something like :obj:`enum.IntEnum`, which if primary_domain = 'cpp' means that you'll need to do :py:obj:`enum.IntEnum`.
Do you have a more complete example?

@AWhetter AWhetter added the Needed: Reproduction Case This issue needs a small test case to reproduce the issue before it can be worked on label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: Reproduction Case This issue needs a small test case to reproduce the issue before it can be worked on
Projects
None yet
Development

No branches or pull requests

2 participants