Skip to content

Commit ecaf17b

Browse files
committed
Proper unique reference ID creation
1 parent dfe4a0c commit ecaf17b

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rpgledoc",
3-
"version": "0.0.25",
3+
"version": "0.0.26",
44
"description": "",
55
"main": "indexfile.js",
66
"scripts": {

render/util.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,35 @@ function interpretMarkers(str)
7777
return out;
7878
}
7979

80+
/**
81+
* Generate unique reference ID
82+
* <ul>
83+
* <li>Symbols that are not exported are prefixed with their filename
84+
* <li>Symbols that are not global are prefixed with their procedure / data structure
85+
* </ul>
86+
* <p>
87+
* I.e a field in a global data structure non exported will have the following ref ID: {@code
88+
* $FILE_NAME:$DS_NAME:$FIELD_NAME}.
89+
* <p>
90+
* The pattern can be described like this: {@code [$FILE_NAME:][$PROC_NAME:][$DS_NAME:]$SYMBOL}
91+
*/
92+
function ref(tag, index)
93+
{
94+
const ref = ['ref'];
95+
if (!tag.exported)
96+
ref.push(index.filename);
97+
/* Inside procedure */
98+
if (tag.scope.proc && tag.scope.refname !== tag.scope.proc)
99+
ref.push(tag.scope.proc);
100+
/* Inside data structure */
101+
if (tag.scope.ds && tag.scope.refname !== tag.scope.ds)
102+
ref.push(tag.scope.ds);
103+
ref.push(tag.refname);
104+
return ref.join(':');
105+
}
106+
80107
module.exports = {
81108
escapeHtml: escapeHtml,
82-
interpretMarkers: interpretMarkers
109+
interpretMarkers: interpretMarkers,
110+
ref: ref
83111
};

views/indicies.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ block content
2626
button(type="submit") Search
2727
each index in indicies
2828
each tag in index.tags
29-
section(id="ref:" + (tag.exported ? '' : index.filename + ':') + tag.refname,
29+
section(id=util.ref(tag, index),
3030
data-file=index.filename,
3131
data-exported=String(tag.exported))
3232
header

0 commit comments

Comments
 (0)