Opened 14 years ago

Closed 13 years ago

#14183 closed Bug (worksforme)

Geodjango models broken with pydoc

Reported by: dzwarg Owned by: dario
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 dario 14 years ago.
bad_docs.txt (5.2 KB ) - added by dario 14 years ago.

Download all attachments as: .zip

Change History (8)

by dario, 14 years ago

Attachment: good_docs.txt added

by dario, 14 years ago

Attachment: bad_docs.txt added

comment:1 by dario, 14 years ago

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 by dario, 14 years ago

Owner: changed from nobody to dario

comment:3 by dzwarg, 14 years ago

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 by Russell Keith-Magee, 14 years ago

Component: Contrib appsGIS
Triage Stage: UnreviewedAccepted

comment:5 by Julien Phalip, 13 years ago

Severity: Normal
Type: Bug

comment:6 by John Paulett, 13 years ago

Easy pickings: unset
Resolution: worksforme
Status: newclosed
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.

Note: See TracTickets for help on using tickets.
Back to Top