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

Filtering attributes with members does not work as advertised #142

Closed
hamelsmu opened this issue May 17, 2023 · 3 comments
Closed

Filtering attributes with members does not work as advertised #142

hamelsmu opened this issue May 17, 2023 · 3 comments

Comments

@hamelsmu
Copy link
Collaborator

The docs state that members can be used to filter attributes

image

But this is not the case. values for the members field only seem to filter methods, and all attributes are shown. In fact, I don't think there is a way to filter attributes in the config?

@machow
Copy link
Owner

machow commented May 17, 2023

It seems like there may be two forces at play here:

  • If a class has an Attributes section of its docstring, then it gets rendered
  • objects like classes and modules can also have individual attributes documented, similar to documenting methods.
    • in this case, members should let you filter what gets documented

I wonder what should happen in the case where an Attributes section exists AND members is specified? In any event, it makes sense that this behavior is confusing. I can take a quick look at how other tools handle this tomorrow....

@machow machow added this to quartodoc May 18, 2023
@machow
Copy link
Owner

machow commented May 18, 2023

It looks like mkdocstrings (which is super great) just renders everything, if you have it:

  • an Attributes section in your docstring
  • individual attribute member docs (specified by the members option).
    • these are automatically included if members is unspecified, and the attribute has a docstring

I can tee up work to do the same thing (so that metaflow.Current attributes will get automatically documented). I wonder if, once it's in place, that will reduce the confusion of trying to filter an Attributes section. I can see how documenting attributes 2 ways has the potential to create a lot of confusion.

mkdocstring example

Here's a fairly involved example.

class SomeClass:
    """Some cool class

    Parameters
    ----------
    c:
        woah man

    Attributes
    ----------
    a:
        The a attribute
    b:
        The b attribute
    """

    a: int
    b: int
    """Another thing."""


    def __init__(self, c: float):
        self.c = c
        """The c attribute"""
image

@machow
Copy link
Owner

machow commented Aug 21, 2024

Let's track in this issue, which discusses more on rendering the attributes section, vs attributes individually:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants