I client of mine asked to have a lot of comments in the code - including css files.
So I thought about using CSScomb to reorganize the css code and add comments automatically. It doesn't make sense but why not.
So the idea would be to change the config file which states:
[
"font",
"font-family"
],
[
"padding",
"margin"
]
...
but get an output that writes:
/* FONT STYLE */
font: ....;
font-family: ....;
Any ideas ?
You can add this functionality yourself by editing the sort-order.js
file in the CSScomb package.
Preferences > Browse Packages…
; This will open the Packages folder.CSScomb/node_modules/csscomb/lib/options/sort-order.js
.sort-order-original.js
.../originals/options/sort-order.js
.sort-order.js
in Sublime Text for editing.sort-order.js
. You may choose to edit further to suit your needs. Save.Preferences > Package Settings > CSScomb > Settings – User
. If you haven't already configured your own settings, you can get started by copying the contents of the Settings – Default
into Settings – User
."sort-order"
property. It is either an array of property names or an array of arrays of property names. By default, CSScomb will add a blank line between the nested array groups, but we've modified the file that does this.sort-order.js
file will detect this and output it at the top of the group. If no comment is defined, the default blank line is output instead.Example User Settings:
"sort-order": [
[
"/* LAYOUT */",
"position",
"z-index",
"top",
"right",
"bottom",
"left"
],
[
"/* DISPLAY */",
"display",
…
"flex-align"
],
[
"/* TYPOGRAPHY */",
"font",
…
"line-height"
],
[
…
]
]
Before running CSScomb:
.selector {
font-family: Arial;
line-height: 1;
position: relative;
display: block;
background-color: red;
}
After running CSScomb:
.selector {
/* LAYOUT */
position: relative;
/* DISPLAY */
display: block;
/* TYPOGRAPHY */
font-family: Arial;
line-height: 1;
background-color: red;
}