Put column descriptions where they belong

The Column class accepts a 'doc' argument. Use it.

And while we're at it, make them all unicode strings.

Performed by the following sed script:

   s/info=dict(description=u\?\("[^"]*"\))/doc=u\1/
   s/info=dict(description=u\?\('[^']*'\))/doc=u\1/
   s/\(\s*\)info=dict(description=u\?\("[^"]*"\), /\1doc=u\2,\n\1info=dict(/
   s/\(\s*\)info=dict(description=u\?\('[^']*'\), /\1doc=u\2,\n\1info=dict(/

   /info=dict(description=u\?\('[^']*'\),$/ {
       s//doc=u\1,/
       n
       s/^\s*/&info=dict(/
   }
This commit is contained in:
Andrew Ekstedt 2014-07-04 13:39:05 -07:00
parent 181ae0fe19
commit 6f5abb9540
4 changed files with 646 additions and 514 deletions

View file

@ -126,10 +126,10 @@ def create_translation_table(_table_name, foreign_class, relation_name,
table = Table(_table_name, foreign_class.__table__.metadata, table = Table(_table_name, foreign_class.__table__.metadata,
Column(foreign_key_name, Integer, ForeignKey(foreign_class.id), Column(foreign_key_name, Integer, ForeignKey(foreign_class.id),
primary_key=True, nullable=False, primary_key=True, nullable=False,
info=dict(description="ID of the %s these texts relate to" % foreign_class.__singlename__)), doc=u"ID of the %s these texts relate to" % foreign_class.__singlename__),
Column('local_language_id', Integer, ForeignKey(language_class.id), Column('local_language_id', Integer, ForeignKey(language_class.id),
primary_key=True, nullable=False, primary_key=True, nullable=False,
info=dict(description="Language these texts are in")), doc=u"Language these texts are in"),
) )
Translations.__table__ = table Translations.__table__ = table

File diff suppressed because it is too large Load diff

View file

@ -183,7 +183,7 @@ def generate_columns(cls, remaining_attrs):
else: else:
yield column_header(c, name) + ':' yield column_header(c, name) + ':'
yield u'' yield u''
yield u' ' + unicode(c.info['description']) yield u' ' + unicode(c.__doc__)
yield u'' yield u''
@with_header(u'Internationalized strings') @with_header(u'Internationalized strings')
@ -198,7 +198,7 @@ def generate_strings(cls, remaining_attrs):
yield column_header(c, cls.__name__, yield column_header(c, cls.__name__,
translation_class.__table__.name) translation_class.__table__.name)
yield u'' yield u''
yield u' ' + unicode(c.info['description']) yield u' ' + unicode(c.__doc__)
yield u'' yield u''
@with_header(u'Relationships') @with_header(u'Relationships')
@ -243,9 +243,6 @@ def generate_associationproxies(cls, remaining_attrs):
yield u'%s.\ **%s**:' % (cls.__name__, attr_name) yield u'%s.\ **%s**:' % (cls.__name__, attr_name)
yield '``{prop.remote_attr.key}`` of ``self.{prop.local_attr.key}``'.format( yield '``{prop.remote_attr.key}`` of ``self.{prop.local_attr.key}``'.format(
prop=prop) prop=prop)
'''if 'description' in info:
yield u''
yield u' ' + unicode(info['description'])'''
yield u'' yield u''
remaining_attrs.remove(attr_name) remaining_attrs.remove(attr_name)

View file

@ -193,7 +193,7 @@ def test_texts(cls):
if column.name == 'name' and format != 'plaintext': if column.name == 'name' and format != 'plaintext':
raise AssertionError('%s: non-plaintext name' % column) raise AssertionError('%s: non-plaintext name' % column)
# No mention of English in the description # No mention of English in the description
assert 'English' not in column.info['description'], column assert u'English' not in column.__doc__, column
# If there's more than one text column in a translation table, # If there's more than one text column in a translation table,
# they have to be nullable, to support missing translations # they have to be nullable, to support missing translations
if hasattr(cls, 'local_language') and len(text_columns) > 1: if hasattr(cls, 'local_language') and len(text_columns) > 1: