Move class attributes to a more relevant location
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 106
- Forks
- 223
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 72
Description
In class docstring, you can write the Attributes: to enumerate what attributes are available, like MyClass.my_attribute. This is different than the class constructor arguments, like MyClass(my_attribute=1) -- the attributes might not equal the class constructor args.
These attributes are similar to properties from @propery methods, and from class attributes from code values like CLASS_ATTRIBUTE = 1. But one big difference is they are defined in the class docstring directly, like this:
We correctly recognize them as <Attribute> components, but we do two confusing things:
- If there's a type hint, we render the
typeas**type**so it's bold. It would be better to inline the type so that it'ssize: str. - The attributes show up in the class description, rather than the
## Attributessection where we normally put things. This mirrors Sphinx's behavior, but I think Sphinx is confusing. Ideally we could move these attributes to instead live in the## Attributessection underneath the class description and constructor.
This is the HTML:
This is the MDX from our conversion pipeline (this was before we had the <Attribute> component set up):
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the qiskit-sphinx-theme example_docs/api_example/electron.py output with the referenced HTML and the scripts/lib/api/snapshots/conversionPipeline.test.ts.snap entry. Trace the conversion pipeline and Attribute component handling, then verify that typed attributes render inline and appear in the Attributes section beneath the class description and constructor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100