1

I have a class that uses a peewee model.

import peewee

class MyDatabase:
   def __init__(self, database_filename):
      self.db = peewee.SqliteDatabase(database_filename)

      class BaseModel(peewee.Model):
            class Meta:
                database = self.db

      class CustomModel(BaseModel):
            my_int = peewee.IntegerField(default=0)

Now I want to document (using the Sphinx autoclass function) the CustomModel and I haven't found out what the best method should be.

Sure I could move CustomModel out of the MyDatabase class, but then I would need a global database variable which is not a good thing if I want to have this script importable. Any maybe the user wants to open multiple Sqlite database files, so a global database variable might be a bad idea and for this case the nested class structure should be the best, shouldn't it?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Randrian
  • 1,055
  • 12
  • 25
  • Related: http://stackoverflow.com/q/27337534/407651 and http://stackoverflow.com/questions/22451195/sphinx-autodoc-include-subfunctions – mzjn May 12 '16 at 04:55
  • I already found the first one, but unfortunately it wasn't helpful. I see that the nested classes are not considered good python syntax, but peewee somehow seems to force me to use it. Isn't there a sort of canonical way to document peewee models? I am probably not the only one who tries to document code which uses peewee. – Randrian May 12 '16 at 07:23

0 Answers0