I will address each part of your questions.
Why is consulting the online documentation insufficient? I think most developers build Django projects while referencing the online documentation rather than while reading Django’s source code.
Having documentation available within the IDE really raises the developer experience.
For those with a Visual IDE it’s shown on hover, and even for those with a text editor they could see that docstring if they “click-into” the class/function/argument/parameter.
What sort of documentation would be inlined?
I will try to explain below how I think the separation of API Reference and Guides should be done.
Would this require a large amount of duplication between docs and source code?
God Forbid! Sphinx has autodoc which convert doctrings to reStructuredText.
Why does adding docstrings require pyi files?
It isn’t required but it would help. I imagine that with some stub magic it would be possible to get docstrings applied onto a Meta class that doesn’t actually inherit anything
class CustomUser(models.Model): class Meta: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< verbose_name = _("user")Are there other projects that use the approach you suggest?
Pretty much everything else.
Some mix docstrings and handwritten docs into 1 really nice API reference
Others write a regular guide separately, but generate API reference from docstrings
I could go on and on, but I’ve never come across a package that does not utilize docstrings at all.
Thanks!
Django’s API Reference is more like a guide than an actual Reference at this point.
I’m proposing as follows:
Django uses a lot of bootstrap/runtime patching under the hood, from custom metaclasses, explicit injection
pattern up to proxies at various ends.
I understand this is true on low level APIs and on classes we implement ourselves (Like passing the correct arguments when creating a django model).
But almost all the documentation in ref is connected to a class, function, method etc. This can be pushed into the source code and autodoced quite easily.
Anything that can’t be in a class can stay the way it is. Correct me if I’m wrong, It is almost certain that I am.
(Adding inline docs to django-stubs would help mitigate this, but coordinating documentation between 2 different projects would be a nightmare.)
I only see 2 downsides to my proposal: