Skip to content

Commit 6aa68f4

Browse files
committed
basic cli support, validHtml option
1 parent 19be18c commit 6aa68f4

File tree

4 files changed

+214
-95
lines changed

4 files changed

+214
-95
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ Currently available options and their default values:
8686
| `'scriptPath'` | `'{:dir}/ref.js'` | Local path to a custom javascript (HTML only); `FALSE` means no javascript (tooltips / toggle / kbd shortcuts require JS)
8787
| `'showUrls'` | `FALSE` | Gets information about URLs. Setting to false can improve performance (requires showStringMatches to be TRUE)
8888
| `'timeout'` | `10` | Stop execution after this amount of seconds, forcing an incomplete listing. Applies to all calls
89-
89+
| `'validHtml'` | `FALSE` | For HTML mode only. Whether to produce W3C-valid HTML (larger code output) or unintelligible, potentially browser-incompatible but much smaller code output
9090

9191
## Similar projects
9292

9393
- [Kint](http://raveren.github.io/kint/)
9494
- [dump_r](https://github.com/leeoniya/dump_r.php)
9595
- [Krumo](http://sourceforge.net/projects/krumo/)
9696
- [dBug](http://dbug.ospinto.com/)
97-
- [symfony-vardumper] (http://www.sitepoint.com/var_dump-introducing-symfony-vardumper/)
97+
- [symfony-vardumper](http://www.sitepoint.com/var_dump-introducing-symfony-vardumper/)
9898

9999

100100
## TODOs

ref.css

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/* reset default styles for these elements */
77
.ref i,
88
.ref span,
9+
.ref r,
910
.ref a{
1011
font-style: inherit;
1112
font-weight: inherit;
@@ -19,17 +20,20 @@
1920
}
2021

2122
/* meta content (used to generate tooltips) */
22-
.ref > div{
23+
.ref > div,
24+
.ref > t{
2325
display: none;
2426
}
2527

2628
/* show help cursor when mouse is over an entity with a tooltip */
27-
.ref [data-tip]{
29+
.ref [data-tip],
30+
.ref [h]{
2831
cursor: help;
2932
}
3033

3134
/* pointer if inside a link */
32-
.ref a > [data-tip]{
35+
.ref a > [data-tip],
36+
.ref a > [h]{
3337
cursor: pointer;
3438
}
3539

@@ -70,7 +74,8 @@
7074
margin: 20px 0 0 25px;
7175
}
7276

73-
#rTip [data-cell]{
77+
#rTip [data-cell],
78+
#rTip [c]{
7479
padding: 2px 7px;
7580
}
7681

@@ -85,7 +90,8 @@
8590
color: #777;
8691
}
8792

88-
#rTip [data-cell][data-varType]{
93+
#rTip [data-cell][data-varType],
94+
#rTip [c][data-varType]{
8995
padding: 10px;
9096
background: #333;
9197
box-shadow: inset -1px 0 0 #444;
@@ -94,7 +100,8 @@
94100
border-bottom-left-radius: 4px;
95101
}
96102

97-
#rTip [data-cell][data-sub]{
103+
#rTip [data-cell][data-sub],
104+
#rTip [c][data-sub]{
98105
padding: 8px 10px 10px 10px;
99106
background: #333;
100107
box-shadow: inset 0 1px 0 #444;
@@ -103,20 +110,22 @@
103110
border-bottom-left-radius: 4px;
104111
}
105112

106-
#rTip [data-table] [data-cell]:first-child{
113+
#rTip [data-table] [data-cell]:first-child,
114+
#rTip [t] [c]:first-child{
107115
font: bold 11px Helvetica, Arial;
108116
color: #888;
109117
}
110118

111-
#rTip [data-table] [data-cell]:nth-child(2){
119+
#rTip [data-table] [data-cell]:nth-child(2),
120+
#rTip [t] [c]:nth-child(2){
112121
color: #edd078;
113122
}
114123

115124

116125

117126

118127
/* base entity - can be nested */
119-
.ref span{
128+
.ref span, .ref r{
120129
white-space: pre;
121130
display: inline;
122131
}
@@ -178,16 +187,19 @@
178187
transform: rotate(90deg);
179188
}
180189

181-
.ref [data-group]{
190+
.ref [data-group],
191+
.ref [g]{
182192
display: none;
183193
}
184194

185-
.ref [data-toggle][data-exp] ~ [data-group]{
195+
.ref [data-toggle][data-exp] ~ [data-group],
196+
.ref [data-toggle][data-exp] ~ [g]{
186197
display: block;
187198
}
188199

189200
/* group sections */
190-
.ref [data-table]{
201+
.ref [data-table],
202+
.ref [t]{
191203
display: table;
192204
}
193205

@@ -202,16 +214,20 @@
202214

203215
/* emulate a table for displaying array & object members */
204216
/* section row */
205-
.ref [data-row]{
217+
.ref [data-row],
218+
.ref [r]{
206219
display: table-row;
207220
}
208221

209222
/* zebra-like rows */
210223
.ref [data-output] [data-row]:nth-child(odd){background: #f4f4f4;}
211224
.ref [data-output] [data-row]:nth-child(even){background: #f9f9f9;}
225+
.ref [data-output] [r]:nth-child(odd){background: #f4f4f4;}
226+
.ref [data-output] [r]:nth-child(even){background: #f9f9f9;}
212227

213228
/* section cells */
214-
.ref [data-cell]{
229+
.ref [data-cell],
230+
.ref [c]{
215231
display: table-cell;
216232
width: auto;
217233
vertical-align: top;
@@ -220,7 +236,9 @@
220236

221237
/* last cell of a row (forces table to adjust width like we want to) */
222238
.ref [data-output] [data-table],
223-
.ref [data-output] [data-cell]:last-child{
239+
.ref [data-output] [t],
240+
.ref [data-output] [data-cell]:last-child,
241+
.ref [data-output] [c]:last-child{
224242
width: 100%;
225243
}
226244

@@ -232,7 +250,8 @@
232250
.ref [data-null],
233251
.ref [data-unknown],
234252
.ref [data-resource],
235-
.ref [data-match]{
253+
.ref [data-match],
254+
.ref [m]{
236255
font: bold 11px Helvetica, Arial;
237256
color: #fff;
238257
padding: 1px 3px;
@@ -246,7 +265,8 @@
246265
}
247266

248267
/* string matches */
249-
.ref [data-match]{
268+
.ref [data-match],
269+
.ref [m]{
250270
background-color: #d78035;
251271
}
252272

@@ -356,7 +376,8 @@
356376
}
357377

358378
/* group info prefix */
359-
.ref [data-gLabel]{
379+
.ref [data-gLabel],
380+
.ref [gl]{
360381
font: bold 11px Helvetica, Arial;
361382
padding: 0 3px;
362383
color: #333;
@@ -373,7 +394,8 @@
373394
color: #444;
374395
}
375396

376-
.ref [data-mod] span{
397+
.ref [data-mod] span,
398+
.ref [data-mod] r{
377399
display: inline-block;
378400
margin: 0 2px;
379401
width: 14px;

ref.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,29 @@ window.addEventListener('load', function(){
4545

4646
tip.id = 'rTip';
4747
document.body.appendChild(tip);
48-
});
4948

50-
window.addEventListener('keydown', function(e){
51-
52-
var tt = e.target.tagName.toLowerCase();
53-
if((e.keyCode != 88) || (tt == 'input') || (tt == 'textarea') || (tt == 'select'))
54-
return;
55-
56-
var kbds = document.querySelectorAll('.ref [data-toggle]'),
57-
partlyExp = document.querySelectorAll('.ref [data-toggle][data-exp]').length !== kbds.length,
58-
_ref = document.querySelectorAll('.ref');
59-
60-
61-
e.preventDefault();
62-
63-
if( e.ctrlKey && e.keyCode == 88 ){
64-
for(var i = 0, m = _ref.length; i < m; i++){
65-
if( _ref[i].style.display == 'none' ){
66-
_ref[i].style.display = 'block';
67-
}else{
68-
_ref[i].style.display = 'none';
69-
}
70-
}
71-
}else{
72-
for(var i = 0, m = kbds.length; i < m; i++)
49+
window.addEventListener('keydown', function(e){
50+
if((e.keyCode != 88) || (['input', 'textarea', 'select'].indexOf(e.target.tagName.toLowerCase()) > -1))
51+
return;
52+
53+
e.preventDefault();
54+
55+
if(e.ctrlKey && e.keyCode == 88){
56+
var d = refs[0].style.display !== 'none' ? 'none' : 'block';
57+
for(var i = 0, n = refs.length; i < n; i++)
58+
refs[i].style.display = d;
59+
60+
return;
61+
}
62+
63+
var kbds = document.querySelectorAll('.ref [data-toggle]'),
64+
m = kbds.length,
65+
partlyExp = document.querySelectorAll('.ref [data-toggle][data-exp]').length !== m;
66+
67+
for(var i = 0; i < m; i++)
7368
partlyExp ? (kbds[i].dataset.exp = 1) : (delete kbds[i].dataset.exp);
74-
}
75-
69+
70+
});
71+
7672
});
73+

0 commit comments

Comments
 (0)