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; }
14 .panel .anchor { display: none; }
15 .panel:hover .anchor { display: inline; color: #fff; }
19 <div class="container" ng-app="clippy" ng-controller="lintList">
20 <div class="page-header">
21 <h1>ALL the Clippy Lints</h1>
25 <div class="alert alert-danger" role="alert">
26 Sorry, this site only works with JavaScript!
32 <div class="alert alert-info" role="alert" ng-if="loading">
35 <div class="alert alert-danger" role="alert" ng-if="error">
39 <div class="panel panel-default" ng-show="data">
40 <div class="panel-body row">
41 <div class="col-md-6 form-inline">
42 <div class="form-group form-group-lg">
43 <div class="checkbox" ng-repeat="(level, enabled) in levels" style="margin-right: 0.6em">
45 <input type="checkbox" ng-model="levels[level]" />
51 <div class="col-md-6">
52 <div class="input-group">
53 <span class="input-group-addon" id="filter-label">Filter:</span>
54 <input type="text" class="form-control" placeholder="Keywords or search string" aria-describedby="filter-label" ng-model="search" />
55 <span class="input-group-btn">
56 <button class="btn btn-default" type="button" ng-click="search = ''">
65 <article class="panel panel-default" id="{{lint.id}}"
66 ng-repeat="lint in data | filter:byLevels | filter:search | orderBy:'id' track by lint.id" on-finish-render="ngRepeatFinished">
67 <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]">
68 <button class="btn btn-default btn-sm pull-right" style="margin-top: -6px;">
69 <span ng-show="open[lint.id]">−</span>
70 <span ng-hide="open[lint.id]">+</span>
73 <h2 class="panel-title">
76 <span ng-if="lint.level == 'Allow'" class="label label-info">Allow</span>
77 <span ng-if="lint.level == 'Warn'" class="label label-warning">Warn</span>
78 <span ng-if="lint.level == 'Deny'" class="label label-danger">Deny</span>
79 <span ng-if="lint.level == 'Deprecated'" class="label label-default">Deprecated</span>
81 <a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">¶</a>
85 <ul class="list-group lint-docs" ng-if="lint.docs" ng-class="{collapse: true, in: open[lint.id]}">
86 <li class="list-group-item" ng-repeat="(title, text) in lint.docs">
87 <h4 class="list-group-item-heading">
90 <div class="list-group-item-text" ng-bind-html="text | markdown"></div>
97 <a href="https://github.com/Manishearth/rust-clippy">
98 <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"/>
101 <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/7.0.0/markdown-it.min.js"></script>
102 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
103 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/languages/rust.min.js"></script>
104 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
107 var md = window.markdownit({
111 highlight: function (str, lang) {
112 if (lang && hljs.getLanguage(lang)) {
114 return '<pre class="hljs"><code>' +
115 hljs.highlight(lang, str, true).value +
120 return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
124 function scrollToLint(lintId) {
125 var target = document.getElementById(lintId);
129 target.scrollIntoView();
132 function scrollToLintByURL($scope) {
133 var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
134 scrollToLint(window.location.hash.slice(1));
139 angular.module("clippy", [])
140 .filter('markdown', function ($sce) {
141 return function (text) {
142 return $sce.trustAsHtml(
143 md.render(text || '')
144 // Oh deer, what a hack :O
145 .replace('<table', '<table class="table"')
149 .directive('onFinishRender', function ($timeout) {
152 link: function (scope, element, attr) {
153 if (scope.$last === true) {
154 $timeout(function () {
155 scope.$emit(attr.onFinishRender);
161 .controller("lintList", function ($scope, $http, $timeout) {
163 var LEVEL_FILTERS_DEFAULT = {Allow: true, Warn: true, Deny: true, Deprecated: true};
164 $scope.levels = LEVEL_FILTERS_DEFAULT;
165 $scope.byLevels = function (lint) {
166 return $scope.levels[lint.level];
171 $scope.loading = true;
173 if (window.location.hash.length > 1) {
174 $scope.search = window.location.hash.slice(1);
175 $scope.open[window.location.hash.slice(1)] = true;
176 scrollToLintByURL($scope);
179 $http.get('./lints.json')
180 .success(function (data) {
182 $scope.loading = false;
184 scrollToLintByURL($scope);
186 .error(function (data) {
188 $scope.loading = false;
191 window.addEventListener('hashchange', function () {
193 $timeout(function () {
194 $scope.levels = LEVEL_FILTERS_DEFAULT;
195 $scope.search = window.location.hash.slice(1);
196 $scope.open[window.location.hash.slice(1)] = true;
198 scrollToLintByURL($scope);