]> git.lizzy.rs Git - rust.git/blob - util/gh-pages/index.html
Document how to create a Clippy release
[rust.git] / util / gh-pages / index.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="UTF-8"/>
5     <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
7     <title>ALL the Clippy Lints</title>
8
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"/>
11     <style>
12         blockquote { font-size: 1em; }
13         [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }
14
15         .form-inline .checkbox { margin-right: 0.6em }
16
17         .panel-heading { cursor: pointer; }
18         .panel-heading:hover { background-color: #eee; }
19
20         .panel-title { display: flex; }
21         .panel-title .label { display: inline-block; }
22
23         .panel-title-name { flex: 1; }
24         .panel-title-name span { vertical-align: bottom; }
25
26         .panel .panel-title-name .anchor { display: none; }
27         .panel:hover .panel-title-name .anchor { display: inline; color: #fff; }
28     </style>
29 </head>
30 <body>
31     <div class="container" ng-app="clippy" ng-controller="lintList">
32         <div class="page-header">
33             <h1>ALL the Clippy Lints</h1>
34         </div>
35
36         <noscript>
37             <div class="alert alert-danger" role="alert">
38                 Sorry, this site only works with JavaScript! :(
39             </div>
40         </noscript>
41
42         <div ng-cloak>
43
44             <div class="alert alert-info" role="alert" ng-if="loading">
45                 Loading&#x2026;
46             </div>
47             <div class="alert alert-danger" role="alert" ng-if="error">
48                 Error loading lints!
49             </div>
50
51             <div class="panel panel-default" ng-show="data">
52                 <div class="panel-body row">
53                     <div class="col-md-6 form-inline">
54                         <div class="form-group form-group-lg">
55                             <p class="h4">Lint levels</p>
56                             <div class="checkbox" ng-repeat="(level, enabled) in levels">
57                                 <label>
58                                     <input type="checkbox" ng-model="levels[level]" />
59                                     {{level}}
60                                 </label>
61                             </div>
62                         </div>
63                     </div>
64                     <div class="col-md-6 form-inline">
65                         <div class="form-group form-group-lg">
66                             <p class="h4">Lint groups</p>
67                             <div class="checkbox" ng-repeat="(group, enabled) in groups">
68                                 <label class="text-capitalize">
69                                     <input type="checkbox" ng-model="groups[group]" />
70                                     {{group}}
71                                 </label>
72                             </div>
73                         </div>
74                     </div>
75                 </div>
76                 <div class="panel-body row">
77                     <div class="col-md-12 form-horizontal">
78                         <div class="input-group">
79                             <label class="input-group-addon" id="filter-label" for="filter-input">Filter:</label>
80                             <input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" />
81                             <span class="input-group-btn">
82                                 <button class="btn btn-default" type="button" ng-click="search = ''">
83                                     Clear
84                                 </button>
85                             </span>
86                         </div>
87                     </div>
88                 </div>
89             </div>
90
91             <article class="panel panel-default" id="{{lint.id}}"
92                 ng-repeat="lint in data | filter:byLevels | filter:byGroups | filter:search | orderBy:'id' track by lint.id" on-finish-render="ngRepeatFinished">
93                 <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]">
94                     <h2 class="panel-title">
95                         <div class="panel-title-name">
96                             <span>{{lint.id}}</span>
97                             <a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">&para;</a>
98                         </div>
99
100                         <div class="panel-title-addons">
101                             <span class="label label-default text-capitalize">{{lint.group}}</span>
102
103                             <span ng-if="lint.level == 'Allow'" class="label label-success">Allow</span>
104                             <span ng-if="lint.level == 'Warn'" class="label label-warning">Warn</span>
105                             <span ng-if="lint.level == 'Deny'" class="label label-danger">Deny</span>
106                             <span ng-if="lint.level == 'Deprecated'" class="label label-default">Deprecated</span>
107
108                             <button class="btn btn-default btn-xs">
109                                 <span ng-show="open[lint.id]">&minus;</span>
110                                 <span ng-hide="open[lint.id]">&plus;</span>
111                             </button>
112                         </div>
113                     </h2>
114                 </header>
115
116                 <ul class="list-group lint-docs" ng-if="lint.docs" ng-class="{collapse: true, in: open[lint.id]}">
117                     <li class="list-group-item" ng-repeat="(title, text) in lint.docs">
118                         <h4 class="list-group-item-heading">
119                             {{title}}
120                         </h4>
121                         <div class="list-group-item-text" ng-bind-html="text | markdown"></div>
122                     </li>
123                 </ul>
124             </article>
125         </div>
126     </div>
127
128     <a href="https://github.com/rust-lang/rust-clippy">
129         <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"/>
130     </a>
131
132     <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/7.0.0/markdown-it.min.js"></script>
133     <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
134     <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/languages/rust.min.js"></script>
135     <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
136     <script>
137     (function () {
138         var md = window.markdownit({
139             html: true,
140             linkify: true,
141             typographer: true,
142             highlight: function (str, lang) {
143                 if (lang && hljs.getLanguage(lang)) {
144                     try {
145                         return '<pre class="hljs"><code>' +
146                             hljs.highlight(lang, str, true).value +
147                             '</code></pre>';
148                     } catch (__) {}
149                 }
150
151                 return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
152             }
153         });
154
155         function scrollToLint(lintId) {
156             var target = document.getElementById(lintId);
157             if (!target) {
158                 return;
159             }
160             target.scrollIntoView();
161         }
162
163         function scrollToLintByURL($scope) {
164             var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
165                 scrollToLint(window.location.hash.slice(1));
166                 removeListener();
167             });
168         }
169
170         function selectGroup($scope, selectedGroup) {
171             var groups = $scope.groups;
172             for (var group in groups) {
173                 if (groups.hasOwnProperty(group)) {
174                     if (group === selectedGroup) {
175                         groups[group] = true;
176                     } else {
177                         groups[group] = false;
178                     }
179                 }
180             }
181         }
182
183         angular.module("clippy", [])
184         .filter('markdown', function ($sce) {
185             return function (text) {
186                 return $sce.trustAsHtml(
187                     md.render(text || '')
188                     // Oh deer, what a hack :O
189                     .replace('<table', '<table class="table"')
190                 );
191             };
192         })
193         .directive('onFinishRender', function ($timeout) {
194             return {
195                 restrict: 'A',
196                 link: function (scope, element, attr) {
197                     if (scope.$last === true) {
198                         $timeout(function () {
199                             scope.$emit(attr.onFinishRender);
200                         });
201                     }
202                 }
203             };
204         })
205         .controller("lintList", function ($scope, $http, $timeout) {
206             // Level filter
207             var LEVEL_FILTERS_DEFAULT = {Allow: true, Warn: true, Deny: true, Deprecated: true};
208             $scope.levels = LEVEL_FILTERS_DEFAULT;
209             $scope.byLevels = function (lint) {
210                 return $scope.levels[lint.level];
211             };
212
213             $scope.groups = {};
214             $scope.byGroups = function (lint) {
215                 return $scope.groups[lint.group];
216             };
217
218             // Get data
219             $scope.open = {};
220             $scope.loading = true;
221
222             if (window.location.hash.length > 1) {
223                 $scope.search = window.location.hash.slice(1);
224                 $scope.open[window.location.hash.slice(1)] = true;
225                 scrollToLintByURL($scope);
226             }
227
228             $http.get('./lints.json')
229             .success(function (data) {
230                 $scope.data = data;
231                 $scope.loading = false;
232
233                 // Initialize lint groups (the same structure is also used to enable filtering)
234                 $scope.groups = data.reduce(function (result, val) {
235                     result[val.group] = true;
236                     return result;
237                 }, {});
238
239                 var selectedGroup = getQueryVariable("sel");
240                 if (selectedGroup) {
241                     selectGroup($scope, selectedGroup.toLowerCase());
242                 }
243
244                 scrollToLintByURL($scope);
245             })
246             .error(function (data) {
247                 $scope.error = data;
248                 $scope.loading = false;
249             });
250
251             window.addEventListener('hashchange', function () {
252                 // trigger re-render
253                 $timeout(function () {
254                     $scope.levels = LEVEL_FILTERS_DEFAULT;
255                     $scope.search = window.location.hash.slice(1);
256                     $scope.open[window.location.hash.slice(1)] = true;
257
258                     scrollToLintByURL($scope);
259                 });
260                 return true;
261             }, false);
262         });
263     })();
264
265     function getQueryVariable(variable) {
266         var query = window.location.search.substring(1);
267         var vars = query.split('&');
268         for (var i = 0; i < vars.length; i++) {
269             var pair = vars[i].split('=');
270             if (decodeURIComponent(pair[0]) == variable) {
271                 return decodeURIComponent(pair[1]);
272             }
273         }
274     }
275     </script>
276 </body>
277 </html>