File tree Expand file tree Collapse file tree 6 files changed +95
-12
lines changed Open diff view settings
Expand file tree Collapse file tree 6 files changed +95
-12
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -103,6 +103,19 @@ em code {
103103 background-color : # 0084B6 ;
104104}
105105
106+ .api_metadata {
107+ font-size : .75em ;
108+ margin-bottom : 1em ;
109+ }
110+
111+ .api_metadata span {
112+ margin-right : 1em ;
113+ }
114+
115+ .api_metadata span : last-child {
116+ margin-right : 0px ;
117+ }
118+
106119ul .plain {
107120 list-style : none;
108121}
Original file line number Diff line number Diff line change @@ -6,18 +6,27 @@ Each type of heading has a description block.
66
77
88 ## module
9+ <!-- YAML
10+ added: v0.10.0
11+ -->
912
1013 Stability: 3 - Stable
1114
1215 description and examples.
1316
1417 ### module.property
18+ <!-- YAML
19+ added: v0.10.0
20+ -->
1521
1622 * Type
1723
1824 description of the property.
1925
2026 ### module.someFunction(x, y, [z=100])
27+ <!-- YAML
28+ added: v0.10.0
29+ -->
2130
2231 * `x` {String} the description of the string
2332 * `y` {Boolean} Should I stay or should I go?
@@ -26,17 +35,26 @@ Each type of heading has a description block.
2635 A description of the function.
2736
2837 ### Event: 'blerg'
38+ <!-- YAML
39+ added: v0.10.0
40+ -->
2941
3042 * Argument: SomeClass object.
3143
3244 Modules don't usually raise events on themselves. `cluster` is the
3345 only exception.
3446
3547 ## Class: SomeClass
48+ <!-- YAML
49+ added: v0.10.0
50+ -->
3651
3752 description of the class.
3853
3954 ### Class Method: SomeClass.classMethod(anArg)
55+ <!-- YAML
56+ added: v0.10.0
57+ -->
4058
4159 * `anArg` {Object} Just an argument
4260 * `field` {String} anArg can have this field.
@@ -46,16 +64,25 @@ Each type of heading has a description block.
4664 Description of the method for humans.
4765
4866 ### someClass.nextSibling()
67+ <!-- YAML
68+ added: v0.10.0
69+ -->
4970
5071 * Return: {SomeClass object | null} The next someClass in line.
5172
5273 ### someClass.someProperty
74+ <!-- YAML
75+ added: v0.10.0
76+ -->
5377
5478 * String
5579
5680 The indication of what someProperty is.
5781
5882 ### Event: 'grelb'
83+ <!-- YAML
84+ added: v0.10.0
85+ -->
5986
6087 * `isBlerg` {Boolean}
6188
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const yaml = require ( 'js-yaml' ) ;
4+
5+ function isYAMLBlock ( text ) {
6+ return ! ! text . match ( / ^ < ! - - Y A M L / ) ;
7+ }
8+
9+ exports . isYAMLBlock = isYAMLBlock ;
10+
11+ function extractAndParseYAML ( text ) {
12+ text = text . trim ( ) ;
13+
14+ text = text . replace ( / ^ < ! - - Y A M L / , '' )
15+ . replace ( / - - > $ / , '' ) ;
16+
17+ // js-yaml.safeLoad() throws on error
18+ return yaml . safeLoad ( text ) ;
19+ }
20+
21+ exports . extractAndParseYAML = extractAndParseYAML ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- var processIncludes = require ( './preprocess.js' ) ;
4- var fs = require ( 'fs' ) ;
3+ const processIncludes = require ( './preprocess.js' ) ;
4+ const fs = require ( 'fs' ) ;
55
66// parse the args.
77// Don't use nopt or whatever for this. It's simple enough.
88
9- var args = process . argv . slice ( 2 ) ;
10- var format = 'json' ;
11- var template = null ;
12- var inputFile = null ;
9+ const args = process . argv . slice ( 2 ) ;
10+ let format = 'json' ;
11+ let template = null ;
12+ let inputFile = null ;
1313
1414args . forEach ( function ( arg ) {
1515 if ( ! arg . match ( / ^ \- \- / ) ) {
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- var fs = require ( 'fs' ) ;
4- var marked = require ( 'marked' ) ;
5- var path = require ( 'path' ) ;
6- var preprocess = require ( './preprocess.js' ) ;
7- var typeParser = require ( './type-parser.js' ) ;
3+ const common = require ( './common.js' ) ;
4+ const fs = require ( 'fs' ) ;
5+ const marked = require ( 'marked' ) ;
6+ const path = require ( 'path' ) ;
7+ const preprocess = require ( './preprocess.js' ) ;
8+ const typeParser = require ( './type-parser.js' ) ;
89
910module . exports = toHTML ;
1011
@@ -148,6 +149,9 @@ function parseLists(input) {
148149 output . push ( tok ) ;
149150 return ;
150151 }
152+ if ( tok . type === 'html' && common . isYAMLBlock ( tok . text ) ) {
153+ tok . text = parseYAML ( tok . text ) ;
154+ }
151155 state = null ;
152156 output . push ( tok ) ;
153157 return ;
@@ -174,6 +178,18 @@ function parseLists(input) {
174178 return output ;
175179}
176180
181+ function parseYAML ( text ) {
182+ const meta = common . extractAndParseYAML ( text ) ;
183+ let html = '<div class="api_metadata">' ;
184+
185+ if ( meta . added || meta . Added ) {
186+ meta . added = meta . added || meta . Added ;
187+
188+ html += '<span>Added: ' + meta . added + '</span>' ;
189+ }
190+
191+ return html + '</div>' ;
192+ }
177193
178194// Syscalls which appear in the docs, but which only exist in BSD / OSX
179195var BSD_ONLY_SYSCALLS = new Set ( [ 'lchmod' ] ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ module.exports = doJSON;
55// Take the lexed input, and return a JSON-encoded object
66// A module looks like this: https://gist.github.com/1777387
77
8- var marked = require ( 'marked' ) ;
8+ const common = require ( './common.js' ) ;
9+ const marked = require ( 'marked' ) ;
910
1011function doJSON ( input , filename , cb ) {
1112 var root = { source : filename } ;
@@ -91,6 +92,8 @@ function doJSON(input, filename, cb) {
9192 current . list = current . list || [ ] ;
9293 current . list . push ( tok ) ;
9394 current . list . level = 1 ;
95+ } else if ( type === 'html' && common . isYAMLBlock ( tok . text ) ) {
96+ current . meta = parseYAML ( tok . text ) ;
9497 } else {
9598 current . desc = current . desc || [ ] ;
9699 if ( ! Array . isArray ( current . desc ) ) {
@@ -274,6 +277,9 @@ function processList(section) {
274277 delete section . list ;
275278}
276279
280+ function parseYAML ( text ) {
281+ return common . extractAndParseYAML ( text ) ;
282+ }
277283
278284// textRaw = "someobject.someMethod(a[, b=100][, c])"
279285function parseSignature ( text , sig ) {
You can’t perform that action at this time.
0 commit comments