Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm a bit of a neat freak and I'm currently creating a cleaner .info file format by hand which is time consuming and problematic when diffing new exports of features.
The format I use is as such:
- Each group of info type (dependencies, features, features_exclude, files, etc) get's prepended with three line breaks a comment containing the type name and an additional line break.
- Each primary key of an info type (features[field_instance], etc) is separated by a single line break
And example of this is seen below:
Old:
name = Feature core = 7.x package = Features php = 5.2.4 version = 7.x-2.0 project = feature dependencies[] = features dependencies[] = file dependencies[] = image features[context][] = layout-articles features[features_api][] = api:2 features[field_base][] = field_file features[field_base][] = field_image features[field_instance][] = node-article-field_file features[field_instance][] = node-article-field_image features[node][] = article
New:
name = Feature core = 7.x package = Features php = 5.2.4 version = 7.x-2.0 project = feature; Dependencies dependencies[] = features dependencies[] = file dependencies[] = image
; Features features[context][] = layout-articles features[features_api][] = api:2 features[field_base][] = field_file features[field_base][] = field_image features[field_instance][] = node-article-field_file features[field_instance][] = node-article-field_image features[node][] = article
I find this new format to be much more readable.
Patch coming shortly.
Comment | File | Size | Author |
---|---|---|---|
#1 | cleaner_info-2155793-1.patch | 1.07 KB | Deciphered |
Comments
Comment #1
Deciphered CreditAttribution: Deciphered commentedComment #2
Deciphered CreditAttribution: Deciphered commentedComment #3
hefox CreditAttribution: hefox commented3 new lines seems a bit excessive to me XD
Comment #4
Deciphered CreditAttribution: Deciphered commented@hefox,
I'd be more than happy to make the format configurable if I had an inkling that it would help push the patch forward.
Comment #5
hefox CreditAttribution: hefox commentedType of issue that has too much impact for me to commit without more input. Initial commit means all features will change on update for everyone, which complicates some people's development workflow (or at least reviewing the diff to see what has changed).
Comment #6
Deciphered CreditAttribution: Deciphered commentedOk, fair call. While I personally think it's a change for the better, I can understand that it is often frustrating when something changes only aesthetically and clutters up a commit.
I'll re-work the patch with one of the following approaches:
Comment #7
mpotter CreditAttribution: mpotter commentedYeah, not sure on this one myself. Seems like a lot of work for aesthetics. Also, Drupal itself doesn't have doc guidelines for .info files. Other lines get added to this file, such as files[] for stylesheets and PHP class inc files. So it's not really something Features has full control over either.
I guess if somebody wants to do the work and submit a full patch that we can look at it. But it will need a lot of testing with different Features to make sure it doesn't break something functional. It should also be tested with other Features-related modules, such as Features Override and Features Extra.