AnswerDotAI / AnswerDotAI/nbdev

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

Aperta
#1,459 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Jupyter Notebook
Stelle
5.3k
Fork
513
Merge medio
2g 30m
PR unite (30g)
8

Descrizione

# 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)`

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dal punto di ingresso show_doc di nbdev e riproduci l’esempio Colors per esaminare come viene attualmente renderizzata una classe sottile. Segui il percorso di rendering della documentazione, quindi verifica che una variante opt-in con full_source=True mostri il codice sorgente completo della classe, mentre il comportamento esistente di show_doc(Colors) rimanga invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
jupyter, python
Ambito
documentation
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.