AnswerDotAI / AnswerDotAI/nbdev
[FR] Make it easier to show source in docs for thin classes
- Dominant language
- Jupyter Notebook
- Stars
- 5.3k
- Forks
- 513
- Avg merge
- 2d 30m
- Merged PRs (30d)
- 8
Description
# Minimally reproducible example:
```python
from enum import Enum # StrEnum for python >= 3.12
from nbdev import show_doc
class Colors(str, Enum): # Or `StrEnum` if on python >= 3.12
"Enum with the valid colors we can use in our package"
RED = "red"
GREEN = "green"
BLUE = "blue"
show_doc(Colors)
```

# Issue description
This it not really a bug, more like a feature request. When defining thin classes, such as enums or dataclasses, the documentation for those classes shows a very uninformative `ClassName (*values)`.
For this use case, it would be really useful to have an option that would allow inlining the entire class source in the docs, to get a view of all the possible values. To avoid breaking existing code this could be implemented as an optional argument to the `show_doc` method, so to enable this one would do something like `show_doc(Colors, full_source=True)`
Contributor guide
Research direction
Start at nbdev's show_doc entry point and reproduce the Colors example to inspect how a thin class is currently rendered. Trace the documentation rendering path, then verify that an opt-in full_source=True form shows the complete class source while existing show_doc(Colors) behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter, python
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100