sphinx-doc / sphinxcontrib-django

This is a sphinx extension which improves the documentation of Django apps.
https://pypi.org/project/sphinxcontrib-django/
Apache License 2.0
43 stars 25 forks source link

option not to override Model field docstrings? #12

Closed n2ygk closed 5 years ago

n2ygk commented 5 years ago

Documentation of my class members is ignored. Is there a way to configure to use provided docstrings, if present?

For example:

class CommonModel(models.Model):
    """
    Abstract :py:class:`~django.db.models.Model` with common fields for all "real" Models
    """
    #: globally unique id (UUID4)
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    #: date when this model instance becomes "active"
    effective_start_date = models.DateField(default=None, blank=True, null=True)
    #: date when this model instance becomes inactive
    effective_end_date = models.DateField(default=None, blank=True, null=True)
    #: who last modified this instance
    last_mod_user_name = models.CharField(default=None, null=True, max_length=80)
    #: when they modified it.
    last_mod_date = models.DateField(auto_now=True)

    class Meta:
        #: this is an abstract model
        abstract = True

When rendered with this package, it looks like this:


Parameters: * id (UUIDField) – Id
            * effective_start_date (DateField) -- Effective start date
            * effective_end_date (DateField) -- Effective end date
            * last_mod_user_name (CharField) -- Last mod user name
            * last_mod_date (DateField) -- Last mod date

id
Model field: id

effective_start_date
Model field: effective start date

...

without the package, like this (without the Parameters block and with the comments):

id
globally unique id (UUID4)

effective_start_date
date when this model instance becomes “active”

...

I've tried both with #: comments before and docstrings after each member.

I've also tried setting help_text which changes the Parameters display but not the members. I have these autodoc settings in conf.py:

autodoc_member_order = 'bysource'
autodoc_inherit_docstrings = False

and I run apidoc like this: sphinx-apidoc -e -T -M -f -o apidoc ../myapp

And, unfortunately, if I don't use this package and don't document every member, I get this for each undocumented member:

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

So I really want to use this but want my docstrings to be used if present!

rixx commented 5 years ago

If you use :param field_name: field description, my PR at #16 will resolve this issue.

vdboor commented 5 years ago

PR #16 got merged, so closing this one now!