Git Product home page Git Product logo

Comments (12)

electric-coder avatar electric-coder commented on June 11, 2024

Your repo doesn't have any Python class and no Enum as said in the title. This bug report is missing a minimal reproducer.

from sphinx.

trim21 avatar trim21 commented on June 11, 2024

Your repo doesn't have any Python class and no Enum as said in the title. This bug report is missing a minimal reproducer.

Which repo are you talking about?

https://github.com/trim21/sphinx-autodoc_class_signature-bug/blob/ee160815ed1c6217e1e4b9751c7d362453ee4c8a/lib/__init__.py#L4

lib/__init__.py

import enum


class Status(str, enum.Enum):
    """enum for status"""

from sphinx.

picnixz avatar picnixz commented on June 11, 2024

I can confirm the bug but I'm not sure if it's a bug because of the .. autoclass directive or not... Without the directive and by using :members: for .. automodule, the enumeration is being shown normally but using autoclass on the enumeration, it appears that there is an issue...

I can try to fix it but I don't like specializing the behaviours for enums in general because it's an API that is constantly changing... I'll try to see what I can do.

from sphinx.

trim21 avatar trim21 commented on June 11, 2024

interesting, now I can't re-produce this...

from sphinx.

trim21 avatar trim21 commented on June 11, 2024

OK, I'm guessing this only happed on old version of python. I can reproduce this with py 3.9 but not 3.12

from sphinx.

picnixz avatar picnixz commented on June 11, 2024

Oh yes, I was using the same version as you (3.10) and could confirm the bug. That's why I said I hate working with the enum API since it changes every version...

from sphinx.

trim21 avatar trim21 commented on June 11, 2024

I more generic way could be make :exclude-members: __init__ work? I guess?

I don't know how sphinx works internally...

from sphinx.

trim21 avatar trim21 commented on June 11, 2024

Normal class with __new__ only doesn't have this problem...

from sphinx.

picnixz avatar picnixz commented on June 11, 2024

The exclude-members wouldn't work because we are always picking all members before excluding them later. The rationale is because the filtering logic can be changed by the user after. The flow is more or less:

  • Pick everything.
  • Filter when needed.
  • Ask extensions if this should really be filtered.
  • Do your things.

However, the warnings happens before the exclusion is being made (it's trying to pick up every possible members).

from sphinx.

trim21 avatar trim21 commented on June 11, 2024

thanks for your answer.

from sphinx.

picnixz avatar picnixz commented on June 11, 2024

I've found the issue:

if self.config.autodoc_class_signature == 'separated':
self.options = self.options.copy()
# show __init__() method
if self.options.special_members is None:
self.options['special-members'] = ['__new__', '__init__']
else:
self.options.special_members.append('__new__')
self.options.special_members.append('__init__')

It appears we are forcibly assuming that __new__ and __init__ exist, which may not necessarily be the case and you get the warning here:

for name in self.options.members:
if name in members:
selected.append(members[name])
else:
logger.warning(__('missing attribute %s in object %s'),
name, self.fullname, type='autodoc')

So, I should add some if-logic for this warning if the __new__ and __init__ are missing but I won't have much time today.

from sphinx.

trim21 avatar trim21 commented on June 11, 2024

I currently just use workaround with adding :members:

from sphinx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.