Hi! I managed to make sphinx's autoattribute to work with Django attributes, is there a way to collaborate?
here's the diff between the original autodoc.py and my autodoc.py: (just in case, it's on http://pastebin.com/f6cece68e) 322c322,328 < obj = self.get_attr(obj, part) --- > try: > obj = self.get_attr(obj, part) > except Exception, e: > if getattr(obj, '_meta', False): > obj = obj._meta.get_field_by_name(part)[0] > else: > raise e 479,481c485,488 < return False, sorted([ < (mname, self.get_attr(self.object, mname, None)) < for mname in self.get_attr(self.object, '__dict__').keys()]) --- > ret = [(mname, self.get_attr(self.object, mname, None)) for mname > in self.get_attr(self.object, '__dict__').keys()] > if getattr(self.object, '_meta', False): > ret += [(mname, > self.object._meta.get_field_by_name(mname)[0]) for mname in > self.object._meta.get_all_field_names()] > return False, sorted(ret) 532c539 < --- > 584d590 < On Nov 8, 2:47 pm, Georg Brandl <[email protected]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Jochen Maes schrieb: > > > > > \\//, > > > I'm usingDjangofor Djagios and use Sphinx for the docs and website. > > However I've been trying to incorporate my documentation as much as > > possible into the code. So I started using attribute docstrings on my > > models. Right nom it's in a separate file > > (http://docs.djagios.org/core/models.html). > > > You'll notice that it's a huge list of attributes. > > Now the problem lies inDjango'sway of working with attributes, set me > > demonstrate the problem: > > > class Author(models.Model): > > name = models.CharField(max_length=100) > > """Docstring for name""" > > > class Book(models.Model): > > name = models.CharField(max_length=255) > > """Another Docstring""" > > author = models.ForeignKey(Author) > > """Each book has an Author""" > > > Will result in a documentation with only the docstrings of Book.author. > > > As I really, really like sphinx I am asking if it's possible to (I'm > > willing to patch myself with a bit of help) add this to theautodoc > > extension. > > Hi Jochen, > > I don't understand why only Book.author is documented; is it because > of some differences between models.ForeignKey and models.CharField? > > I'll certainly help where I can if you try to fix this in sphinx. > > cheers, > Georg > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.11 (GNU/Linux) > > iEYEARECAAYFAkr3ElEACgkQN9GcIYhpnLAWWgCfVelMP5iWfcu9XraJzitrRKRP > DOkAnivK4WiCMjp4yYo6/qvKoQmMR0pW > =wiYx > -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en -~----------~----~----~----~------~----~------~--~---
