Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added the mro.py prettification script at root of docs. Demonstrated …

…the results of the script by updating the MRO statements for fundamental, display, and edit class based views
  • Loading branch information...
commit 7b9467ee76762a546e5bde8c844555946d3493a8 1 parent 9effb21
@pydanny authored
View
36 docs/mro.py
@@ -0,0 +1,36 @@
+"""
+Undocumented and crazy, with a silly workflow, but it turns <class>.mro() into
+formatted RestructuredText.
+
+Documentation to come soon.
+"""
+
+from django.conf import settings
+settings.configure()
+
+def print_mro(cls):
+ """ If passed in a class will return a string that turns the MRO for
+ that class into an attractive RestructuredText snippet.
+ """
+ for item in cls.mro():
+ print(item)
+
+def clean(text=None):
+ if text is None:
+ items = open('hack.txt', 'r').read().splitlines()
+ else:
+ items = text.splitlines()
+ for item in items:
+ if item == "<type 'object'>":
+ continue
+ item = item.replace("'", "`")
+ item = item.replace("<class ", "* :class:")
+ item = item.replace(">", "")
+ print(item)
+
+if __name__=='__main__':
+ class A(object): pass
+ class B(A): pass
+ print_mro(B)
+
+
View
1  docs/ref/class-based-views/fundamentals.txt
@@ -97,6 +97,7 @@ TemplateView
**Ancestors (MRO)**
+ * :class:`django.views.generic.base.TemplateView`
* :class:`django.views.generic.base.TemplateResponseMixin`
* :class:`django.views.generic.base.View`
View
2  docs/ref/class-based-views/generic-display.txt
@@ -96,7 +96,7 @@ ListView
**Mixins**
- * :class:`django.views.generic.list.MultipleObjectMixin`
+ * :class:`django.views.generic.list.ListView`
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
* :class:`django.views.generic.base.TemplateResponseMixin`
* :class:`django.views.generic.list.BaseListView`
View
24 docs/ref/class-based-views/generic-editing.txt
@@ -19,8 +19,12 @@ FormView
**Ancestors (MRO)**
+ * :class:`django.views.generic.edit.FormView`
+ * :class:`django.views.generic.base.TemplateResponseMixin`
+ * :class:`django.views.generic.edit.BaseFormView`
* :class:`django.views.generic.edit.FormMixin`
* :class:`django.views.generic.edit.ProcessFormView`
+ * :class:`django.views.generic.base.View`
**Methods and Attributes**
@@ -36,8 +40,15 @@ CreateView
**Ancestors (MRO)**
+ * :class:`django.views.generic.edit.CreateView`
+ * :class:`django.views.generic.detail.SingleObjectTemplateResponseMixin`
+ * :class:`django.views.generic.base.TemplateResponseMixin`
+ * :class:`django.views.generic.edit.BaseCreateView`
* :class:`django.views.generic.edit.ModelFormMixin`
+ * :class:`django.views.generic.edit.FormMixin`
+ * :class:`django.views.generic.detail.SingleObjectMixin`
* :class:`django.views.generic.edit.ProcessFormView`
+ * :class:`django.views.generic.base.View`
**Methods and Attributes**
@@ -55,8 +66,15 @@ UpdateView
**Ancestors (MRO)**
+ * :class:`django.views.generic.edit.UpdateView`
+ * :class:`django.views.generic.detail.SingleObjectTemplateResponseMixin`
+ * :class:`django.views.generic.base.TemplateResponseMixin`
+ * :class:`django.views.generic.edit.BaseUpdateView`
* :class:`django.views.generic.edit.ModelFormMixin`
+ * :class:`django.views.generic.edit.FormMixin`
+ * :class:`django.views.generic.detail.SingleObjectMixin`
* :class:`django.views.generic.edit.ProcessFormView`
+ * :class:`django.views.generic.base.View`
**Methods and Attributes**
@@ -74,8 +92,14 @@ DeleteView
**Ancestors (MRO)**
+ * :class:`django.views.generic.edit.DeleteView`
+ * :class:`django.views.generic.detail.SingleObjectTemplateResponseMixin`
+ * :class:`django.views.generic.base.TemplateResponseMixin`
+ * :class:`django.views.generic.edit.BaseDeleteView`
* :class:`django.views.generic.edit.DeletionMixin`
* :class:`django.views.generic.detail.BaseDetailView`
+ * :class:`django.views.generic.detail.SingleObjectMixin`
+ * :class:`django.views.generic.base.View`
**Notes**
Please sign in to comment.
Something went wrong with that request. Please try again.