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

sub classes appear as miscellaneous #16

Closed
maeddlae opened this issue Jun 28, 2019 · 5 comments · Fixed by #17
Closed

sub classes appear as miscellaneous #16

maeddlae opened this issue Jun 28, 2019 · 5 comments · Fixed by #17

Comments

@maeddlae
Copy link

  • If a class defines a subclass, the subclass appear in summary chapter "miscellaneous"
  • And in autodocsumm, it says "miscallaneous", which is wrong. Correct: "Miscellaneous"
@Chilipp
Copy link
Owner

Chilipp commented Jun 28, 2019

Hi @maeddlae! Thanks again for your report! Could you please be a bit more explicit? Because I could not reproduce this problemDo I get you right, that if you have something like

class A:
    "Doc of A"
    pass

class B(A):
    "Doc of B"
    pass

in a file named test.py, then B appears under the miscellaneous section in

.. automodule:: test
    :autosummary:
    :members:

?

@maeddlae
Copy link
Author

maeddlae commented Jul 4, 2019

Sorry for answering that late. I didn't see your question earlier. Here is an example:

class A():
    """
    Class A docstring
    """    
    class SubClassOfA():
        """
        Class SubClassOfA docstring
        """
    
        def __init__(self):
            """
            Init of class SubClassOfA
            """
            pass
        
    def __init__(self):
        """
        Init of class A
        """
        pass
    
    def met1(self):
        """
        Method 1 of class A
        """
        pass

The generated API then looks like this:
image

@Chilipp
Copy link
Owner

Chilipp commented Jul 5, 2019

Hi @maeddlae! Thanks for the clarification 😄 As workaround, you can define your own grouper in conf.py, for example

def grouper(app, what, name, obj, section, parent):
    if isinstance(obj, type) and isinstance(parent, type):
        return "Class"

def setup(app):
    app.connect('autodocsumm-grouper', grouper)

However, we can also change the current behaviour of autodocsumm. Any suggestion, under which section the SubClassOfA should appear? Maybe Member classes?

@maeddlae
Copy link
Author

maeddlae commented Jul 8, 2019

Hmm, I would say just "Class" would be ok. But Python calls them "Inner Class" or "Nested Class", see https://pythonspot.com/inner-classes/.

Chilipp added a commit that referenced this issue Jul 8, 2019
This commit fixes #16
and adds a new *Classes* section for the AutoSummClassDocumenter
@Chilipp Chilipp mentioned this issue Jul 8, 2019
@Chilipp
Copy link
Owner

Chilipp commented Jul 8, 2019

Agreed. I just implemented the necessary changes in #17 which then closes this issue. Would you mind confirming that it fulfills the request?

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 a pull request may close this issue.

2 participants