|
| 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>Clippy</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 | + .panel .anchor { display: none; } |
| 15 | + .panel:hover .anchor { display: inline; color: #fff; } |
| 16 | + </style> |
| 17 | +</head> |
| 18 | +<body> |
| 19 | + <div class="container" ng-app="clippy" ng-controller="lintList"> |
| 20 | + <div class="page-header"> |
| 21 | + <h1>ALL the Clippy Lints</h1> |
| 22 | + </div> |
| 23 | + |
| 24 | + <noscript> |
| 25 | + <div class="alert alert-danger" role="alert"> |
| 26 | + Sorry, this site only works with JavaScript! |
| 27 | + </div> |
| 28 | + </noscript> |
| 29 | + |
| 30 | + <div ng-cloak> |
| 31 | + |
| 32 | + <div class="alert alert-info" role="alert" ng-if="loading"> |
| 33 | + Loading… |
| 34 | + </div> |
| 35 | + <div class="alert alert-danger" role="alert" ng-if="error"> |
| 36 | + Error loading lints! |
| 37 | + </div> |
| 38 | + |
| 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"> |
| 44 | + <label> |
| 45 | + <input type="checkbox" ng-model="levels[level]" /> |
| 46 | + {{level}} |
| 47 | + </label> |
| 48 | + </div> |
| 49 | + </div> |
| 50 | + </div> |
| 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 = ''"> |
| 57 | + Clear |
| 58 | + </button> |
| 59 | + </span> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </div> |
| 63 | + </div> |
| 64 | + |
| 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> |
| 71 | + </button> |
| 72 | + |
| 73 | + <h2 class="panel-title"> |
| 74 | + {{lint.id}} |
| 75 | + |
| 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> |
| 80 | + |
| 81 | + <a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">¶</a> |
| 82 | + </h2> |
| 83 | + </header> |
| 84 | + |
| 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"> |
| 88 | + {{title}} |
| 89 | + </h4> |
| 90 | + <div class="list-group-item-text" ng-bind-html="text | markdown"></div> |
| 91 | + </li> |
| 92 | + </ul> |
| 93 | + </article> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + |
| 97 | + <a href="https://github.com/rust-lang-nursery/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"/> |
| 99 | + </a> |
| 100 | + |
| 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> |
| 105 | + <script> |
| 106 | + (function () { |
| 107 | + var md = window.markdownit({ |
| 108 | + html: true, |
| 109 | + linkify: true, |
| 110 | + typographer: true, |
| 111 | + highlight: function (str, lang) { |
| 112 | + if (lang && hljs.getLanguage(lang)) { |
| 113 | + try { |
| 114 | + return '<pre class="hljs"><code>' + |
| 115 | + hljs.highlight(lang, str, true).value + |
| 116 | + '</code></pre>'; |
| 117 | + } catch (__) {} |
| 118 | + } |
| 119 | + |
| 120 | + return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>'; |
| 121 | + } |
| 122 | + }); |
| 123 | + |
| 124 | + function scrollToLint(lintId) { |
| 125 | + var target = document.getElementById(lintId); |
| 126 | + if (!target) { |
| 127 | + return; |
| 128 | + } |
| 129 | + target.scrollIntoView(); |
| 130 | + } |
| 131 | + |
| 132 | + function scrollToLintByURL($scope) { |
| 133 | + var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) { |
| 134 | + scrollToLint(window.location.hash.slice(1)); |
| 135 | + removeListener(); |
| 136 | + }); |
| 137 | + } |
| 138 | + |
| 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"') |
| 146 | + ); |
| 147 | + }; |
| 148 | + }) |
| 149 | + .directive('onFinishRender', function ($timeout) { |
| 150 | + return { |
| 151 | + restrict: 'A', |
| 152 | + link: function (scope, element, attr) { |
| 153 | + if (scope.$last === true) { |
| 154 | + $timeout(function () { |
| 155 | + scope.$emit(attr.onFinishRender); |
| 156 | + }); |
| 157 | + } |
| 158 | + } |
| 159 | + }; |
| 160 | + }) |
| 161 | + .controller("lintList", function ($scope, $http, $timeout) { |
| 162 | + // Level filter |
| 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]; |
| 167 | + }; |
| 168 | + |
| 169 | + // Get data |
| 170 | + $scope.open = {}; |
| 171 | + $scope.loading = true; |
| 172 | + |
| 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); |
| 177 | + } |
| 178 | + |
| 179 | + $http.get('./lints.json') |
| 180 | + .success(function (data) { |
| 181 | + $scope.data = data; |
| 182 | + $scope.loading = false; |
| 183 | + |
| 184 | + scrollToLintByURL($scope); |
| 185 | + }) |
| 186 | + .error(function (data) { |
| 187 | + $scope.error = data; |
| 188 | + $scope.loading = false; |
| 189 | + }); |
| 190 | + |
| 191 | + window.addEventListener('hashchange', function () { |
| 192 | + // trigger re-render |
| 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; |
| 197 | + |
| 198 | + scrollToLintByURL($scope); |
| 199 | + }); |
| 200 | + return true; |
| 201 | + }, false); |
| 202 | + }); |
| 203 | + })(); |
| 204 | + </script> |
| 205 | +</body> |
| 206 | +</html> |
0 commit comments