Skip to content

Commit 962452e

Browse files
committed
Merge branch 'feature/dash-update'
2 parents 5b9c257 + e94a524 commit 962452e

File tree

3 files changed

+32
-41
lines changed

3 files changed

+32
-41
lines changed

lib/utils.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,23 @@ module.exports.buildDashDocSet = function (input) {
1717

1818
input.uid = module.exports.formatStringForUID(input.title);
1919

20-
zip.addFile(
21-
input.title + '.docset/Contents/Resources/Documents/index.html',
22-
require('../templates/dash/index.hbs')(input)
23-
);
20+
input.files.forEach(function (file) {
21+
22+
file.methods.forEach(function (method) {
23+
24+
if (!method.ignore && method.ctx) {
25+
26+
zip.addFile(
27+
input.title + '.docset/Contents/Resources/Documents/' + method.ctx.uid + '.html',
28+
require('../templates/dash/method.hbs')(method)
29+
);
30+
31+
}
32+
33+
});
34+
35+
});
36+
2437

2538
zip.addFile(
2639
input.title + '.docset/Contents/Info.plist',
@@ -53,7 +66,7 @@ module.exports.buildDashDocSet = function (input) {
5366
db.run('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ($name, $type, $path);', {
5467
$name: hbs.helpers.formatName(method.ctx.string),
5568
$type: method.ctx.type.replace(/^[a-z]/, function (match) { return match.toUpperCase(); }),
56-
$path: 'index.html#' + method.ctx.uid
69+
$path: method.ctx.uid + '.html'
5770
});
5871

5972
}
@@ -117,29 +130,21 @@ module.exports.formatStringForUID = function (content) {
117130

118131
module.exports.parseData = function (data, file) {
119132

120-
data.forEach(function (methods) {
133+
data.forEach(function (method) {
121134

122-
if (methods.ctx) {
135+
if (method.ctx) {
123136

124-
methods.ctx.uid = file + '-' + module.exports.formatStringForUID(methods.ctx.string);
137+
method.ctx.uid = file + '-' + module.exports.formatStringForUID(method.ctx.string);
125138

126139
}
127140

128-
if (methods.tags) {
129-
130-
methods.tags.forEach(function (tag) {
131-
132-
if (tag.types) {
133-
134-
tag.types.forEach(function (type, index) {
135-
136-
if (type.match(/\?/g)) {
141+
if (method.tags) {
137142

138-
tag.types[index] = type.replace(/\?/g, '');
143+
method.tags.forEach(function (tag) {
139144

140-
}
145+
if (tag.name && tag.optional) {
141146

142-
});
147+
tag.name = tag.name.replace(/^\[|\]$/g, '');
143148

144149
}
145150

templates/dash/index.hbs renamed to templates/dash/method.hbs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="initial-scale=1">
6-
<title>{{title}}</title>
6+
<title>{{formatName ctx.string}}</title>
77
<link rel="stylesheet" href="resources/bootstrap/bootstrap.min.css">
88
<link rel="stylesheet" href="resources/highlight.js/github.min.css">
99
<style>
@@ -36,12 +36,6 @@ pre .hljs {
3636

3737
<div class="wrap">
3838

39-
<h1>{{title}}{{#if description}} <small>{{description}}</small>{{/if}}</h1>
40-
41-
{{#each files}}
42-
43-
{{#each methods}}
44-
4539
{{#unless ignore}}
4640

4741
{{#if ctx}}
@@ -73,6 +67,7 @@ pre .hljs {
7367

7468
{{#ifCond type "param"}}
7569

70+
<a name="//apple_ref/cpp/Parameter/{{name}}" class="dashAnchor"></a>
7671
<p>
7772
<b>{{name}}</b>
7873
{{#each types}}
@@ -106,6 +101,7 @@ pre .hljs {
106101

107102
{{#ifCond type "property"}}
108103

104+
<a name="//apple_ref/cpp/Property/{{name}}" class="dashAnchor"></a>
109105
<p>
110106
<b>{{name}}</b>
111107
{{#each types}}
@@ -143,14 +139,6 @@ pre .hljs {
143139

144140
</section>
145141

146-
<section class="code">
147-
148-
<h3>Code</h3>
149-
150-
<pre><code class="hljs">{{{highlightBlock code}}}</code></pre>
151-
152-
</section>
153-
154142
<h3>Returns</h3>
155143

156144
{{#each tags}}
@@ -169,10 +157,6 @@ pre .hljs {
169157

170158
{{/unless}}
171159

172-
{{/each}}
173-
174-
{{/each}}
175-
176160
</div>
177161

178162
<footer class="bs-footer">

templates/dash/plist.hbs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
<string>{{uid}}</string>
77
<key>CFBundleName</key>
88
<string>{{title}}</string>
9+
<key>DocSetPlatformFamily</key>
10+
<string>{{uid}}</string>
911
<key>isDashDocset</key>
1012
<true/>
11-
<key>dashIndexFilePath</key>
12-
<string>index.html</string>
13+
<key>DashDocSetFamily</key>
14+
<string>dashtoc</string>
1315
</dict>
1416
</plist>

0 commit comments

Comments
 (0)