Skip to content

Commit 578400c

Browse files
authored
Markdown template tweaks (#2162)
* Add some spacing * Colon syntax for definition doesn't work, so remove it * tweak features display * Category tweaks * Use h5 * Slightly more verbose source link * Escape opening angle bracket on type parameters
1 parent 98fb869 commit 578400c

26 files changed

+106
-37
lines changed

lib/src/model/categorization.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ abstract class Categorization implements ModelElement {
114114
return categories.where((c) => c.isDocumented);
115115
}
116116

117+
bool get hasDisplayedCategories => displayedCategories.isNotEmpty;
118+
117119
/// True if categories, subcategories, a documentation icon, or samples were
118120
/// declared.
119121
bool get hasCategorization {

lib/src/render/type_parameters_renderer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ class TypeParametersRendererMd extends TypeParametersRenderer {
4949
return '';
5050
}
5151
var joined = typeParameters.map(mapfn).join(', ');
52-
return '<${joined}>';
52+
return '&lt;${joined}>';
5353
}
5454
}

lib/templates/md/_accessor_getter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{{#getter}}
2-
{{{ linkedReturnType }}} {{>name_summary}}
2+
{{{ linkedReturnType }}} {{>name_summary}} {{!two spaces intentional}}
33
{{>features}}
44

55
{{>documentation}}
6+
67
{{>source_code}}
78
{{/getter}}

lib/templates/md/_accessor_setter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{{#setter}}
2-
{{>name_summary}}({{{ linkedParamsNoMetadata }}})
2+
{{>name_summary}}({{{ linkedParamsNoMetadata }}}) {{!two spaces intentional}}
33
{{>features}}
44

55
{{>documentation}}
6+
67
{{>source_code}}
78
{{/setter}}

lib/templates/md/_callable.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
{{{linkedName}}}{{{linkedGenericParameters}}}({{{ linkedParamsNoMetadata }}}) {{{ linkedReturnType }}} {{>categorization}}
2-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
1+
##### {{{linkedName}}}{{{linkedGenericParameters}}}({{{ linkedParamsNoMetadata }}}) {{{ linkedReturnType }}}
2+
{{>categorization}}
3+
4+
{{{ oneLineDoc }}} {{{ extendedDocLink }}} {{!two spaces intentional}}
35
{{>features}}

lib/templates/md/_categorization.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
{{#hasCategoryNames}}
1+
{{#hasDisplayedCategories}}
2+
Categories:
23
{{#displayedCategories}}
34
{{{categoryLabel}}}
45
{{/displayedCategories}}
5-
{{/hasCategoryNames}}
6+
{{/hasDisplayedCategories}}

lib/templates/md/_class.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
{{{linkedName}}}{{{linkedGenericParameters}}} {{>categorization}}
2-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
1+
##### {{{linkedName}}}{{{linkedGenericParameters}}}
2+
{{>categorization}}
3+
4+
{{{ oneLineDoc }}} {{{ extendedDocLink }}}

lib/templates/md/_constant.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
{{{ linkedName }}} const {{{ linkedReturnType }}} {{>categorization}}
2-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
1+
##### {{{ linkedName }}} const {{{ linkedReturnType }}}
2+
{{>categorization}}
3+
4+
{{{ oneLineDoc }}} {{{ extendedDocLink }}} {{!two spaces intentional}}
35
{{>features}}

lib/templates/md/_extension.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
{{{linkedName}}} {{>categorization}}
2-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
1+
##### {{{linkedName}}}
2+
{{>categorization}}
3+
4+
{{{ oneLineDoc }}} {{{ extendedDocLink }}}

lib/templates/md/_library.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{{{ linkedName }}} ({{>categorization}})
1+
##### {{{ linkedName }}}
22
{{#isDocumented}}
3-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
3+
{{{ oneLineDoc }}} {{{ extendedDocLink }}}
4+
45
{{/isDocumented}}

lib/templates/md/_mixin.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
{{{linkedName}}}{{{linkedGenericParameters}}} {{>categorization}}
2-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
1+
##### {{{linkedName}}}{{{linkedGenericParameters}}}
2+
{{>categorization}}
3+
4+
{{{ oneLineDoc }}} {{{ extendedDocLink }}}

lib/templates/md/_property.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
{{{linkedName}}} {{{ arrow }}} {{{ linkedReturnType }}} {{>categorization}}
2-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
1+
##### {{{linkedName}}} {{{ arrow }}} {{{ linkedReturnType }}}
2+
{{>categorization}}
3+
4+
{{{ oneLineDoc }}} {{{ extendedDocLink }}} {{!two spaces intentional}}
35
{{>features}}

lib/templates/md/_source_link.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{{#hasSourceHref}}
2-
[source]({{{sourceHref}}})
2+
[view source]({{{sourceHref}}})
33
{{/hasSourceHref}}

lib/templates/md/category.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
{{#publicLibraries}}
1212
{{>library}}
13+
1314
{{/publicLibraries}}
1415
{{/hasPublicLibraries}}
1516

@@ -18,6 +19,7 @@
1819

1920
{{#publicClasses}}
2021
{{>class}}
22+
2123
{{/publicClasses}}
2224
{{/hasPublicClasses}}
2325

@@ -26,6 +28,7 @@
2628

2729
{{#publicMixins}}
2830
{{>mixin}}
31+
2932
{{/publicMixins}}
3033
{{/hasPublicMixins}}
3134

@@ -34,6 +37,7 @@
3437

3538
{{#publicConstants}}
3639
{{>constant}}
40+
3741
{{/publicConstants}}
3842
{{/hasPublicConstants}}
3943

@@ -42,6 +46,7 @@
4246

4347
{{#publicProperties}}
4448
{{>property}}
49+
4550
{{/publicProperties}}
4651
{{/hasPublicProperties}}
4752

@@ -50,6 +55,7 @@
5055

5156
{{#publicFunctions}}
5257
{{>callable}}
58+
5359
{{/publicFunctions}}
5460
{{/hasPublicFunctions}}
5561

@@ -58,6 +64,7 @@
5864

5965
{{#publicEnums}}
6066
{{>class}}
67+
6168
{{/publicEnums}}
6269
{{/hasPublicEnums}}
6370

@@ -66,6 +73,7 @@
6673

6774
{{#publicTypedefs}}
6875
{{>callable}}
76+
6977
{{/publicTypedefs}}
7078
{{/hasPublicTypedefs}}
7179

@@ -74,6 +82,7 @@
7482

7583
{{#publicExceptions}}
7684
{{>class}}
85+
7786
{{/publicExceptions}}
7887
{{/hasPublicExceptions}}
7988
{{/self}}

lib/templates/md/class.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@
6767

6868
{{#publicConstructors}}
6969
{{{linkedName}}} ({{{ linkedParams }}})
70-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
71-
{{#isConst}}const{{/isConst}} {{#isFactory}}factory{{/isFactory}}
70+
71+
{{{ oneLineDoc }}} {{{ extendedDocLink }}} {{!two spaces intentional}}
72+
{{#isConst}}_const_{{/isConst}} {{#isFactory}}_factory_{{/isFactory}}
73+
7274
{{/publicConstructors}}
7375
{{/hasPublicConstructors}}
7476

@@ -77,6 +79,7 @@
7779

7880
{{#allPublicInstanceProperties}}
7981
{{>property}}
82+
8083
{{/allPublicInstanceProperties}}
8184
{{/hasPublicProperties}}
8285

@@ -85,6 +88,7 @@
8588

8689
{{#allPublicInstanceMethods}}
8790
{{>callable}}
91+
8892
{{/allPublicInstanceMethods}}
8993
{{/hasPublicMethods}}
9094

@@ -93,6 +97,7 @@
9397

9498
{{#allPublicOperators}}
9599
{{>callable}}
100+
96101
{{/allPublicOperators}}
97102
{{/hasPublicOperators}}
98103

@@ -101,6 +106,7 @@
101106

102107
{{#publicStaticProperties}}
103108
{{>property}}
109+
104110
{{/publicStaticProperties}}
105111
{{/hasPublicStaticProperties}}
106112

@@ -109,6 +115,7 @@
109115

110116
{{#publicStaticMethods}}
111117
{{>callable}}
118+
112119
{{/publicStaticMethods}}
113120
{{/hasPublicStaticMethods}}
114121

@@ -117,6 +124,7 @@
117124

118125
{{#publicConstants}}
119126
{{>constant}}
127+
120128
{{/publicConstants}}
121129
{{/hasPublicConstants}}
122130
{{/clazz}}

lib/templates/md/constant.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{{{ linkedReturnType }}} {{>name_summary}} = {{{ constantValue }}}
1111

1212
{{>documentation}}
13+
1314
{{>source_code}}
1415
{{/property}}
1516

lib/templates/md/enum.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,19 @@
5959

6060
{{#publicConstants}}
6161
{{>constant}}
62+
6263
{{/publicConstants}}
6364
{{/hasPublicConstants}}
6465

6566
{{#hasPublicConstructors}}
6667
## Constructors
6768

6869
{{#publicConstructors}}
69-
{{{linkedName}}} ({{{ linkedParams }}})
70-
: {{{ oneLineDoc }}} {{{ extendedDocLink }}}
71-
{{#isConst}}const{{/isConst}} {{#isFactory}}factory{{/isFactory}}
70+
{{{linkedName}}}({{{ linkedParams }}})
71+
72+
{{{ oneLineDoc }}} {{{ extendedDocLink }}} {{!two spaces intentional}}
73+
{{#isConst}}_const_{{/isConst}} {{#isFactory}}_factory_{{/isFactory}}
74+
7275
{{/publicConstructors}}
7376
{{/hasPublicConstructors}}
7477

@@ -77,6 +80,7 @@
7780

7881
{{#allPublicInstanceProperties}}
7982
{{>property}}
83+
8084
{{/allPublicInstanceProperties}}
8185
{{/hasPublicProperties}}
8286

@@ -85,6 +89,7 @@
8589

8690
{{#allPublicInstanceMethods}}
8791
{{>callable}}
92+
8893
{{/allPublicInstanceMethods}}
8994
{{/hasPublicMethods}}
9095

@@ -93,6 +98,7 @@
9398

9499
{{#allPublicOperators}}
95100
{{>callable}}
101+
96102
{{/allPublicOperators}}
97103
{{/hasPublicOperators}}
98104

@@ -101,6 +107,7 @@
101107

102108
{{#publicStaticProperties}}
103109
{{>property}}
110+
104111
{{/publicStaticProperties}}
105112
{{/hasPublicStaticProperties}}
106113

@@ -109,6 +116,7 @@
109116

110117
{{#publicStaticMethods}}
111118
{{>callable}}
119+
112120
{{/publicStaticMethods}}
113121
{{/hasPublicStaticMethods}}
114122
{{/eNum}}

lib/templates/md/extension.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@
22

33
{{#self}}
44
# {{{nameWithGenerics}}} {{kind}}
5+
on {{#extendedType}}{{{linkedName}}}{{/extendedType}}
56

67
{{>source_link}}
8+
79
{{>categorization}}
810
{{/self}}
911

1012
{{#extension}}
1113
{{>documentation}}
1214

13-
on
14-
{{#extendedType}}
15-
: {{{linkedName}}}
16-
{{/extendedType}}
17-
1815
{{#hasPublicProperties}}
1916
## Properties
2017

2118
{{#allPublicInstanceProperties}}
2219
{{>property}}
20+
2321
{{/allPublicInstanceProperties}}
2422
{{/hasPublicProperties}}
2523

@@ -28,6 +26,7 @@ on
2826

2927
{{#allPublicInstanceMethods}}
3028
{{>callable}}
29+
3130
{{/allPublicInstanceMethods}}
3231
{{/hasPublicMethods}}
3332

@@ -36,6 +35,7 @@ on
3635

3736
{{#allPublicOperators}}
3837
{{>callable}}
38+
3939
{{/allPublicOperators}}
4040
{{/hasPublicOperators}}
4141

@@ -44,6 +44,7 @@ on
4444

4545
{{#publicStaticProperties}}
4646
{{>property}}
47+
4748
{{/publicStaticProperties}}
4849
{{/hasPublicStaticProperties}}
4950

@@ -52,6 +53,7 @@ on
5253

5354
{{#publicStaticMethods}}
5455
{{>callable}}
56+
5557
{{/publicStaticMethods}}
5658
{{/hasPublicStaticMethods}}
5759

@@ -60,6 +62,7 @@ on
6062

6163
{{#publicConstants}}
6264
{{>constant}}
65+
6366
{{/publicConstants}}
6467
{{/hasPublicConstants}}
6568
{{/extension}}

lib/templates/md/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{{/defaultCategory.publicLibraries}}
2121

2222
{{#categoriesWithPublicLibraries}}
23-
### {{name}}
23+
### Category {{{categoryLabel}}}
2424

2525
{{#publicLibraries}}
2626
{{>library}}

0 commit comments

Comments
 (0)