MCPcopy Index your code
hub / github.com/neomjs/neo / generateStructure

Function generateStructure

buildScripts/docs/jsdocx.mjs:129–227  ·  view source on GitHub ↗
(namespaceTree, target, parentId, docIndex)

Source from the content-addressed store, hash-verified

127}
128
129function generateStructure(namespaceTree, target, parentId, docIndex) {
130 const namespace = getNamespace(namespaceTree, target);
131
132 if (!namespace) {
133 console.log('Missing namespace:', target);
134 return;
135 }
136
137 const entries = Object.entries(namespace);
138
139 for (const [key, value] of entries) {
140 const id = ++neoStructureId;
141 const isLeaf = Object.keys(value).length === 0;
142 let className = null;
143 let singleton = false;
144 let srcPath = null;
145 let path = '';
146 let hasMatch = false;
147
148 // Check app names
149 for (const appName of appNames) {
150 if (target.indexOf(appName + 'Empty.') === 0) {
151 path = target.substr(appName.length * 2 + 6);
152 className = isLeaf ? appName + (path ? path + '.' : '.') + key : null;
153 hasMatch = true;
154 break;
155 }
156 }
157
158 if (!hasMatch) {
159 if (target.indexOf('DocsEmpty.') === 0) {
160 path = target.substr(15);
161 className = isLeaf ? 'Docs.app.' + (path ? path + '.' : '') + key : null;
162 } else {
163 path = target.substr(target.indexOf('NeoEmpty.') === 0 ? 9 : 8);
164 className = isLeaf ? 'Neo.' + (path ? path + '.' : '') + key : null;
165 className = className === 'Neo.Neo' ? 'Neo' : className;
166 }
167 }
168
169 if (isLeaf && className) {
170 const docItem = docIndex.byClassName.get(className);
171
172 if (docItem) {
173 const metaPath = docItem.meta.path;
174 let m = false;
175
176 // Try different path patterns
177 const patterns = [
178 { search: 'neomjs/neo/', offset: 11 },
179 { search: 'neo.mjs/', offset: 8 },
180 { search: 'neo/', offset: 4 },
181 { search: '/apps/', offset: 1 },
182 { search: '/docs/', offset: 1 }
183 ];
184
185 for (const { search, offset } of patterns) {
186 const i = metaPath.indexOf(search);

Callers 1

jsdocx.mjsFile · 0.85

Calls 7

getNamespaceFunction · 0.85
someMethod · 0.80
includesMethod · 0.80
logMethod · 0.45
indexOfMethod · 0.45
getMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected