Contributing Stylesheets to Compass
Thank you for your interest in contributing to Compass. Our goal is to make it as easy as we can for you to contribute changes to compass -- So if there's something here that seems harder than it ought to be, please let us know.
If you find a bug in this document, you are bound to contribute a fix. Stop reading now if you do not wish to abide by this rule.
Step 1: If you do not have a github account, create one.
Step 2: Fork Compass to your account. Go to the main repo and click the fork button.
Now we're at a decision point. What kind of change do you intend to make?
- Fix a typo (or some other trivial change)
- Documentation Changes
- Fixing Stylesheet Bugs
- New Stylesheet Features
- Ruby Changes
Here's some general information about the project you might find useful along the way:
- General Philosophy
- Stylesheet Conventions
- Miscellaneous Stuff
Making Trivial Changes
Thanks to Github, making small changes is super easy. After forking the project navigate to the file you want to change and click the edit link.
Change the file, write a commit message, and click the
Now you need to get your change accepted.
Making Documentation Changes
The compass documentation is stored in two places. First, the
compass-style.org directory is
where the documentation lives -- however much of the documentation is generated
from comments in the Sass files themselves. More information on changing
documentation. Once your changes are pushed, please
Fixing Stylesheet Bugs
Step 3: If this is a bug you discovered. Please report it before working on a fix. This helps us better understand the patch.
Step 4: Get the code if you haven't yet done so.
Step 5: Fix the bug and commit the changes. Please make sure to mention the bug id in your commit message like so:
Fixed the display of the fizzlebuzz in IE6. Closes GH-123.
Step 6: Verify the fix in as many browsers as you can as well as against your own project. How to use compass while changing it.
Step 7: Make sure the tests pass. More info on running tests If the tests fail, fix the tests or the stylesheets accordingly. If the tests, don't fail, that means this aspect was not well enough tested. Please add or augment a test.
You're done. Please submit your changes.
Making Stylesheet Changes
It is a good idea to discuss new features ideas with the compass users and developers before building something. Please don't be shy; send an email to the compass mailing list.
Many feature ideas are good but not obviously a good fit for the compass core library. In these cases, you can and should create a compass extension. Sometimes this is because the concept does not align with the compass philosophy. But sometimes it's just because we think the idea needs time to bake. Documentation on making extensions.
Step 3: Get the code if you haven't yet done so.
Step 4: Add the feature -- contact the mailing list if you have any questions.
Step 5: Add a test case. More info on writing tests for compass.
Step 6: Documentation - Add or update the reference documentation. Add an example of using the feature. See the doc readme for details.
You're done. Please submit your changes.
Making Ruby Changes
At this time, if you're a rubyist who's planning on working on the ruby-side of things, it's assumed you know how to read code and use standard ruby tools like rake, gem, bundler, test/unit, cucumber, rspec, etc. If you have any questions, please ask. No changes will be accepted without accompanying tests.
If you are submitting features that have more than one changeset, please create a topic branch to hold the changes while they are pending merge and also to track iterations to the original submission. To create a topic branch:
$ git checkout -b new_branch_name ... make more commits if needed ... $ git push origin new_branch_name
You can now see these changes online at a url like:
If you have single-commit patches, it is fine to keep them on master. But do keep in mind that these changesets might be cherry-picked.
Once your changeset(s) are on github, select the appropriate branch containing your changes and send a pull request. Make sure to choose the same upstream branch that you developed against (probably stable or master). Most of the description of your changes should be in the commit messages -- so no need to write a whole lot in the pull request message. However, the pull request message is a good place to provide a rationale or use case for the change if you think one is needed. More info on pull requests.
Pull requests are then managed like an issue from the compass issues page. A code review will be performed by a compass core team member, and one of three outcomes will result:
- The change is rejected -- Not all changes are right for compass's philosophy. If your change is rejected it might be better suited for a plugin, at least until it matures and/or proves itself with the users.
- The change is rejected, unless -- Sometimes, there are missing pieces, or other changes that need to be made before the change can be accepted. Comments will be left on the commits indicating what issues need to be addressed.
- The change is accepted -- The change is merged into compass, sometimes minor changes are then applied by the committer after the merge.
compass/ core/ - The core of compass's configuration and stylesheets. frameworks/ - All frameworks in this directory are loaded automatically compass/ - The compass framework stylesheets/ - The compass libraries templates/ - The compass project templates and patterns test/ - unit tests lib/ compass-core.rb - The main compass-core ruby library compass/ core/ sass_extensions/ - enhancements to Sass functions/ - Sass functions exposed by compass monkey_patches/ - Changes to sass itself configuration/ - support for project configuration cli/ - All the compass code that makes the command line work bin/ compass - CLI executable devbin/ - development scripts after installing the bundle test/ - unit tests features/ - tests for compass lib/ compass.rb - The main compass ruby library compass/ app_integration/ - integration with app frameworks commands/ - UI agnostic support for the CLI configuration/ - Some CLI specific configuration. exec/ - UI code for the CLI installers/ - support for installing templates compass-style.org/ - source for documentation output/ - generated documentation import-once/ - Compass's import-once importer for Sass.
- Users specify their own selectors. Compass never forces a user to use a presentational class name.
- Compass core is "design agnostic". This is why compass core has no grid framework -- grids are not design agnostic.
- Compass frameworks are not special. If compass can do it, so should an extension be able.
- Sass is awesome -- Compass should make sass more accessible and demonstrate how to use Sass to its fullest potential.
- Developing across browsers is hard and will always be hard. It takes a community to get it right.
- By default, Compass supports as many browsers as it can. Where it can't it progressively enhances. Where it degrades, the documentation should make a note. Deviation from this requires an excellent reason.
- Compass is a proving ground for Sass features. The watcher and color functions are examples of features that started in Compass and got moved to Sass.
- All framework stylesheets are partials. Their filename begin with an underscore. Otherwise, Sass will create stylesheets directly into the user's CSS directory.
- Compass imports do not emit styles. There are a few limited exceptions to this like the resets and base classes for inheritance.
- Mixins with two-level defaults. Mixins often provide two levels of default values. The first is a global default that can be overridden once. The second is a default that can be overridden when the mixin is included.
- Mixin argument names are part of the public API, make sure they are understandable and not needlessly truncated or terse.
- If adding a new folder of stylesheets, add a single stylesheet with the same name that imports all of the stylesheets in the folder.
- Try to avoid passing selectors as arguments. This is what mixins are for.
Common Problems & Miscellaneous Info
Setting up Git
Please follow these instructions to set up your email address and attribution information.
Download your git repo:
git clone email@example.com:your_username/compass.git
Set up a remote to the main repo:
cd compass git remote add chriseppstein git://github.com/chriseppstein/compass.git
Getting recent changes from the main repo:
git fetch chriseppstein
Using Compass while Under Development
- Use the bin script.
/path/to/compass/bin/compassis a version of the compass command line that uses the local changes you have made. You can add
$PATH, or refer to it directly.
- Build and install a gem:
- Edit VERSION and change the version to something like:
gem build compass.gemspec
gem install compass-0.10.6.something-uniq-to-me.0.gem-- If installing to your system gems, you'll probably need to add
sudoto the front. If you don't know what that means, you probably need to add
sudoto the front.
- Edit VERSION and change the version to something like:
In a bundled environment, you can configure your gem to use compass while you work on it like so:
gem 'compass', :path => "/Users/myusername/some/path/to/compass"
Bundler will perform some sort of charm on ruby to make it work.
Configuring ruby directly. If you're a ruby pro, you probably don't need to be told that you can set compass on the load path like so:
You must have Ruby installed on your system. After setting up git, change to the root directory of your git checkout of Compass.
Install the bundler Ruby gem.
gem install bundler
If installing to your system gems, you'll probably need to add
sudoto the front of that command. If you don't know what that means, you probably need to add
sudoto the front.
Install development dependencies:
bundle install --binstubs devbin
Running core library and stylesheet tests:
bundle exec rake test features
Running behavior tests
If stylesheet tests fail, the output of the test project is captured in
test/fixtures/stylesheets/<project>/saved/ and the error message will report where
the error was. Here's an example:
Writing Stylesheet Tests
Compass has stylesheet tests to ensure that each stylesheet compiles, can be imported directly without any other dependencies and that refactorings that should not affect the output, don't.
At some point, it would be great to have a test system that verifies that the stylesheets work correctly in various browsers. If you have ideas for how to accomplish this in a sane way, please let us know.
test/fixtures/stylesheets directory, there are a number of compass projects.
The tests work by adding or updating the sass files, running the tests to make sure they fail,
and then changing the expected css output to make the test pass. It is rudimentary, but as
a safety net, it has caught a number of problems that might have been missed otherwise.
If you add a new stylesheet to compass, please make sure to add a new test stylesheet
that only imports the newly added stylesheet and add rules that use the new features in that
You cherry-picked/rebased my changes. What should I do?
Depending on any number of reasons, including but not limited to the alignment of the stars, Your changes might not be merged into compass using a simple merge. For instance, we might decide to place a change against master into stable instead, or we might squish all your changes together into a single commit at the time of merge, or we might want a change you've submitted but not a change that it was placed onto top of. In these cases, there are a couple of ways you can react:
- If you have some changes on a branch that were not yet accepted, but other changes on that
branch were accepted then you should run the following command (make sure to fetch first):
git checkout branch_name; git rebase chriseppstein/master(assuming the change was applied to the master branch)
- If all your changes on the topic branch were accepted or you don't care to keep it around
git checkout master; git branch -D branch_name; git push origin :branch_name