Code

Opened 4 years ago

Closed 3 years ago

#14183 closed Bug (worksforme)

Geodjango models broken with pydoc

Reported by: dzwarg Owned by: dariog
Component: GIS Version: 1.1
Severity: Normal Keywords: pydoc
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It's not possible to generate docs with pydoc for geographic models.

Use this as pydoctest/geotest/models.py:

"""
Models to test pydoc.

I'm writing some DocStrings to test pydoc and geodjango.
"""

# 1) Test that pydoc creates good docs with this line:
from django.db import models

# 2) Test that pydoc creates bad docs with this line:
#from django.contrib.gis.db import models

# Create your models here.
class TestGeoModel(models.Model):
    """This is a geographic model.

    It is very complicated, thus the enormously long docstring."""
    name = models.CharField(max_length=50)
    area = models.IntegerField()
    lon = models.FloatField()
    lat = models.FloatField()
    # 2) Uncomment these lines to generate bad docs with gis models:
    #geom = models.PolygonField()
    #objects = models.GeoManager()

    class Meta:
        """A meta class helper for TestGeoModel.

        This meta class tells me how to pluralize the name of TestGeoModel."""
        verbose_name_plural = 'TestGeoModelles'

    def __unicode__(self):
        """Get a unicode representation of this object (it's just its name)."""
        return self.name

Steps to reproduce:

  1. django-admin startproject pydoctest
  2. cd pydoctest
  3. django-admin startapp geotest
  4. edit settings.py -- use a spatial db, like spatialite, add geotest to INSTALLED_APPS
  5. cd ..
  6. export DJANGO_SETTINGS_MODULE=pydoctest.settings
  7. pydoc pydoctest.geotest.models
  8. Observe: Good docs!
    Help on module pydoctest.geotest.models in pydoctest.geotest:
    
    NAME
        pydoctest.geotest.models - Models to test pydoc.
    
    FILE
        /tmp/pydoctest/geotest/models.py
    
    DESCRIPTION
        I'm writing some DocStrings to test pydoc and geodjango.
    
    CLASSES
        django.db.models.base.Model(__builtin__.object)
            TestGeoModel
    
        class TestGeoModel(django.db.models.base.Model)
         |  This is a geographic model.
         |
         |  It is very complicated, thus the enormously long docstring.
         |
         |  Method resolution order:
         |      TestGeoModel
         |      django.db.models.base.Model
         |      __builtin__.object
    ...etc
    
  9. In pydoctest/geotest/models.py, comment out line 8.
  10. In pydoctest/geotest/models.py, uncomment line 11, 23, 24.
  11. pydoc pydoctest.geotest.models
  12. Observe: Bad docs!
    Help on module pydoctest.geotest.models in pydoctest.geotest:
    
    NAME
        pydoctest.geotest.models - Models to test pydoc.
    
    FILE
        /tmp/pydoctest/geotest/models.py
    
    DESCRIPTION
        I'm writing some DocStrings to test pydoc and geodjango.
    
    CLASSES
        django.db.models.base.Model(__builtin__.object)
            TestGeoModel
    
        TestGeoModel = <class 'pydoctest.geotest.models.TestGeoModel'>
    
    (END)
    

Please advise.

Attachments (2)

good_docs.txt (5.0 KB) - added by dariog 4 years ago.
bad_docs.txt (5.2 KB) - added by dariog 4 years ago.

Download all attachments as: .zip

Change History (8)

Changed 4 years ago by dariog

Changed 4 years ago by dariog

comment:1 Changed 4 years ago by dariog

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I probed it with python 2.6.4 and spatialite 2.3 and it works fine.
With the same definition in models.py I follow the same steps.

Steps to reproduce:

  1. django-admin startproject pydoctest
  2. cd pydoctest
  3. django-admin startapp geotest
  4. edit settings.py -- use a spatial db, like spatialite, add geotest to INSTALLED_APPS
  5. cd ..
  6. export DJANGO_SETTINGS_MODULE=pydoctest.settings
  7. pydoc pydoctest.geotest.models
  8. Observe: Good docs!

See attach: good_docs.txt

  1. In pydoctest/geotest/models.py, comment out line 8.
  1. In pydoctest/geotest/models.py, uncomment line 11, 23, 24.
  2. pydoc pydoctest.geotest.models
  3. Observe: Bad docs!

See attach: bad_docs.txt

Please give more information about the platform you are using.

comment:2 Changed 4 years ago by dariog

  • Owner changed from nobody to dariog

comment:3 Changed 4 years ago by dzwarg

My platform:

ubuntu 10.4
django 1.1
python 2.6.5
postgres 8.4.5
postgis 1.4.0

Has this been resolved in the new version of django?

comment:4 Changed 4 years ago by russellm

  • Component changed from Contrib apps to GIS
  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:6 Changed 3 years ago by jpaulett

  • Easy pickings unset
  • Resolution set to worksforme
  • Status changed from new to closed
  • UI/UX unset

Testing pydoc on Django's trunk using the gis version of models.Model and it worked fine. I am closing the ticket. Please reopen if still broken using Django trunk.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.