Skip to content

Commit 94e8978

Browse files
authored
Merge pull request #2654 from killercup/feature/lint-groups-in-docs
Show/Filter by lint groups in docs
2 parents 4015395 + c43a892 commit 94e8978

File tree

2 files changed

+58
-18
lines changed

2 files changed

+58
-18
lines changed

util/export.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
def parse_lint_def(lint):
1919
lint_dict = {}
2020
lint_dict['id'] = lint.name
21+
lint_dict['group'] = lint.group
2122
lint_dict['level'] = lint.level
2223
lint_dict['docs'] = {}
2324

util/gh-pages/index.html

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@
1111
<style>
1212
blockquote { font-size: 1em; }
1313
[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; }
14+
15+
.form-inline .checkbox { margin-right: 0.6em }
16+
17+
.panel-title { display: flex; }
18+
.panel-title .label { display: inline-block; }
19+
20+
.panel-title-name { flex: 1; }
21+
.panel-title-name span { vertical-align: bottom; }
22+
23+
.panel .panel-title-name .anchor { display: none; }
24+
.panel:hover .panel-title-name .anchor { display: inline; color: #fff; }
1625
</style>
1726
</head>
1827
<body>
@@ -23,7 +32,7 @@ <h1>ALL the Clippy Lints</h1>
2332

2433
<noscript>
2534
<div class="alert alert-danger" role="alert">
26-
Sorry, this site only works with JavaScript!
35+
Sorry, this site only works with JavaScript! :(
2736
</div>
2837
</noscript>
2938

@@ -40,15 +49,29 @@ <h1>ALL the Clippy Lints</h1>
4049
<div class="panel-body row">
4150
<div class="col-md-6 form-inline">
4251
<div class="form-group form-group-lg">
43-
<div class="checkbox" ng-repeat="(level, enabled) in levels" style="margin-right: 0.6em">
52+
<p class="h4">Lint levels</p>
53+
<div class="checkbox" ng-repeat="(level, enabled) in levels">
4454
<label>
4555
<input type="checkbox" ng-model="levels[level]" />
4656
{{level}}
4757
</label>
4858
</div>
4959
</div>
5060
</div>
51-
<div class="col-md-6">
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]" />
67+
{{group}}
68+
</label>
69+
</div>
70+
</div>
71+
</div>
72+
</div>
73+
<div class="panel-body row">
74+
<div class="col-md-12 form-horizontal">
5275
<div class="input-group">
5376
<span class="input-group-addon" id="filter-label">Filter:</span>
5477
<input type="text" class="form-control" placeholder="Keywords or search string" aria-describedby="filter-label" ng-model="search" />
@@ -63,22 +86,27 @@ <h1>ALL the Clippy Lints</h1>
6386
</div>
6487

6588
<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">
89+
ng-repeat="lint in data | filter:byLevels | filter:byGroups | filter:search | orderBy:'id' track by lint.id" on-finish-render="ngRepeatFinished">
6790
<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]">&minus;</span>
70-
<span ng-hide="open[lint.id]">&plus;</span>
71-
</button>
72-
7391
<h2 class="panel-title">
74-
{{lint.id}}
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()">&para;</a>
95+
</div>
96+
97+
<div class="panel-title-addons">
98+
<span class="label label-default text-capitalize">{{lint.group}}</span>
7599

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>
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>
80104

81-
<a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">&para;</a>
105+
<button class="btn btn-default btn-xs">
106+
<span ng-show="open[lint.id]">&minus;</span>
107+
<span ng-hide="open[lint.id]">&plus;</span>
108+
</button>
109+
</div>
82110
</h2>
83111
</header>
84112

@@ -95,7 +123,7 @@ <h4 class="list-group-item-heading">
95123
</div>
96124

97125
<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"/>
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"/>
99127
</a>
100128

101129
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/7.0.0/markdown-it.min.js"></script>
@@ -166,6 +194,11 @@ <h4 class="list-group-item-heading">
166194
return $scope.levels[lint.level];
167195
};
168196

197+
$scope.groups = {};
198+
$scope.byGroups = function (lint) {
199+
return $scope.groups[lint.group];
200+
};
201+
169202
// Get data
170203
$scope.open = {};
171204
$scope.loading = true;
@@ -181,6 +214,12 @@ <h4 class="list-group-item-heading">
181214
$scope.data = data;
182215
$scope.loading = false;
183216

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;
220+
return result;
221+
}, {});
222+
184223
scrollToLintByURL($scope);
185224
})
186225
.error(function (data) {

0 commit comments

Comments
 (0)