Skip to content

[Documentation] Autogenerate the Attributes section for all classes #5242

@harshil21

Description

@harshil21

Currently, we manually write out the Attributes section for every single class. Almost all attributes are simply copied over from the Args section and only a few things change, for the majority of cases:

  1. The , optional -> Optional.
  2. Sequence[...] -> tuple[...]

I propose automating this task. This would help delete thousands of lines of code, make reviewing faster, reduce package size, and also help eliminate a whole class of documentation bugs.

How would this be done? We already do something very similar with the Bot keyword argument insertion and with #5241. This would be done in a similar manner:

  1. Check if the class has a public attribute not already documented
  2. If it does, skip, since this was manually documented (perhaps because it's an edge case)
  3. If it does not, look at the Args section to see if we have the same name so we can copy over the description
  4. If we do, copy the description, admonitions (like the versionchanged) and apply the transforms as mentioned above
  5. If we don't, raise a warning, telling the user to manually document since nothing suitable could be found to copy.

There are probably going to be a few edge cases with this logic, which is why the ability to manually document some attributes is a good middle ground.

Metadata

Metadata

Assignees

Labels

Priority

Low

Effort

High

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions