AnswerDotAI / AnswerDotAI/nbdev

[FR] Make it easier to show source in docs for thin classes

Open
#1,459 0 comments 0 reactions 0 assignees View on GitHub
bug
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)
```
![image](https://github.com/user-attachments/assets/9b8185e2-94a2-4a85-8c61-461517a336fd)

# 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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.