8000 always generate unique hash ids · DreamCode-Uz/documentation@4048e97 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4048e97

Browse files
mmomtchevanthony-redFox
authored andcommitted
always generate unique hash ids
1 parent d8ac5e9 commit 4048e97

File tree

4 files changed

+291
-4
lines changed

4 files changed

+291
-4
lines changed

__tests__/__snapshots__/bin.js.snap

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,34 @@ exports[`--config 1`] = `
190190
191191
192192
193+
</div>
194+
195+
</li>
196+
197+
198+
<li><a
199+
href='#foobar-1'
200+
class=\\" toggle-sibling\\">
201+
Foobar
202+
<span class='icon'>▸</span>
203+
</a>
204+
205+
<div class='toggle-target display-none'>
206+
207+
208+
<ul class='list-reset py1-ul pl1'>
209+
<li class='h5'><span>Instance members</span></li>
210+
211+
<li><a
212+
href='#foobarbar'
213+
class='regular pre-open'>
214+
#bar
215+
</a></li>
216+
217+
</ul>
218+
219+
220+
193221
</div>
194222
195223
</li>
@@ -1375,6 +1403,112 @@ like a <a href=\\"#klass\\">klass</a>. This needs a <a href=\\"https://developer
13751403
13761404
13771405
1406+
1407+
1408+
1409+
1410+
1411+
1412+
1413+
1414+
1415+
</section>
1416+
1417+
</div>
1418+
</div>
1419+
1420+
</div>
1421+
1422+
1423+
1424+
1425+
1426+
1427+
</section>
1428+
1429+
1430+
1431+
1432+
<section class='p2 mb2 clearfix bg-white minishadow'>
1433+
1434+
1435+
<div class='clearfix'>
1436+
1437+
<h3 class='fl m0' id='foobar-1'>
1438+
Foobar
1439+
</h3>
1440+
1441+
1442+
</div>
1443+
1444+
1445+
<p>This is Foobar
1446+
must have a distinct id from Foo.bar</p>
1447+
1448+
<div class='pre p1 fill-light mt0'>new Foobar()</div>
1449+
1450+
1451+
1452+
1453+
1454+
1455+
1456+
1457+
1458+
1459+
1460+
1461+
1462+
1463+
1464+
1465+
1466+
1467+
1468+
1469+
1470+
1471+
1472+
1473+
1474+
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
1475+
<div class=\\"clearfix\\">
1476+
1477+
<div class='border-bottom' id='foobarbar'>
1478+
<div class=\\"clearfix small pointer toggle-sibling\\">
1479+
<div class=\\"py1 contain\\">
1480+
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
1481+
<span class='code strong strong truncate'>bar</span>
1482+
</div>
1483+
</div>
1484+
<div class=\\"clearfix display-none toggle-target\\">
1485+
<section class='p2 mb2 clearfix bg-white minishadow'>
1486+
1487+
1488+
1489+
<p>This is bar</p>
1490+
1491+
<div class='pre p1 fill-light mt0'>bar</div>
1492+
1493+
1494+
1495+
1496+
1497+
1498+
1499+
1500+
1501+
1502+
1503+
1504+
1505+
1506+
1507+
1508+
1509+
1510+
1511+
13781512
13791513
13801514

__tests__/__snapshots__/test.js.snap

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,34 @@ exports[`html nested.input.js 1`] = `
12161216

12171217

12181218

1219+
</div>
1220+
1221+
</li>
1222+
1223+
1224+
<li><a
1225+
href='#foobar-1'
1226+
class=\\" toggle-sibling\\">
1227+
Foobar
1228+
<span class='icon'>▸</span>
1229+
</a>
1230+
1231+
<div class='toggle-target display-none'>
1232+
1233+
1234+
<ul class='list-reset py1-ul pl1'>
1235+
<li class='h5'><span>Instance members</span></li>
1236+
1237+
<li><a
1238+
href='#foobarbar'
1239+
class='regular pre-open'>
1240+
#bar
1241+
</a></li>
1242+
1243+
</ul>
1244+
1245+
1246+
12191247
</div>
12201248

12211249
</li>
@@ -2379,6 +2407,112 @@ like a <a href=\\"#klass\\">klass</a>. This needs a <a href=\\"https://developer
23792407

23802408

23812409

2410+
2411+
2412+
2413+
2414+
2415+
2416+
2417+
2418+
2419+
</section>
2420+
2421+
</div>
2422+
</div>
2423+
2424+
</div>
2425+
2426+
2427+
2428+
2429+
2430+
2431+
</section>
2432+
2433+
2434+
2435+
2436+
<section class='p2 mb2 clearfix bg-white minishadow'>
2437+
2438+
2439+
<div class='clearfix'>
2440+
2441+
<h3 class='fl m0' id='foobar-1'>
2442+
Foobar
2443+
</h3>
2444+
2445+
2446+
</div>
2447+
2448+
2449+
<p>This is Foobar
2450+
must have a distinct id from Foo.bar</p>
2451+
2452+
<div class='pre p1 fill-light mt0'>new Foobar()</div>
2453+
2454+
2455+
2456+
2457+
2458+
2459+
2460+
2461+
2462+
2463+
2464+
2465+
2466+
2467+
2468+
2469+
2470+
2471+
2472+
2473+
2474+
2475+
2476+
2477+
2478+
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
2479+
<div class=\\"clearfix\\">
2480+
2481+
<div class='border-bottom' id='foobarbar'>
2482+
<div class=\\"clearfix small pointer toggle-sibling\\">
2483+
<div class=\\"py1 contain\\">
2484+
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
2485+
<span class='code strong strong truncate'>bar</span>
2486+
</div>
2487+
</div>
2488+
<div class=\\"clearfix display-none toggle-target\\">
2489+
<section class='p2 mb2 clearfix bg-white minishadow'>
2490+
2491+
2492+
2493+
<p>This is bar</p>
2494+
2495+
<div class='pre p1 fill-light mt0'>bar</div>
2496+
2497+
2498+
2499+
2500+
2501+
2502+
2503+
2504+
2505+
2506+
2507+
2508+
2509+
2510+
2511+
2512+
2513+
2514+
2515+
23822516

23832517

23842518

__tests__/fixture/html/nested.input.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ class Foo {
145145
get bar() {}
146146
}
147147

148+
/**
149+
* This is Foobar
150+
* must have a distinct id from Foo.bar
151+
*/
152+
class Foobar {
153+
/**
154+
* This is bar
155+
*/
156+
get bar() { }
157+
}
158+
148159
/**
149160
* I am the container of stream types
150161
*/

src/default_theme/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,21 @@ function isFunction(section) {
3535
);
3636
}
3737

38+
const slugger = new GithubSlugger();
39+
const slugs = {};
40+
41+
function getSlug(str) {
42+
if (slugs[str] === undefined) {
43+
slugs[str] = slugger.slug(str);
44+
}
45+
return slugs[str];
46+
}
47+
3848
export default async function (comments, config) {
3949
var linkerStack = new LinkerStack(config).namespaceResolver(
4050
comments,
4151
function (namespace) {
42-
var slugger = new GithubSlugger();
43-
return '#' + slugger.slug(namespace);
52+
return '#' + getSlug(namespace);
4453
}
4554
);
4655

@@ -51,8 +60,7 @@ export default async function (comments, config) {
5160
var sharedImports = {
5261
imports: {
5362
slug(str) {
54-
var slugger = new GithubSlugger();
55-
return slugger.slug(str);
63+
return getSlug(str);
5664
},
5765
shortSignature(section) {
5866
var prefix = '';

0 commit comments

Comments
 (0)
0