cleaned up code, added comments on doc-directive.js.erb