(namespaceTree, target, parentId, docIndex)
| 127 | } |
| 128 | |
| 129 | function 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); |
no test coverage detected