4 <meta charset="UTF-8"/>
5 <meta name="viewport" content="width=device-width, initial-scale=1"/>
9 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"/>
10 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/github.min.css"/>
12 blockquote { font-size: 1em; }
13 [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }
15 .form-inline .checkbox { margin-right: 0.6em }
17 .panel-title { display: flex; }
18 .panel-title .label { display: inline-block; }
20 .panel-title-name { flex: 1; }
21 .panel-title-name span { vertical-align: bottom; }
23 .panel .panel-title-name .anchor { display: none; }
24 .panel:hover .panel-title-name .anchor { display: inline; color: #fff; }
28 <div class="container" ng-app="clippy" ng-controller="lintList">
29 <div class="page-header">
30 <h1>ALL the Clippy Lints</h1>
34 <div class="alert alert-danger" role="alert">
35 Sorry, this site only works with JavaScript! :(
41 <div class="alert alert-info" role="alert" ng-if="loading">
44 <div class="alert alert-danger" role="alert" ng-if="error">
48 <div class="panel panel-default" ng-show="data">
49 <div class="panel-body row">
50 <div class="col-md-6 form-inline">
51 <div class="form-group form-group-lg">
52 <p class="h4">Lint levels</p>
53 <div class="checkbox" ng-repeat="(level, enabled) in levels">
55 <input type="checkbox" ng-model="levels[level]" />
61 <div class="col-md-6 form-inline">
62 <div class="form-group form-group-lg">
63 <p class="h4">Lint groups</p>
64 <div class="checkbox" ng-repeat="(group, enabled) in groups">
65 <label class="text-capitalize">
66 <input type="checkbox" ng-model="groups[group]" />
73 <div class="panel-body row">
74 <div class="col-md-12 form-horizontal">
75 <div class="input-group">
76 <span class="input-group-addon" id="filter-label">Filter:</span>
77 <input type="text" class="form-control" placeholder="Keywords or search string" aria-describedby="filter-label" ng-model="search" />
78 <span class="input-group-btn">
79 <button class="btn btn-default" type="button" ng-click="search = ''">
88 <article class="panel panel-default" id="{{lint.id}}"
89 ng-repeat="lint in data | filter:byLevels | filter:byGroups | filter:search | orderBy:'id' track by lint.id" on-finish-render="ngRepeatFinished">
90 <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]">
91 <h2 class="panel-title">
92 <div class="panel-title-name">
93 <span>{{lint.id}}</span>
94 <a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">¶</a>
97 <div class="panel-title-addons">
98 <span class="label label-default text-capitalize">{{lint.group}}</span>
100 <span ng-if="lint.level == 'Allow'" class="label label-success">Allow</span>
101 <span ng-if="lint.level == 'Warn'" class="label label-warning">Warn</span>
102 <span ng-if="lint.level == 'Deny'" class="label label-danger">Deny</span>
103 <span ng-if="lint.level == 'Deprecated'" class="label label-default">Deprecated</span>
105 <button class="btn btn-default btn-xs">
106 <span ng-show="open[lint.id]">−</span>
107 <span ng-hide="open[lint.id]">+</span>
113 <ul class="list-group lint-docs" ng-if="lint.docs" ng-class="{collapse: true, in: open[lint.id]}">
114 <li class="list-group-item" ng-repeat="(title, text) in lint.docs">
115 <h4 class="list-group-item-heading">
118 <div class="list-group-item-text" ng-bind-html="text | markdown"></div>
125 <a href="https://github.com/rust-lang-nursery/rust-clippy">
126 <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on Github"/>
129 <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/7.0.0/markdown-it.min.js"></script>
130 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
131 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/languages/rust.min.js"></script>
132 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
135 var md = window.markdownit({
139 highlight: function (str, lang) {
140 if (lang && hljs.getLanguage(lang)) {
142 return '<pre class="hljs"><code>' +
143 hljs.highlight(lang, str, true).value +
148 return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
152 function scrollToLint(lintId) {
153 var target = document.getElementById(lintId);
157 target.scrollIntoView();
160 function scrollToLintByURL($scope) {
161 var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
162 scrollToLint(window.location.hash.slice(1));
167 angular.module("clippy", [])
168 .filter('markdown', function ($sce) {
169 return function (text) {
170 return $sce.trustAsHtml(
171 md.render(text || '')
172 // Oh deer, what a hack :O
173 .replace('<table', '<table class="table"')
177 .directive('onFinishRender', function ($timeout) {
180 link: function (scope, element, attr) {
181 if (scope.$last === true) {
182 $timeout(function () {
183 scope.$emit(attr.onFinishRender);
189 .controller("lintList", function ($scope, $http, $timeout) {
191 var LEVEL_FILTERS_DEFAULT = {Allow: true, Warn: true, Deny: true, Deprecated: true};
192 $scope.levels = LEVEL_FILTERS_DEFAULT;
193 $scope.byLevels = function (lint) {
194 return $scope.levels[lint.level];
198 $scope.byGroups = function (lint) {
199 return $scope.groups[lint.group];
204 $scope.loading = true;
206 if (window.location.hash.length > 1) {
207 $scope.search = window.location.hash.slice(1);
208 $scope.open[window.location.hash.slice(1)] = true;
209 scrollToLintByURL($scope);
212 $http.get('./lints.json')
213 .success(function (data) {
215 $scope.loading = false;
217 // Initialize lint groups (the same structure is also used to enable filtering)
218 $scope.groups = data.reduce(function (result, val) {
219 result[val.group] = true;
223 scrollToLintByURL($scope);
225 .error(function (data) {
227 $scope.loading = false;
230 window.addEventListener('hashchange', function () {
232 $timeout(function () {
233 $scope.levels = LEVEL_FILTERS_DEFAULT;
234 $scope.search = window.location.hash.slice(1);
235 $scope.open[window.location.hash.slice(1)] = true;
237 scrollToLintByURL($scope);