-
Notifications
You must be signed in to change notification settings - Fork 173
/
AttributesBuilder.java
635 lines (576 loc) · 15.6 KB
/
AttributesBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
package org.asciidoctor;
import java.net.URI;
import java.util.Date;
import java.util.Map;
public class AttributesBuilder {
private final Attributes attributes = new Attributes();
AttributesBuilder() {
super();
}
/**
* Creates attributes builder.
* @deprecated Use {@link Attributes#builder()} instead.
*
* @return attributes builder.
*/
@Deprecated
public static AttributesBuilder attributes() {
return new AttributesBuilder();
}
/**
* Creates attributes builder.
* @deprecated Use {@link Attributes#builder()} with {@link #arguments(String...)} instead.
*
* @return attributes builder.
*/
@Deprecated
public static AttributesBuilder attributes(String[] arguments) {
AttributesBuilder attributesBuilder = new AttributesBuilder();
attributesBuilder.arguments(arguments);
return attributesBuilder;
}
/**
* Creates attributes builder.
* @deprecated Use {@link Attributes#builder()} with {@link #arguments(String)} instead.
*
* @return attributes builder.
*/
@Deprecated
public static AttributesBuilder attributes(String arguments) {
AttributesBuilder attributesBuilder = new AttributesBuilder();
attributesBuilder.arguments(arguments);
return attributesBuilder;
}
/**
* Source language attribute.
* @param sourceLanguage value.
* @return this instance.
*/
public AttributesBuilder sourceLanguage(String sourceLanguage) {
this.attributes.setSourceLanguage(sourceLanguage);
return this;
}
/**
* Skips front matter.
* @param skipFrontMatter value.
* @return this instance.
*/
public AttributesBuilder skipFrontMatter(boolean skipFrontMatter) {
this.attributes.setSkipFrontMatter(skipFrontMatter);
return this;
}
/**
* Sets ignore undefined flag so lines are kept when they contain a reference to a missing attribute.
* @param ignoreUndefinedAttributes value.
* @return this instance.
*/
public AttributesBuilder ignoreUndefinedAttributes(boolean ignoreUndefinedAttributes) {
this.attributes.setIgnoreUndefinedAttributes(ignoreUndefinedAttributes);
return this;
}
/**
* Sets max include depth attribute.
* @param maxIncludeDepth value.
* @return this instance.
*/
public AttributesBuilder maxIncludeDepth(int maxIncludeDepth) {
this.attributes.setMaxIncludeDepth(maxIncludeDepth);
return this;
}
/**
* Sets sect num levels attribute.
* @param sectnumlevels value.
* @return this instance.
*/
public AttributesBuilder sectNumLevels(int sectnumlevels) {
this.attributes.setSectNumLevels(sectnumlevels);
return this;
}
/**
* Sets attribute missing attribute. (Possible values skip, drop, drop-line)
* @param attributeMissing value.
* @return this instance.
*/
public AttributesBuilder attributeMissing(String attributeMissing) {
this.attributes.setAttributeMissing(attributeMissing);
return this;
}
/**
* Sets attribute undefined attribute. (Possible values skip, drop, drop-line)
* @param attributeUndefined value.
* @return this instance.
*/
public AttributesBuilder attributeUndefined(String attributeUndefined) {
this.attributes.setAttributeUndefined(attributeUndefined);
return this;
}
/**
* Sets setanchor flag.
* @param setAnchors value.
* @return this instance.
*/
public AttributesBuilder setAnchors(boolean setAnchors) {
this.attributes.setAnchors(setAnchors);
return this;
}
/**
* Sets the untitled label value.
* @param untitledLabel value.
* @return this instance.
*/
public AttributesBuilder untitledLabel(String untitledLabel) {
this.attributes.setUntitledLabel(untitledLabel);
return this;
}
/**
* Sets table of contents attribute.
* @param placement where toc is rendered.
* @return this instance.
*/
public AttributesBuilder tableOfContents(Placement placement) {
this.attributes.setTableOfContents(placement);
return this;
}
/**
* Sets table of contents 2 attribute.
* @param placement where toc is rendered.
* @return this instance.
* @deprecated Use {@link #tableOfContents(Placement)}
*/
@Deprecated
public AttributesBuilder tableOfContents2(Placement placement) {
this.attributes.setTableOfContents2(placement);
return this;
}
/**
* Sets allow uri read attribute.
* @param allowUriRead value.
* @return this instance.
*/
public AttributesBuilder allowUriRead(boolean allowUriRead) {
this.attributes.setAllowUriRead(allowUriRead);
return this;
}
/**
* Sets backend attribue.
*
* @param backend
* value.
* @return this instance.
*/
public AttributesBuilder backend(String backend) {
this.attributes.setBackend(backend);
return this;
}
/**
* Sets showtitle value as an alias for notitle!
*
* @param showTitle value.
* @return this instance
*/
public AttributesBuilder showTitle(boolean showTitle) {
this.attributes.setShowTitle(showTitle);
return this;
}
/**
* Sets title of document.
*
* @param title
* for document.
* @return this instance.
*/
public AttributesBuilder title(String title) {
this.attributes.setTitle(title);
return this;
}
/**
* Sets doc type attribute.
*
* @param docType
* value.
* @return this instance.
*/
public AttributesBuilder docType(String docType) {
this.attributes.setDocType(docType);
return this;
}
/**
* Sets image directory.
*
* @param imagesDir
* location.
* @return this instance.
*/
public AttributesBuilder imagesDir(String imagesDir) {
this.attributes.setImagesDir(imagesDir);
return this;
}
/**
* Sets source highlighter processor. It should be supported by asciidoctor.
*
* @param sourceHighlighter
* name of the source highlighting library (e.g., coderay).
* @return this instance.
*/
public AttributesBuilder sourceHighlighter(String sourceHighlighter) {
this.attributes.setSourceHighlighter(sourceHighlighter);
return this;
}
/**
* Sets local date for document.
*
* @param date
* @return this instance.
*/
public AttributesBuilder localDate(Date date) {
this.attributes.setLocalDate(date);
return this;
}
/**
* Sets local time for document.
*
* @param time
* @return this instance.
*/
public AttributesBuilder localTime(Date time) {
this.attributes.setLocalTime(time);
return this;
}
/**
* Sets doc date for current document.
*
* @param date
* @return this instance.
*/
public AttributesBuilder docDate(Date date) {
this.attributes.setDocDate(date);
return this;
}
/**
* Sets doc time for current document.
*
* @param time
* @return this instance.
*/
public AttributesBuilder docTime(Date time) {
this.attributes.setDocTime(time);
return this;
}
/**
* Sets if table of contents should be rendered or not
*
* @param toc
* value
* @return this instance.
*/
public AttributesBuilder tableOfContents(boolean toc) {
this.attributes.setTableOfContents(toc);
return this;
}
/**
* Sets stylesheet name.
*
* @param styleSheetName
* of css file.
* @return this instance.
*/
public AttributesBuilder styleSheetName(String styleSheetName) {
this.attributes.setStyleSheetName(styleSheetName);
return this;
}
/**
* Unsets stylesheet name so document will be generated without style.
*
* @return this instance.
*/
public AttributesBuilder unsetStyleSheet() {
this.attributes.unsetStyleSheet();
return this;
}
/**
* Sets the styles dir.
*
* @param stylesDir
* directory.
* @return this instance.
*/
public AttributesBuilder stylesDir(String stylesDir) {
this.attributes.setStylesDir(stylesDir);
return this;
}
/**
* Sets link css attribute.
*
* @param linkCss
* true if css is linked, false if css is embedded.
* @return this instance.
*/
public AttributesBuilder linkCss(boolean linkCss) {
this.attributes.setLinkCss(linkCss);
return this;
}
/**
* Sets copy css attribute.
*
* @param copyCss
* true if css should be copied to the output location, false
* otherwise.
* @return this instance.
*/
public AttributesBuilder copyCss(boolean copyCss) {
this.attributes.setCopyCss(copyCss);
return this;
}
/**
* Sets which admonition icons to use. Attributes.IMAGE_ICONS constant can be used to use the original icons with images or Attributes.FONT_ICONS for font icons (font-awesome).
*
* @param icons
* value.
* @return this instance.
*/
public AttributesBuilder icons(String icons) {
this.attributes.setIcons(icons);
return this;
}
/**
* Enable icon font remote attribute. If enabled, will use the iconfont-cdn value to load the icon font URI; if disabled, will use the iconfont-name value to locate the icon font CSS file
* @param iconFontRemote true if attribute enabled false otherwise.
* @return this instance.
*/
public AttributesBuilder iconFontRemote(boolean iconFontRemote) {
this.attributes.setIconFontRemote(iconFontRemote);
return this;
}
/**
* The URI prefix of the icon font; looks for minified CSS file based on iconfont-name value; used when iconfont-remote is set
* @param cdnUri uri where css is stored.
* @return this instance.
*/
public AttributesBuilder iconFontCdn(URI cdnUri) {
this.attributes.setIconFontCdn(cdnUri);
return this;
}
/**
* The name of the stylesheet in the stylesdir to load (.css extension added automatically)
* @param iconFontName stylesheet name without .css extension.
* @return this instance.
*/
public AttributesBuilder iconFontName(String iconFontName) {
this.attributes.setIconFontName(iconFontName);
return this;
}
/**
* Sets icons directory location.
*
* @param iconsDir
* location.
* @return this instance.
*/
public AttributesBuilder iconsDir(String iconsDir) {
this.attributes.setIconsDir(iconsDir);
return this;
}
/**
* Sets data-uri attribute.
*
* @param dataUri
* true if images should be embedded, false otherwise.
*/
public AttributesBuilder dataUri(boolean dataUri) {
this.attributes.setDataUri(dataUri);
return this;
}
/**
* Sets custom or unlisted attribute to the default value, empty string.
*
* @param attributeName
* A flag-only attribute, such as "icons"
* @return this instance.
*/
public AttributesBuilder attribute(String attributeName) {
this.attributes.setAttribute(attributeName, "");
return this;
}
/**
* Auto-number section titles.
*
* @param sectionNumbers
* true if numbers should be auto-numbered, false otherwise.
* @return this instance.
*/
public AttributesBuilder sectionNumbers(boolean sectionNumbers) {
this.attributes.setSectionNumbers(sectionNumbers);
return this;
}
/**
* Sets hardbreaks at the end of each line.
*
* @param hardbreaks
* true if each line should be added a hardbreak, false otherwise.
* @return this instance.
*/
public AttributesBuilder hardbreaks(boolean hardbreaks) {
this.attributes.setHardbreaks(hardbreaks);
return this;
}
/**
* Sets cache-uri flag.
*
* @param cacheUri
* true if URI content should be cached, false otherwise.
* @return this instance.
*/
public AttributesBuilder cacheUri(boolean cacheUri) {
this.attributes.setCacheUri(cacheUri);
return this;
}
/**
* Sets hide-uri-scheme flag.
*
* @param hiddenUriScheme
* true if URI is hidden, false otherwise.
* @return this instance.
*/
public AttributesBuilder hiddenUriScheme(boolean hiddenUriScheme) {
this.attributes.setHideUriScheme(hiddenUriScheme);
return this;
}
/**
* Sets appendix-caption label.
*
* @param appendixCaption
* value.
* @return this instance.
*/
public AttributesBuilder appendixCaption(String appendixCaption) {
this.attributes.setAppendixCaption(appendixCaption);
return this;
}
/**
* Sets math default engine.
*
* @param math
* value.
* @return this instance.
*/
public AttributesBuilder math(String math) {
this.attributes.setMath(math);
return this;
}
/**
* Sets linkattrs attribute.
* @param linkAttrs true if Asciidoctor should parse link macro attributes, false otherwise.
*
* @return this instance.
*/
public AttributesBuilder linkAttrs(boolean linkAttrs) {
this.attributes.setLinkAttrs(linkAttrs);
return this;
}
/**
* Sets experimental attribute.
* @param experimental true if experimental features should be enabled, false otherwise.
*/
public AttributesBuilder experimental(boolean experimental) {
this.attributes.setExperimental(experimental);
return this;
}
/**
* Sets nofooter attribute.
* @param noFooter true if footer block should not be shown, false otherwise.
* @return this instance.
*/
public AttributesBuilder noFooter(boolean noFooter) {
this.attributes.setNoFooter(noFooter);
return this;
}
/**
* Sets compat mode attribute.
* @param compatMode value.
* @return this instance.
*/
public AttributesBuilder compatMode(CompatMode compatMode) {
this.attributes.setCompatMode(compatMode);
return this;
}
/**
* Sets custom or unlisted attribute
*
* @param attributeName
* @param attributeValue
* @return this instance.
*/
public AttributesBuilder attribute(String attributeName, Object attributeValue) {
this.attributes.setAttribute(attributeName, attributeValue);
return this;
}
/**
* Adds all attributes.
*
* @param attributes
* map.
* @return this instance.
*/
public AttributesBuilder attributes(Map<String, Object> attributes) {
this.attributes.setAttributes(attributes);
return this;
}
/**
* Sets attributes in string form. An example of a valid string would be:
*
* 'toc sectnums source-highlighter=coderay'
*
* where you are adding three attributes: toc, sectnums and
* source-highlighter with value coderay.
*
* @param attributes
* in string format.
*
* @return this instance.
*/
public AttributesBuilder arguments(String attributes) {
this.attributes.setAttributes(attributes);
return this;
}
/**
* Sets attributes in array form. An example of a valid array would be:
*
* '['toc', 'sectnums']'
*
* where you are adding two attributes: toc and sectnums.
*
* @param attributes
* in array format.
*
* @return this instance.
*/
public AttributesBuilder arguments(String... attributes) {
this.attributes.setAttributes(attributes);
return this;
}
/**
* Gets a map with configured options.
* @deprecated Use {@link #build()} instead.
*
* @return map with all options. By default an empty map is returned.
*/
@Deprecated
public Map<String, Object> asMap() {
return this.attributes.map();
}
/**
* @deprecated Use {@link #build()} instead.
*/
@Deprecated
public Attributes get() {
return this.attributes;
}
/**
* Returns a valid Attributes instance.
*
* @return attributes instance.
*/
public Attributes build() {
return this.attributes;
}
}