Sort relationship docs alphabetically.

Creation order wasn't that big of a win and didn't play nicely with
backrefs.
This commit is contained in:
Andrew Ekstedt 2012-06-05 18:10:37 -07:00
parent 527b3ce056
commit f4c51c845d

View file

@ -204,14 +204,11 @@ def generate_relationships(cls, remaining_attrs):
def isrelationship(prop): def isrelationship(prop):
return isinstance(prop, InstrumentedAttribute) and isinstance(prop.property, RelationshipProperty) return isinstance(prop, InstrumentedAttribute) and isinstance(prop.property, RelationshipProperty)
relationships = [] for attr_name in sorted(remaining_attrs):
for attr_name in remaining_attrs:
prop = getattr(cls, attr_name) prop = getattr(cls, attr_name)
if isrelationship(prop): if not isrelationship(prop):
relationships.append((attr_name, prop.property)) continue
relationships.sort(key=lambda x: x[1]._creation_order) rel = prop.property
for attr_name, rel in relationships:
yield u'%s.\ **%s**' % (cls.__name__, attr_name) yield u'%s.\ **%s**' % (cls.__name__, attr_name)
class_name = u':class:`~pokedex.db.tables.%s`' % rel.mapper.class_.__name__ class_name = u':class:`~pokedex.db.tables.%s`' % rel.mapper.class_.__name__
if rel.uselist: if rel.uselist: