Skip to content

Conversation

@Miauwkeru
Copy link
Collaborator

@Miauwkeru Miauwkeru commented Aug 28, 2025

There is an issue with sphinx generating warnings due to duplicate object entries

From what I found out, it only occurs in dissect-docs, this is not an issue when using docs-build
in other projects.

What I think the issue might be is that this issue occurs due to shadowing of modules, and sphinx not knowing how or what.
For example, with the following construction:

dissect.cstruct:
   __init__.py:
     from dissect.cstruct.cstruct import cstruct
     __all__ = ["cstruct"]
   cstruct.py:
     class cstruct: ...

Sphinx sees both dissect.cstruct.__init__.cstruct and dissect.cstruct.cstruct as conflicting/duplicate object entries.
I assume this happens because the one in the __init__.py file shadows the module cstruct in the same directory.

My current fix is skip generating rst for the cstruct class inside api/dissect/cstruct/index and only render it in api/dissect/cstruct/cstruct/index.

An alternative method is avoid generating class definitions exposed by __init__.__all__ at all inside api/dissect/cstruct/index this would remove all those classes below Functions.

@Schamper
Copy link
Member

The current proposed solution looks extremely flakey. This is a super common Python idiom, surely there's a better workaround?

@Miauwkeru
Copy link
Collaborator Author

The current proposed solution looks extremely flakey. This is a super common Python idiom, surely there's a better workaround?

I am completely aware it is flakey. i was first looking into ignoring these warnings all together. But it doesn't look like these warnings can be suppressed. As i checked the suppressing code during generation and this specific warning does not have an associated type and his warning does not have an associated type or subtype. Both of these are None

Even then, the other solution would be the alternative I described above, or not treating warnings as errors for the readthedocs build, and see whether we can send in a patch to sphinx to make it possible to suppress these warnings.

@Miauwkeru Miauwkeru mentioned this pull request Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants