| author | |
| committer | |
| log | e0ee9d38cf589c70f81444e79b6c7ee551adcf03 |
| tree | 33f5e2d3acacc24e63f259ce5485fee28243ed44 |
| parent | 8d88dcdc61c61e3410138f4402482131f5074a80 |
| parent | 015ea6fd6c0c0deacb42de237f737d208737e3ac |
| signature |
autodoc: Change package to module to better reflect the new names3 files changed, 207 insertions(+), 207 deletions(-)
lib/docs/index.html+38-38| ... | @@ -14,13 +14,13 @@ | ... | @@ -14,13 +14,13 @@ |
| 14 | --bg-color: #ffffff; | 14 | --bg-color: #ffffff; |
| 15 | --link-color: #2A6286; | 15 | --link-color: #2A6286; |
| 16 | --sidebar-sh-color: rgba(0, 0, 0, 0.09); | 16 | --sidebar-sh-color: rgba(0, 0, 0, 0.09); |
| 17 | --sidebar-pkg-bg-color: #f1f1f1; | 17 | --sidebar-mod-bg-color: #f1f1f1; |
| 18 | --sidebar-pkglnk-tx-color: #141414; | 18 | --sidebar-modlnk-tx-color: #141414; |
| 19 | --sidebar-pkglnk-tx-color-hover: #fff; | 19 | --sidebar-modlnk-tx-color-hover: #fff; |
| 20 | --sidebar-pkglnk-tx-color-active: #000; | 20 | --sidebar-modlnk-tx-color-active: #000; |
| 21 | --sidebar-pkglnk-bg-color: transparent; | 21 | --sidebar-modlnk-bg-color: transparent; |
| 22 | --sidebar-pkglnk-bg-color-hover: #555; | 22 | --sidebar-modlnk-bg-color-hover: #555; |
| 23 | --sidebar-pkglnk-bg-color-active: #FFBB4D; | 23 | --sidebar-modlnk-bg-color-active: #FFBB4D; |
| 24 | --search-bg-color: #f3f3f3; | 24 | --search-bg-color: #f3f3f3; |
| 25 | --search-bg-color-focus: #ffffff; | 25 | --search-bg-color-focus: #ffffff; |
| 26 | --search-sh-color: rgba(0, 0, 0, 0.18); | 26 | --search-sh-color: rgba(0, 0, 0, 0.18); |
| ... | @@ -130,8 +130,8 @@ | ... | @@ -130,8 +130,8 @@ |
| 130 | .sidebar .guides-api-switch a { | 130 | .sidebar .guides-api-switch a { |
| 131 | display: block; | 131 | display: block; |
| 132 | padding: 0.5rem 1rem; | 132 | padding: 0.5rem 1rem; |
| 133 | color: var(--sidebar-pkglnk-tx-color); | 133 | color: var(--sidebar-modlnk-tx-color); |
| 134 | background-color: var(--sidebar-pkglnk-bg-color); | 134 | background-color: var(--sidebar-modlnk-bg-color); |
| 135 | border: 1px solid var(--tx-color); | 135 | border: 1px solid var(--tx-color); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| ... | @@ -150,13 +150,13 @@ | ... | @@ -150,13 +150,13 @@ |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | #ApiSwitch:hover:not(.active), #guideSwitch:hover:not(.active) { | 152 | #ApiSwitch:hover:not(.active), #guideSwitch:hover:not(.active) { |
| 153 | color: var(--sidebar-pkglnk-tx-color-hover); | 153 | color: var(--sidebar-modlnk-tx-color-hover); |
| 154 | background-color: var(--sidebar-pkglnk-bg-color-hover); | 154 | background-color: var(--sidebar-modlnk-bg-color-hover); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | .sidebar .guides-api-switch .active { | 157 | .sidebar .guides-api-switch .active { |
| 158 | color: var(--sidebar-pkglnk-tx-color-active); | 158 | color: var(--sidebar-modlnk-tx-color-active); |
| 159 | background-color: var(--sidebar-pkglnk-bg-color-active); | 159 | background-color: var(--sidebar-modlnk-bg-color-active); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | .sidebar h2 { | 162 | .sidebar h2 { |
| ... | @@ -169,29 +169,29 @@ | ... | @@ -169,29 +169,29 @@ |
| 169 | border-bottom: 0.125rem dotted var(--tx-color); | 169 | border-bottom: 0.125rem dotted var(--tx-color); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | .sidebar .packages { | 172 | .sidebar .modules { |
| 173 | list-style-type: none; | 173 | list-style-type: none; |
| 174 | margin: 0; | 174 | margin: 0; |
| 175 | padding: 0; | 175 | padding: 0; |
| 176 | background-color: var(--sidebar-pkg-bg-color); | 176 | background-color: var(--sidebar-mod-bg-color); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | .sidebar .packages > li > a { | 179 | .sidebar .modules > li > a { |
| 180 | display: block; | 180 | display: block; |
| 181 | padding: 0.5rem 1rem; | 181 | padding: 0.5rem 1rem; |
| 182 | color: var(--sidebar-pkglnk-tx-color); | 182 | color: var(--sidebar-modlnk-tx-color); |
| 183 | background-color: var(--sidebar-pkglnk-bg-color); | 183 | background-color: var(--sidebar-modlnk-bg-color); |
| 184 | text-decoration: none; | 184 | text-decoration: none; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | .sidebar .packages > li > a:hover { | 187 | .sidebar .modules > li > a:hover { |
| 188 | color: var(--sidebar-pkglnk-tx-color-hover); | 188 | color: var(--sidebar-modlnk-tx-color-hover); |
| 189 | background-color: var(--sidebar-pkglnk-bg-color-hover); | 189 | background-color: var(--sidebar-modlnk-bg-color-hover); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | .sidebar .packages > li > a.active { | 192 | .sidebar .modules > li > a.active { |
| 193 | color: var(--sidebar-pkglnk-tx-color-active); | 193 | color: var(--sidebar-modlnk-tx-color-active); |
| 194 | background-color: var(--sidebar-pkglnk-bg-color-active); | 194 | background-color: var(--sidebar-modlnk-bg-color-active); |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | .sidebar p.str { | 197 | .sidebar p.str { |
| ... | @@ -495,13 +495,13 @@ | ... | @@ -495,13 +495,13 @@ |
| 495 | --bg-color: #111; | 495 | --bg-color: #111; |
| 496 | --link-color: #88f; | 496 | --link-color: #88f; |
| 497 | --sidebar-sh-color: rgba(128, 128, 128, 0.09); | 497 | --sidebar-sh-color: rgba(128, 128, 128, 0.09); |
| 498 | --sidebar-pkg-bg-color: #333; | 498 | --sidebar-mod-bg-color: #333; |
| 499 | --sidebar-pkglnk-tx-color: #fff; | 499 | --sidebar-modlnk-tx-color: #fff; |
| 500 | --sidebar-pkglnk-tx-color-hover: #fff; | 500 | --sidebar-modlnk-tx-color-hover: #fff; |
| 501 | --sidebar-pkglnk-tx-color-active: #000; | 501 | --sidebar-modlnk-tx-color-active: #000; |
| 502 | --sidebar-pkglnk-bg-color: transparent; | 502 | --sidebar-modlnk-bg-color: transparent; |
| 503 | --sidebar-pkglnk-bg-color-hover: #555; | 503 | --sidebar-modlnk-bg-color-hover: #555; |
| 504 | --sidebar-pkglnk-bg-color-active: #FFBB4D; | 504 | --sidebar-modlnk-bg-color-active: #FFBB4D; |
| 505 | --search-bg-color: #3c3c3c; | 505 | --search-bg-color: #3c3c3c; |
| 506 | --search-bg-color-focus: #000; | 506 | --search-bg-color-focus: #000; |
| 507 | --search-sh-color: rgba(255, 255, 255, 0.28); | 507 | --search-sh-color: rgba(255, 255, 255, 0.28); |
| ... | @@ -590,7 +590,7 @@ | ... | @@ -590,7 +590,7 @@ |
| 590 | padding-right: 1.4rem; | 590 | padding-right: 1.4rem; |
| 591 | background: transparent; | 591 | background: transparent; |
| 592 | } | 592 | } |
| 593 | .packages { | 593 | .modules { |
| 594 | display: flex; | 594 | display: flex; |
| 595 | flex-wrap: wrap; | 595 | flex-wrap: wrap; |
| 596 | } | 596 | } |
| ... | @@ -703,15 +703,15 @@ | ... | @@ -703,15 +703,15 @@ |
| 703 | <div id="guidesList"></div> | 703 | <div id="guidesList"></div> |
| 704 | </div> | 704 | </div> |
| 705 | <div id="apiMenu" class="hidden"> | 705 | <div id="apiMenu" class="hidden"> |
| 706 | <div id="sectMainPkg" class="hidden"> | 706 | <div id="sectMainMod" class="hidden"> |
| 707 | <h2><span>Main Package</span></h2> | 707 | <h2><span>Main Module</span></h2> |
| 708 | <ul class="packages"> | 708 | <ul class="modules"> |
| 709 | <li><a id="mainPkg" class="" href=""></a></li> | 709 | <li><a id="mainMod" class="" href=""></a></li> |
| 710 | </ul> | 710 | </ul> |
| 711 | </div> | 711 | </div> |
| 712 | <div id="sectPkgs" class="hidden"> | 712 | <div id="sectMods" class="hidden"> |
| 713 | <h2><span>Dependencies</span></h2> | 713 | <h2><span>Dependencies</span></h2> |
| 714 | <ul id="listPkgs" class="packages"></ul> | 714 | <ul id="listMods" class="modules"></ul> |
| 715 | </div> | 715 | </div> |
| 716 | <div id="sectInfo" class="hidden"> | 716 | <div id="sectInfo" class="hidden"> |
| 717 | <h2><span>Zig Version</span></h2> | 717 | <h2><span>Zig Version</span></h2> |
lib/docs/main.js+109-109| ... | @@ -17,9 +17,9 @@ const NAV_MODES = { | ... | @@ -17,9 +17,9 @@ const NAV_MODES = { |
| 17 | const domGuidesMenu = document.getElementById("guidesMenu"); | 17 | const domGuidesMenu = document.getElementById("guidesMenu"); |
| 18 | const domApiMenu = document.getElementById("apiMenu"); | 18 | const domApiMenu = document.getElementById("apiMenu"); |
| 19 | const domGuidesList = document.getElementById("guidesList"); | 19 | const domGuidesList = document.getElementById("guidesList"); |
| 20 | const domSectMainPkg = document.getElementById("sectMainPkg"); | 20 | const domSectMainMod = document.getElementById("sectMainMod"); |
| 21 | const domSectPkgs = document.getElementById("sectPkgs"); | 21 | const domSectMods = document.getElementById("sectMods"); |
| 22 | const domListPkgs = document.getElementById("listPkgs"); | 22 | const domListMods = document.getElementById("listMods"); |
| 23 | const domSectTypes = document.getElementById("sectTypes"); | 23 | const domSectTypes = document.getElementById("sectTypes"); |
| 24 | const domListTypes = document.getElementById("listTypes"); | 24 | const domListTypes = document.getElementById("listTypes"); |
| 25 | const domSectTests = document.getElementById("sectTests"); | 25 | const domSectTests = document.getElementById("sectTests"); |
| ... | @@ -66,7 +66,7 @@ const NAV_MODES = { | ... | @@ -66,7 +66,7 @@ const NAV_MODES = { |
| 66 | const domHdrName = document.getElementById("hdrName"); | 66 | const domHdrName = document.getElementById("hdrName"); |
| 67 | const domHelpModal = document.getElementById("helpModal"); | 67 | const domHelpModal = document.getElementById("helpModal"); |
| 68 | const domSearchPlaceholder = document.getElementById("searchPlaceholder"); | 68 | const domSearchPlaceholder = document.getElementById("searchPlaceholder"); |
| 69 | const sourceFileUrlTemplate = "src/{{pkg}}/{{file}}.html#L{{line}}" | 69 | const sourceFileUrlTemplate = "src/{{mod}}/{{file}}.html#L{{line}}" |
| 70 | const domLangRefLink = document.getElementById("langRefLink"); | 70 | const domLangRefLink = document.getElementById("langRefLink"); |
| 71 | 71 | ||
| 72 | let searchTimer = null; | 72 | let searchTimer = null; |
| ... | @@ -83,27 +83,27 @@ const NAV_MODES = { | ... | @@ -83,27 +83,27 @@ const NAV_MODES = { |
| 83 | let typeTypeId = findTypeTypeId(); | 83 | let typeTypeId = findTypeTypeId(); |
| 84 | let pointerSizeEnum = { One: 0, Many: 1, Slice: 2, C: 3 }; | 84 | let pointerSizeEnum = { One: 0, Many: 1, Slice: 2, C: 3 }; |
| 85 | 85 | ||
| 86 | // for each package, is an array with packages to get to this one | 86 | // for each module, is an array with modules to get to this one |
| 87 | let canonPkgPaths = computeCanonicalPackagePaths(); | 87 | let canonModPaths = computeCanonicalModulePaths(); |
| 88 | 88 | ||
| 89 | // for each decl, is an array with {declNames, pkgNames} to get to this one | 89 | // for each decl, is an array with {declNames, modNames} to get to this one |
| 90 | 90 | ||
| 91 | let canonDeclPaths = null; // lazy; use getCanonDeclPath | 91 | let canonDeclPaths = null; // lazy; use getCanonDeclPath |
| 92 | 92 | ||
| 93 | // for each type, is an array with {declNames, pkgNames} to get to this one | 93 | // for each type, is an array with {declNames, modNames} to get to this one |
| 94 | 94 | ||
| 95 | let canonTypeDecls = null; // lazy; use getCanonTypeDecl | 95 | let canonTypeDecls = null; // lazy; use getCanonTypeDecl |
| 96 | 96 | ||
| 97 | let curNav = { | 97 | let curNav = { |
| 98 | mode: NAV_MODES.API, | 98 | mode: NAV_MODES.API, |
| 99 | activeGuide: "", | 99 | activeGuide: "", |
| 100 | // each element is a package name, e.g. @import("a") then within there @import("b") | 100 | // each element is a module name, e.g. @import("a") then within there @import("b") |
| 101 | // starting implicitly from root package | 101 | // starting implicitly from root module |
| 102 | pkgNames: [], | 102 | modNames: [], |
| 103 | // same as above except actual packages, not names | 103 | // same as above except actual modules, not names |
| 104 | pkgObjs: [], | 104 | modObjs: [], |
| 105 | // Each element is a decl name, `a.b.c`, a is 0, b is 1, c is 2, etc. | 105 | // Each element is a decl name, `a.b.c`, a is 0, b is 1, c is 2, etc. |
| 106 | // empty array means refers to the package itself | 106 | // empty array means refers to the module itself |
| 107 | declNames: [], | 107 | declNames: [], |
| 108 | // these will be all types, except the last one may be a type or a decl | 108 | // these will be all types, except the last one may be a type or a decl |
| 109 | declObjs: [], | 109 | declObjs: [], |
| ... | @@ -190,9 +190,9 @@ const NAV_MODES = { | ... | @@ -190,9 +190,9 @@ const NAV_MODES = { |
| 190 | switch (curNav.mode) { | 190 | switch (curNav.mode) { |
| 191 | case NAV_MODES.API: | 191 | case NAV_MODES.API: |
| 192 | case NAV_MODES.API_INTERNAL: | 192 | case NAV_MODES.API_INTERNAL: |
| 193 | let list = curNav.pkgNames.concat(curNav.declNames); | 193 | let list = curNav.modNames.concat(curNav.declNames); |
| 194 | if (list.length === 0) { | 194 | if (list.length === 0) { |
| 195 | document.title = zigAnalysis.packages[zigAnalysis.rootPkg].name + suffix; | 195 | document.title = zigAnalysis.modules[zigAnalysis.rootMod].name + suffix; |
| 196 | } else { | 196 | } else { |
| 197 | document.title = list.join(".") + suffix; | 197 | document.title = list.join(".") + suffix; |
| 198 | } | 198 | } |
| ... | @@ -406,7 +406,7 @@ const NAV_MODES = { | ... | @@ -406,7 +406,7 @@ const NAV_MODES = { |
| 406 | 406 | ||
| 407 | // sidebar guides list | 407 | // sidebar guides list |
| 408 | const section_list = zigAnalysis.guide_sections; | 408 | const section_list = zigAnalysis.guide_sections; |
| 409 | resizeDomList(domGuidesList, section_list.length, '<div><h2><span></span></h2><ul class="packages"></ul></div>'); | 409 | resizeDomList(domGuidesList, section_list.length, '<div><h2><span></span></h2><ul class="modules"></ul></div>'); |
| 410 | for (let j = 0; j < section_list.length; j += 1) { | 410 | for (let j = 0; j < section_list.length; j += 1) { |
| 411 | const section = section_list[j]; | 411 | const section = section_list[j]; |
| 412 | const domSectionName = domGuidesList.children[j].children[0].children[0]; | 412 | const domSectionName = domGuidesList.children[j].children[0].children[0]; |
| ... | @@ -445,7 +445,7 @@ const NAV_MODES = { | ... | @@ -445,7 +445,7 @@ const NAV_MODES = { |
| 445 | } | 445 | } |
| 446 | 446 | ||
| 447 | if (activeGuide == undefined) { | 447 | if (activeGuide == undefined) { |
| 448 | const root_file_idx = zigAnalysis.packages[zigAnalysis.rootPkg].file; | 448 | const root_file_idx = zigAnalysis.modules[zigAnalysis.rootMod].file; |
| 449 | const root_file_name = getFile(root_file_idx).name; | 449 | const root_file_name = getFile(root_file_idx).name; |
| 450 | domGuides.innerHTML = markdown(` | 450 | domGuides.innerHTML = markdown(` |
| 451 | # Zig Guides | 451 | # Zig Guides |
| ... | @@ -492,8 +492,8 @@ const NAV_MODES = { | ... | @@ -492,8 +492,8 @@ const NAV_MODES = { |
| 492 | domFnProto.classList.add("hidden"); | 492 | domFnProto.classList.add("hidden"); |
| 493 | domSectParams.classList.add("hidden"); | 493 | domSectParams.classList.add("hidden"); |
| 494 | domTldDocs.classList.add("hidden"); | 494 | domTldDocs.classList.add("hidden"); |
| 495 | domSectMainPkg.classList.add("hidden"); | 495 | domSectMainMod.classList.add("hidden"); |
| 496 | domSectPkgs.classList.add("hidden"); | 496 | domSectMods.classList.add("hidden"); |
| 497 | domSectTypes.classList.add("hidden"); | 497 | domSectTypes.classList.add("hidden"); |
| 498 | domSectTests.classList.add("hidden"); | 498 | domSectTests.classList.add("hidden"); |
| 499 | domSectDocTests.classList.add("hidden"); | 499 | domSectDocTests.classList.add("hidden"); |
| ... | @@ -518,7 +518,7 @@ const NAV_MODES = { | ... | @@ -518,7 +518,7 @@ const NAV_MODES = { |
| 518 | 518 | ||
| 519 | renderTitle(); | 519 | renderTitle(); |
| 520 | renderInfo(); | 520 | renderInfo(); |
| 521 | renderPkgList(); | 521 | renderModList(); |
| 522 | 522 | ||
| 523 | domPrivDeclsBox.checked = curNav.mode == NAV_MODES.API_INTERNAL; | 523 | domPrivDeclsBox.checked = curNav.mode == NAV_MODES.API_INTERNAL; |
| 524 | 524 | ||
| ... | @@ -526,19 +526,19 @@ const NAV_MODES = { | ... | @@ -526,19 +526,19 @@ const NAV_MODES = { |
| 526 | return renderSearch(); | 526 | return renderSearch(); |
| 527 | } | 527 | } |
| 528 | 528 | ||
| 529 | let rootPkg = zigAnalysis.packages[zigAnalysis.rootPkg]; | 529 | let rootMod = zigAnalysis.modules[zigAnalysis.rootMod]; |
| 530 | let pkg = rootPkg; | 530 | let mod = rootMod; |
| 531 | curNav.pkgObjs = [pkg]; | 531 | curNav.modObjs = [mod]; |
| 532 | for (let i = 1; i < curNav.pkgNames.length; i += 1) { | 532 | for (let i = 1; i < curNav.modNames.length; i += 1) { |
| 533 | let childPkg = zigAnalysis.packages[pkg.table[curNav.pkgNames[i]]]; | 533 | let childMod = zigAnalysis.modules[mod.table[curNav.modNames[i]]]; |
| 534 | if (childPkg == null) { | 534 | if (childMod == null) { |
| 535 | return render404(); | 535 | return render404(); |
| 536 | } | 536 | } |
| 537 | pkg = childPkg; | 537 | mod = childMod; |
| 538 | curNav.pkgObjs.push(pkg); | 538 | curNav.modObjs.push(mod); |
| 539 | } | 539 | } |
| 540 | 540 | ||
| 541 | let currentType = getType(pkg.main); | 541 | let currentType = getType(mod.main); |
| 542 | curNav.declObjs = [currentType]; | 542 | curNav.declObjs = [currentType]; |
| 543 | for (let i = 0; i < curNav.declNames.length; i += 1) { | 543 | for (let i = 0; i < curNav.declNames.length; i += 1) { |
| 544 | let childDecl = findSubDecl(currentType, curNav.declNames[i]); | 544 | let childDecl = findSubDecl(currentType, curNav.declNames[i]); |
| ... | @@ -818,24 +818,24 @@ const NAV_MODES = { | ... | @@ -818,24 +818,24 @@ const NAV_MODES = { |
| 818 | } | 818 | } |
| 819 | 819 | ||
| 820 | function renderNav() { | 820 | function renderNav() { |
| 821 | let len = curNav.pkgNames.length + curNav.declNames.length; | 821 | let len = curNav.modNames.length + curNav.declNames.length; |
| 822 | resizeDomList(domListNav, len, '<li><a href="#"></a></li>'); | 822 | resizeDomList(domListNav, len, '<li><a href="#"></a></li>'); |
| 823 | let list = []; | 823 | let list = []; |
| 824 | let hrefPkgNames = []; | 824 | let hrefModNames = []; |
| 825 | let hrefDeclNames = []; | 825 | let hrefDeclNames = []; |
| 826 | for (let i = 0; i < curNav.pkgNames.length; i += 1) { | 826 | for (let i = 0; i < curNav.modNames.length; i += 1) { |
| 827 | hrefPkgNames.push(curNav.pkgNames[i]); | 827 | hrefModNames.push(curNav.modNames[i]); |
| 828 | let name = curNav.pkgNames[i]; | 828 | let name = curNav.modNames[i]; |
| 829 | list.push({ | 829 | list.push({ |
| 830 | name: name, | 830 | name: name, |
| 831 | link: navLink(hrefPkgNames, hrefDeclNames), | 831 | link: navLink(hrefModNames, hrefDeclNames), |
| 832 | }); | 832 | }); |
| 833 | } | 833 | } |
| 834 | for (let i = 0; i < curNav.declNames.length; i += 1) { | 834 | for (let i = 0; i < curNav.declNames.length; i += 1) { |
| 835 | hrefDeclNames.push(curNav.declNames[i]); | 835 | hrefDeclNames.push(curNav.declNames[i]); |
| 836 | list.push({ | 836 | list.push({ |
| 837 | name: curNav.declNames[i], | 837 | name: curNav.declNames[i], |
| 838 | link: navLink(hrefPkgNames, hrefDeclNames), | 838 | link: navLink(hrefModNames, hrefDeclNames), |
| 839 | }); | 839 | }); |
| 840 | } | 840 | } |
| 841 | 841 | ||
| ... | @@ -866,29 +866,29 @@ const NAV_MODES = { | ... | @@ -866,29 +866,29 @@ const NAV_MODES = { |
| 866 | domStatus.classList.remove("hidden"); | 866 | domStatus.classList.remove("hidden"); |
| 867 | } | 867 | } |
| 868 | 868 | ||
| 869 | function renderPkgList() { | 869 | function renderModList() { |
| 870 | const rootPkg = zigAnalysis.packages[zigAnalysis.rootPkg]; | 870 | const rootMod = zigAnalysis.modules[zigAnalysis.rootMod]; |
| 871 | let list = []; | 871 | let list = []; |
| 872 | for (let key in rootPkg.table) { | 872 | for (let key in rootMod.table) { |
| 873 | let pkgIndex = rootPkg.table[key]; | 873 | let modIndex = rootMod.table[key]; |
| 874 | if (zigAnalysis.packages[pkgIndex] == null) continue; | 874 | if (zigAnalysis.modules[modIndex] == null) continue; |
| 875 | if (key == rootPkg.name) continue; | 875 | if (key == rootMod.name) continue; |
| 876 | list.push({ | 876 | list.push({ |
| 877 | name: key, | 877 | name: key, |
| 878 | pkg: pkgIndex, | 878 | mod: modIndex, |
| 879 | }); | 879 | }); |
| 880 | } | 880 | } |
| 881 | 881 | ||
| 882 | { | 882 | { |
| 883 | let aDom = domSectMainPkg.children[1].children[0].children[0]; | 883 | let aDom = domSectMainMod.children[1].children[0].children[0]; |
| 884 | aDom.textContent = rootPkg.name; | 884 | aDom.textContent = rootMod.name; |
| 885 | aDom.setAttribute("href", navLinkPkg(zigAnalysis.rootPkg)); | 885 | aDom.setAttribute("href", navLinkMod(zigAnalysis.rootMod)); |
| 886 | if (rootPkg.name === curNav.pkgNames[0]) { | 886 | if (rootMod.name === curNav.modNames[0]) { |
| 887 | aDom.classList.add("active"); | 887 | aDom.classList.add("active"); |
| 888 | } else { | 888 | } else { |
| 889 | aDom.classList.remove("active"); | 889 | aDom.classList.remove("active"); |
| 890 | } | 890 | } |
| 891 | domSectMainPkg.classList.remove("hidden"); | 891 | domSectMainMod.classList.remove("hidden"); |
| 892 | } | 892 | } |
| 893 | 893 | ||
| 894 | list.sort(function (a, b) { | 894 | list.sort(function (a, b) { |
| ... | @@ -896,45 +896,45 @@ const NAV_MODES = { | ... | @@ -896,45 +896,45 @@ const NAV_MODES = { |
| 896 | }); | 896 | }); |
| 897 | 897 | ||
| 898 | if (list.length !== 0) { | 898 | if (list.length !== 0) { |
| 899 | resizeDomList(domListPkgs, list.length, '<li><a href="#"></a></li>'); | 899 | resizeDomList(domListMods, list.length, '<li><a href="#"></a></li>'); |
| 900 | for (let i = 0; i < list.length; i += 1) { | 900 | for (let i = 0; i < list.length; i += 1) { |
| 901 | let liDom = domListPkgs.children[i]; | 901 | let liDom = domListMods.children[i]; |
| 902 | let aDom = liDom.children[0]; | 902 | let aDom = liDom.children[0]; |
| 903 | aDom.textContent = list[i].name; | 903 | aDom.textContent = list[i].name; |
| 904 | aDom.setAttribute("href", navLinkPkg(list[i].pkg)); | 904 | aDom.setAttribute("href", navLinkMod(list[i].mod)); |
| 905 | if (list[i].name === curNav.pkgNames[0]) { | 905 | if (list[i].name === curNav.modNames[0]) { |
| 906 | aDom.classList.add("active"); | 906 | aDom.classList.add("active"); |
| 907 | } else { | 907 | } else { |
| 908 | aDom.classList.remove("active"); | 908 | aDom.classList.remove("active"); |
| 909 | } | 909 | } |
| 910 | } | 910 | } |
| 911 | 911 | ||
| 912 | domSectPkgs.classList.remove("hidden"); | 912 | domSectMods.classList.remove("hidden"); |
| 913 | } | 913 | } |
| 914 | } | 914 | } |
| 915 | 915 | ||
| 916 | function navLink(pkgNames, declNames, callName) { | 916 | function navLink(modNames, declNames, callName) { |
| 917 | let base = curNav.mode; | 917 | let base = curNav.mode; |
| 918 | 918 | ||
| 919 | if (pkgNames.length === 0 && declNames.length === 0) { | 919 | if (modNames.length === 0 && declNames.length === 0) { |
| 920 | return base; | 920 | return base; |
| 921 | } else if (declNames.length === 0 && callName == null) { | 921 | } else if (declNames.length === 0 && callName == null) { |
| 922 | return base + pkgNames.join("."); | 922 | return base + modNames.join("."); |
| 923 | } else if (callName == null) { | 923 | } else if (callName == null) { |
| 924 | return base + pkgNames.join(".") + ":" + declNames.join("."); | 924 | return base + modNames.join(".") + ":" + declNames.join("."); |
| 925 | } else { | 925 | } else { |
| 926 | return ( | 926 | return ( |
| 927 | base + pkgNames.join(".") + ":" + declNames.join(".") + ";" + callName | 927 | base + modNames.join(".") + ":" + declNames.join(".") + ";" + callName |
| 928 | ); | 928 | ); |
| 929 | } | 929 | } |
| 930 | } | 930 | } |
| 931 | 931 | ||
| 932 | function navLinkPkg(pkgIndex) { | 932 | function navLinkMod(modIndex) { |
| 933 | return navLink(canonPkgPaths[pkgIndex], []); | 933 | return navLink(canonModPaths[modIndex], []); |
| 934 | } | 934 | } |
| 935 | 935 | ||
| 936 | function navLinkDecl(childName) { | 936 | function navLinkDecl(childName) { |
| 937 | return navLink(curNav.pkgNames, curNav.declNames.concat([childName])); | 937 | return navLink(curNav.modNames, curNav.declNames.concat([childName])); |
| 938 | } | 938 | } |
| 939 | 939 | ||
| 940 | function findDeclNavLink(declName) { | 940 | function findDeclNavLink(declName) { |
| ... | @@ -946,12 +946,12 @@ const NAV_MODES = { | ... | @@ -946,12 +946,12 @@ const NAV_MODES = { |
| 946 | const curDeclName = curNav.declNames[i - 1]; | 946 | const curDeclName = curNav.declNames[i - 1]; |
| 947 | if (curDeclName == declName) { | 947 | if (curDeclName == declName) { |
| 948 | const declPath = curNav.declNames.slice(0, i); | 948 | const declPath = curNav.declNames.slice(0, i); |
| 949 | return navLink(curNav.pkgNames, declPath); | 949 | return navLink(curNav.modNames, declPath); |
| 950 | } | 950 | } |
| 951 | 951 | ||
| 952 | if (findSubDecl(curDecl, declName) != null) { | 952 | if (findSubDecl(curDecl, declName) != null) { |
| 953 | const declPath = curNav.declNames.slice(0, i).concat([declName]); | 953 | const declPath = curNav.declNames.slice(0, i).concat([declName]); |
| 954 | return navLink(curNav.pkgNames, declPath); | 954 | return navLink(curNav.modNames, declPath); |
| 955 | } | 955 | } |
| 956 | } | 956 | } |
| 957 | 957 | ||
| ... | @@ -972,7 +972,7 @@ const NAV_MODES = { | ... | @@ -972,7 +972,7 @@ const NAV_MODES = { |
| 972 | // callName += ')'; | 972 | // callName += ')'; |
| 973 | 973 | ||
| 974 | // declNamesCopy.push(callName); | 974 | // declNamesCopy.push(callName); |
| 975 | // return navLink(curNav.pkgNames, declNamesCopy); | 975 | // return navLink(curNav.modNames, declNamesCopy); |
| 976 | // } | 976 | // } |
| 977 | 977 | ||
| 978 | function resizeDomListDl(dlDom, desiredLen) { | 978 | function resizeDomListDl(dlDom, desiredLen) { |
| ... | @@ -2396,7 +2396,7 @@ const NAV_MODES = { | ... | @@ -2396,7 +2396,7 @@ const NAV_MODES = { |
| 2396 | if ( | 2396 | if ( |
| 2397 | rootIsStd && | 2397 | rootIsStd && |
| 2398 | typeObj === | 2398 | typeObj === |
| 2399 | getType(zigAnalysis.packages[zigAnalysis.rootPkg].main) | 2399 | getType(zigAnalysis.modules[zigAnalysis.rootMod].main) |
| 2400 | ) { | 2400 | ) { |
| 2401 | name = "std"; | 2401 | name = "std"; |
| 2402 | } else { | 2402 | } else { |
| ... | @@ -2702,7 +2702,7 @@ const NAV_MODES = { | ... | @@ -2702,7 +2702,7 @@ const NAV_MODES = { |
| 2702 | const srcNode = getAstNode(decl.src); | 2702 | const srcNode = getAstNode(decl.src); |
| 2703 | const srcFile = getFile(srcNode.file); | 2703 | const srcFile = getFile(srcNode.file); |
| 2704 | return sourceFileUrlTemplate. | 2704 | return sourceFileUrlTemplate. |
| 2705 | replace("{{pkg}}", zigAnalysis.packages[srcFile.pkgIndex].name). | 2705 | replace("{{mod}}", zigAnalysis.modules[srcFile.modIndex].name). |
| 2706 | replace("{{file}}", srcFile.name). | 2706 | replace("{{file}}", srcFile.name). |
| 2707 | replace("{{line}}", srcNode.line + 1); | 2707 | replace("{{line}}", srcNode.line + 1); |
| 2708 | } | 2708 | } |
| ... | @@ -3050,14 +3050,14 @@ const NAV_MODES = { | ... | @@ -3050,14 +3050,14 @@ const NAV_MODES = { |
| 3050 | } | 3050 | } |
| 3051 | 3051 | ||
| 3052 | function detectRootIsStd() { | 3052 | function detectRootIsStd() { |
| 3053 | let rootPkg = zigAnalysis.packages[zigAnalysis.rootPkg]; | 3053 | let rootMod = zigAnalysis.modules[zigAnalysis.rootMod]; |
| 3054 | if (rootPkg.table["std"] == null) { | 3054 | if (rootMod.table["std"] == null) { |
| 3055 | // no std mapped into the root package | 3055 | // no std mapped into the root module |
| 3056 | return false; | 3056 | return false; |
| 3057 | } | 3057 | } |
| 3058 | let stdPkg = zigAnalysis.packages[rootPkg.table["std"]]; | 3058 | let stdMod = zigAnalysis.modules[rootMod.table["std"]]; |
| 3059 | if (stdPkg == null) return false; | 3059 | if (stdMod == null) return false; |
| 3060 | return rootPkg.file === stdPkg.file; | 3060 | return rootMod.file === stdMod.file; |
| 3061 | } | 3061 | } |
| 3062 | 3062 | ||
| 3063 | function indexTypeKinds() { | 3063 | function indexTypeKinds() { |
| ... | @@ -3112,8 +3112,8 @@ const NAV_MODES = { | ... | @@ -3112,8 +3112,8 @@ const NAV_MODES = { |
| 3112 | function updateCurNav() { | 3112 | function updateCurNav() { |
| 3113 | curNav = { | 3113 | curNav = { |
| 3114 | mode: NAV_MODES.API, | 3114 | mode: NAV_MODES.API, |
| 3115 | pkgNames: [], | 3115 | modNames: [], |
| 3116 | pkgObjs: [], | 3116 | modObjs: [], |
| 3117 | declNames: [], | 3117 | declNames: [], |
| 3118 | declObjs: [], | 3118 | declObjs: [], |
| 3119 | callName: null, | 3119 | callName: null, |
| ... | @@ -3123,11 +3123,11 @@ const NAV_MODES = { | ... | @@ -3123,11 +3123,11 @@ const NAV_MODES = { |
| 3123 | const mode = location.hash.substring(0, 3); | 3123 | const mode = location.hash.substring(0, 3); |
| 3124 | let query = location.hash.substring(3); | 3124 | let query = location.hash.substring(3); |
| 3125 | 3125 | ||
| 3126 | const DEFAULT_HASH = NAV_MODES.API + zigAnalysis.packages[zigAnalysis.rootPkg].name; | 3126 | const DEFAULT_HASH = NAV_MODES.API + zigAnalysis.modules[zigAnalysis.rootMod].name; |
| 3127 | switch (mode) { | 3127 | switch (mode) { |
| 3128 | case NAV_MODES.API: | 3128 | case NAV_MODES.API: |
| 3129 | case NAV_MODES.API_INTERNAL: | 3129 | case NAV_MODES.API_INTERNAL: |
| 3130 | // #A;PACKAGE:decl.decl.decl?search-term | 3130 | // #A;MODULE:decl.decl.decl?search-term |
| 3131 | curNav.mode = mode; | 3131 | curNav.mode = mode; |
| 3132 | 3132 | ||
| 3133 | let qpos = query.indexOf("?"); | 3133 | let qpos = query.indexOf("?"); |
| ... | @@ -3143,7 +3143,7 @@ const NAV_MODES = { | ... | @@ -3143,7 +3143,7 @@ const NAV_MODES = { |
| 3143 | if (parts[0] == "") { | 3143 | if (parts[0] == "") { |
| 3144 | location.hash = DEFAULT_HASH; | 3144 | location.hash = DEFAULT_HASH; |
| 3145 | } else { | 3145 | } else { |
| 3146 | curNav.pkgNames = decodeURIComponent(parts[0]).split("."); | 3146 | curNav.modNames = decodeURIComponent(parts[0]).split("."); |
| 3147 | } | 3147 | } |
| 3148 | 3148 | ||
| 3149 | if (parts[1] != null) { | 3149 | if (parts[1] != null) { |
| ... | @@ -3249,30 +3249,30 @@ const NAV_MODES = { | ... | @@ -3249,30 +3249,30 @@ const NAV_MODES = { |
| 3249 | return null; | 3249 | return null; |
| 3250 | } | 3250 | } |
| 3251 | 3251 | ||
| 3252 | function computeCanonicalPackagePaths() { | 3252 | function computeCanonicalModulePaths() { |
| 3253 | let list = new Array(zigAnalysis.packages.length); | 3253 | let list = new Array(zigAnalysis.modules.length); |
| 3254 | // Now we try to find all the packages from root. | 3254 | // Now we try to find all the modules from root. |
| 3255 | let rootPkg = zigAnalysis.packages[zigAnalysis.rootPkg]; | 3255 | let rootMod = zigAnalysis.modules[zigAnalysis.rootMod]; |
| 3256 | // Breadth-first to keep the path shortest possible. | 3256 | // Breadth-first to keep the path shortest possible. |
| 3257 | let stack = [ | 3257 | let stack = [ |
| 3258 | { | 3258 | { |
| 3259 | path: [], | 3259 | path: [], |
| 3260 | pkg: rootPkg, | 3260 | mod: rootMod, |
| 3261 | }, | 3261 | }, |
| 3262 | ]; | 3262 | ]; |
| 3263 | while (stack.length !== 0) { | 3263 | while (stack.length !== 0) { |
| 3264 | let item = stack.shift(); | 3264 | let item = stack.shift(); |
| 3265 | for (let key in item.pkg.table) { | 3265 | for (let key in item.mod.table) { |
| 3266 | let childPkgIndex = item.pkg.table[key]; | 3266 | let childModIndex = item.mod.table[key]; |
| 3267 | if (list[childPkgIndex] != null) continue; | 3267 | if (list[childModIndex] != null) continue; |
| 3268 | let childPkg = zigAnalysis.packages[childPkgIndex]; | 3268 | let childMod = zigAnalysis.modules[childModIndex]; |
| 3269 | if (childPkg == null) continue; | 3269 | if (childMod == null) continue; |
| 3270 | 3270 | ||
| 3271 | let newPath = item.path.concat([key]); | 3271 | let newPath = item.path.concat([key]); |
| 3272 | list[childPkgIndex] = newPath; | 3272 | list[childModIndex] = newPath; |
| 3273 | stack.push({ | 3273 | stack.push({ |
| 3274 | path: newPath, | 3274 | path: newPath, |
| 3275 | pkg: childPkg, | 3275 | mod: childMod, |
| 3276 | }); | 3276 | }); |
| 3277 | } | 3277 | } |
| 3278 | } | 3278 | } |
| ... | @@ -3283,15 +3283,15 @@ const NAV_MODES = { | ... | @@ -3283,15 +3283,15 @@ const NAV_MODES = { |
| 3283 | let list = new Array(zigAnalysis.decls.length); | 3283 | let list = new Array(zigAnalysis.decls.length); |
| 3284 | canonTypeDecls = new Array(zigAnalysis.types.length); | 3284 | canonTypeDecls = new Array(zigAnalysis.types.length); |
| 3285 | 3285 | ||
| 3286 | for (let pkgI = 0; pkgI < zigAnalysis.packages.length; pkgI += 1) { | 3286 | for (let modI = 0; modI < zigAnalysis.modules.length; modI += 1) { |
| 3287 | let pkg = zigAnalysis.packages[pkgI]; | 3287 | let mod = zigAnalysis.modules[modI]; |
| 3288 | let pkgNames = canonPkgPaths[pkgI]; | 3288 | let modNames = canonModPaths[modI]; |
| 3289 | if (pkgNames === undefined) continue; | 3289 | if (modNames === undefined) continue; |
| 3290 | 3290 | ||
| 3291 | let stack = [ | 3291 | let stack = [ |
| 3292 | { | 3292 | { |
| 3293 | declNames: [], | 3293 | declNames: [], |
| 3294 | type: getType(pkg.main), | 3294 | type: getType(mod.main), |
| 3295 | }, | 3295 | }, |
| 3296 | ]; | 3296 | ]; |
| 3297 | while (stack.length !== 0) { | 3297 | while (stack.length !== 0) { |
| ... | @@ -3323,12 +3323,12 @@ const NAV_MODES = { | ... | @@ -3323,12 +3323,12 @@ const NAV_MODES = { |
| 3323 | if (childDecl.is_uns) { | 3323 | if (childDecl.is_uns) { |
| 3324 | unsDeclList.push(childDecl); | 3324 | unsDeclList.push(childDecl); |
| 3325 | } else { | 3325 | } else { |
| 3326 | addDeclToSearchResults(childDecl, childDeclIndex, pkgNames, item, list, stack); | 3326 | addDeclToSearchResults(childDecl, childDeclIndex, modNames, item, list, stack); |
| 3327 | } | 3327 | } |
| 3328 | } | 3328 | } |
| 3329 | } | 3329 | } |
| 3330 | } else { | 3330 | } else { |
| 3331 | addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack); | 3331 | addDeclToSearchResults(decl, declIndex, modNames, item, list, stack); |
| 3332 | } | 3332 | } |
| 3333 | } | 3333 | } |
| 3334 | } | 3334 | } |
| ... | @@ -3337,13 +3337,13 @@ const NAV_MODES = { | ... | @@ -3337,13 +3337,13 @@ const NAV_MODES = { |
| 3337 | return list; | 3337 | return list; |
| 3338 | } | 3338 | } |
| 3339 | 3339 | ||
| 3340 | function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { | 3340 | function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) { |
| 3341 | let declVal = resolveValue(decl.value); | 3341 | let declVal = resolveValue(decl.value); |
| 3342 | let declNames = item.declNames.concat([decl.name]); | 3342 | let declNames = item.declNames.concat([decl.name]); |
| 3343 | 3343 | ||
| 3344 | if (list[declIndex] != null) return; | 3344 | if (list[declIndex] != null) return; |
| 3345 | list[declIndex] = { | 3345 | list[declIndex] = { |
| 3346 | pkgNames: pkgNames, | 3346 | modNames: modNames, |
| 3347 | declNames: declNames, | 3347 | declNames: declNames, |
| 3348 | }; | 3348 | }; |
| 3349 | 3349 | ||
| ... | @@ -3677,8 +3677,8 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { | ... | @@ -3677,8 +3677,8 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { |
| 3677 | const canonPath = getCanonDeclPath(curDeclOrType.find_subdecl_idx); | 3677 | const canonPath = getCanonDeclPath(curDeclOrType.find_subdecl_idx); |
| 3678 | if (!canonPath) return; | 3678 | if (!canonPath) return; |
| 3679 | 3679 | ||
| 3680 | let lastPkgName = canonPath.pkgNames[canonPath.pkgNames.length - 1]; | 3680 | let lastModName = canonPath.modNames[canonPath.modNames.length - 1]; |
| 3681 | let fullPath = lastPkgName + ":" + canonPath.declNames.join("."); | 3681 | let fullPath = lastModName + ":" + canonPath.declNames.join("."); |
| 3682 | 3682 | ||
| 3683 | separator = '.'; | 3683 | separator = '.'; |
| 3684 | result = "#A;" + fullPath; | 3684 | result = "#A;" + fullPath; |
| ... | @@ -3688,8 +3688,8 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { | ... | @@ -3688,8 +3688,8 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { |
| 3688 | } | 3688 | } |
| 3689 | 3689 | ||
| 3690 | if (!curDeclOrType) { | 3690 | if (!curDeclOrType) { |
| 3691 | for (let i = 0; i < zigAnalysis.packages.length; i += 1){ | 3691 | for (let i = 0; i < zigAnalysis.modules.length; i += 1){ |
| 3692 | const p = zigAnalysis.packages[i]; | 3692 | const p = zigAnalysis.modules[i]; |
| 3693 | if (p.name == components[0]) { | 3693 | if (p.name == components[0]) { |
| 3694 | curDeclOrType = getType(p.main); | 3694 | curDeclOrType = getType(p.main); |
| 3695 | result += "#A;" + components[0]; | 3695 | result += "#A;" + components[0]; |
| ... | @@ -4005,9 +4005,9 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { | ... | @@ -4005,9 +4005,9 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { |
| 4005 | if (canonPath == null) continue; | 4005 | if (canonPath == null) continue; |
| 4006 | 4006 | ||
| 4007 | let decl = getDecl(declIndex); | 4007 | let decl = getDecl(declIndex); |
| 4008 | let lastPkgName = canonPath.pkgNames[canonPath.pkgNames.length - 1]; | 4008 | let lastModName = canonPath.modNames[canonPath.modNames.length - 1]; |
| 4009 | let fullPathSearchText = | 4009 | let fullPathSearchText = |
| 4010 | lastPkgName + "." + canonPath.declNames.join("."); | 4010 | lastModName + "." + canonPath.declNames.join("."); |
| 4011 | let astNode = getAstNode(decl.src); | 4011 | let astNode = getAstNode(decl.src); |
| 4012 | let fileAndDocs = ""; //zigAnalysis.files[astNode.file]; | 4012 | let fileAndDocs = ""; //zigAnalysis.files[astNode.file]; |
| 4013 | // TODO: understand what this piece of code is trying to achieve | 4013 | // TODO: understand what this piece of code is trying to achieve |
| ... | @@ -4074,10 +4074,10 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { | ... | @@ -4074,10 +4074,10 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { |
| 4074 | 4074 | ||
| 4075 | for (let i = 0; i < matchedItems.length; i += 1) { | 4075 | for (let i = 0; i < matchedItems.length; i += 1) { |
| 4076 | const match = matchedItems[i]; | 4076 | const match = matchedItems[i]; |
| 4077 | const lastPkgName = match.path.pkgNames[match.path.pkgNames.length - 1]; | 4077 | const lastModName = match.path.modNames[match.path.modNames.length - 1]; |
| 4078 | 4078 | ||
| 4079 | const text = lastPkgName + "." + match.path.declNames.join("."); | 4079 | const text = lastModName + "." + match.path.declNames.join("."); |
| 4080 | const href = navLink(match.path.pkgNames, match.path.declNames); | 4080 | const href = navLink(match.path.modNames, match.path.declNames); |
| 4081 | 4081 | ||
| 4082 | matchedItemsHTML += "<li><a href=\"" + href + "\">" + text + "</a></li>"; | 4082 | matchedItemsHTML += "<li><a href=\"" + href + "\">" + text + "</a></li>"; |
| 4083 | } | 4083 | } |
| ... | @@ -4156,7 +4156,7 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { | ... | @@ -4156,7 +4156,7 @@ function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { |
| 4156 | const file = zigAnalysis.files[idx]; | 4156 | const file = zigAnalysis.files[idx]; |
| 4157 | return { | 4157 | return { |
| 4158 | name: file[0], | 4158 | name: file[0], |
| 4159 | pkgIndex: file[1], | 4159 | modIndex: file[1], |
| 4160 | }; | 4160 | }; |
| 4161 | } | 4161 | } |
| 4162 | 4162 |
src/Autodoc.zig+60-60| ... | @@ -4,23 +4,23 @@ const build_options = @import("build_options"); | ... | @@ -4,23 +4,23 @@ const build_options = @import("build_options"); |
| 4 | const Ast = std.zig.Ast; | 4 | const Ast = std.zig.Ast; |
| 5 | const Autodoc = @This(); | 5 | const Autodoc = @This(); |
| 6 | const Compilation = @import("Compilation.zig"); | 6 | const Compilation = @import("Compilation.zig"); |
| 7 | const Module = @import("Module.zig"); | 7 | const CompilationModule = @import("Module.zig"); |
| 8 | const File = Module.File; | 8 | const File = CompilationModule.File; |
| 9 | const Package = @import("Package.zig"); | 9 | const Module = @import("Package.zig"); |
| 10 | const Tokenizer = std.zig.Tokenizer; | 10 | const Tokenizer = std.zig.Tokenizer; |
| 11 | const Zir = @import("Zir.zig"); | 11 | const Zir = @import("Zir.zig"); |
| 12 | const Ref = Zir.Inst.Ref; | 12 | const Ref = Zir.Inst.Ref; |
| 13 | const log = std.log.scoped(.autodoc); | 13 | const log = std.log.scoped(.autodoc); |
| 14 | const Docgen = @import("autodoc/render_source.zig"); | 14 | const renderer = @import("autodoc/render_source.zig"); |
| 15 | 15 | ||
| 16 | module: *Module, | 16 | comp_module: *CompilationModule, |
| 17 | doc_location: Compilation.EmitLoc, | 17 | doc_location: Compilation.EmitLoc, |
| 18 | arena: std.mem.Allocator, | 18 | arena: std.mem.Allocator, |
| 19 | 19 | ||
| 20 | // The goal of autodoc is to fill up these arrays | 20 | // The goal of autodoc is to fill up these arrays |
| 21 | // that will then be serialized as JSON and consumed | 21 | // that will then be serialized as JSON and consumed |
| 22 | // by the JS frontend. | 22 | // by the JS frontend. |
| 23 | packages: std.AutoArrayHashMapUnmanaged(*Package, DocData.DocPackage) = .{}, | 23 | modules: std.AutoArrayHashMapUnmanaged(*Module, DocData.DocModule) = .{}, |
| 24 | files: std.AutoArrayHashMapUnmanaged(*File, usize) = .{}, | 24 | files: std.AutoArrayHashMapUnmanaged(*File, usize) = .{}, |
| 25 | calls: std.ArrayListUnmanaged(DocData.Call) = .{}, | 25 | calls: std.ArrayListUnmanaged(DocData.Call) = .{}, |
| 26 | types: std.ArrayListUnmanaged(DocData.Type) = .{}, | 26 | types: std.ArrayListUnmanaged(DocData.Type) = .{}, |
| ... | @@ -74,10 +74,10 @@ const Section = struct { | ... | @@ -74,10 +74,10 @@ const Section = struct { |
| 74 | }; | 74 | }; |
| 75 | 75 | ||
| 76 | var arena_allocator: std.heap.ArenaAllocator = undefined; | 76 | var arena_allocator: std.heap.ArenaAllocator = undefined; |
| 77 | pub fn init(m: *Module, doc_location: Compilation.EmitLoc) Autodoc { | 77 | pub fn init(m: *CompilationModule, doc_location: Compilation.EmitLoc) Autodoc { |
| 78 | arena_allocator = std.heap.ArenaAllocator.init(m.gpa); | 78 | arena_allocator = std.heap.ArenaAllocator.init(m.gpa); |
| 79 | return .{ | 79 | return .{ |
| 80 | .module = m, | 80 | .comp_module = m, |
| 81 | .doc_location = doc_location, | 81 | .doc_location = doc_location, |
| 82 | .arena = arena_allocator.allocator(), | 82 | .arena = arena_allocator.allocator(), |
| 83 | }; | 83 | }; |
| ... | @@ -97,15 +97,15 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -97,15 +97,15 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 97 | 97 | ||
| 98 | log.debug("Ref map size: {}", .{Ref.typed_value_map.len}); | 98 | log.debug("Ref map size: {}", .{Ref.typed_value_map.len}); |
| 99 | 99 | ||
| 100 | const root_src_dir = self.module.main_pkg.root_src_directory; | 100 | const root_src_dir = self.comp_module.main_pkg.root_src_directory; |
| 101 | const root_src_path = self.module.main_pkg.root_src_path; | 101 | const root_src_path = self.comp_module.main_pkg.root_src_path; |
| 102 | const joined_src_path = try root_src_dir.join(self.arena, &.{root_src_path}); | 102 | const joined_src_path = try root_src_dir.join(self.arena, &.{root_src_path}); |
| 103 | defer self.arena.free(joined_src_path); | 103 | defer self.arena.free(joined_src_path); |
| 104 | 104 | ||
| 105 | const abs_root_src_path = try std.fs.path.resolve(self.arena, &.{ ".", joined_src_path }); | 105 | const abs_root_src_path = try std.fs.path.resolve(self.arena, &.{ ".", joined_src_path }); |
| 106 | defer self.arena.free(abs_root_src_path); | 106 | defer self.arena.free(abs_root_src_path); |
| 107 | 107 | ||
| 108 | const file = self.module.import_table.get(abs_root_src_path).?; // file is expected to be present in the import table | 108 | const file = self.comp_module.import_table.get(abs_root_src_path).?; // file is expected to be present in the import table |
| 109 | // Append all the types in Zir.Inst.Ref. | 109 | // Append all the types in Zir.Inst.Ref. |
| 110 | { | 110 | { |
| 111 | try self.types.append(self.arena, .{ | 111 | try self.types.append(self.arena, .{ |
| ... | @@ -207,20 +207,20 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -207,20 +207,20 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | const rootName = blk: { | 209 | const rootName = blk: { |
| 210 | const rootName = std.fs.path.basename(self.module.main_pkg.root_src_path); | 210 | const rootName = std.fs.path.basename(self.comp_module.main_pkg.root_src_path); |
| 211 | break :blk rootName[0 .. rootName.len - 4]; | 211 | break :blk rootName[0 .. rootName.len - 4]; |
| 212 | }; | 212 | }; |
| 213 | 213 | ||
| 214 | const main_type_index = self.types.items.len; | 214 | const main_type_index = self.types.items.len; |
| 215 | { | 215 | { |
| 216 | try self.packages.put(self.arena, self.module.main_pkg, .{ | 216 | try self.modules.put(self.arena, self.comp_module.main_pkg, .{ |
| 217 | .name = rootName, | 217 | .name = rootName, |
| 218 | .main = main_type_index, | 218 | .main = main_type_index, |
| 219 | .table = .{}, | 219 | .table = .{}, |
| 220 | }); | 220 | }); |
| 221 | try self.packages.entries.items(.value)[0].table.put( | 221 | try self.modules.entries.items(.value)[0].table.put( |
| 222 | self.arena, | 222 | self.arena, |
| 223 | self.module.main_pkg, | 223 | self.comp_module.main_pkg, |
| 224 | .{ | 224 | .{ |
| 225 | .name = rootName, | 225 | .name = rootName, |
| 226 | .value = 0, | 226 | .value = 0, |
| ... | @@ -257,7 +257,7 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -257,7 +257,7 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 257 | 257 | ||
| 258 | var data = DocData{ | 258 | var data = DocData{ |
| 259 | .params = .{}, | 259 | .params = .{}, |
| 260 | .packages = self.packages, | 260 | .modules = self.modules, |
| 261 | .files = self.files, | 261 | .files = self.files, |
| 262 | .calls = self.calls.items, | 262 | .calls = self.calls.items, |
| 263 | .types = self.types.items, | 263 | .types = self.types.items, |
| ... | @@ -269,7 +269,7 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -269,7 +269,7 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 269 | }; | 269 | }; |
| 270 | 270 | ||
| 271 | const base_dir = self.doc_location.directory orelse | 271 | const base_dir = self.doc_location.directory orelse |
| 272 | self.module.zig_cache_artifact_directory; | 272 | self.comp_module.zig_cache_artifact_directory; |
| 273 | 273 | ||
| 274 | base_dir.handle.makeDir(self.doc_location.basename) catch |e| switch (e) { | 274 | base_dir.handle.makeDir(self.doc_location.basename) catch |e| switch (e) { |
| 275 | error.PathAlreadyExists => {}, | 275 | error.PathAlreadyExists => {}, |
| ... | @@ -279,7 +279,7 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -279,7 +279,7 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 279 | const output_dir = if (self.doc_location.directory) |d| | 279 | const output_dir = if (self.doc_location.directory) |d| |
| 280 | try d.handle.openDir(self.doc_location.basename, .{}) | 280 | try d.handle.openDir(self.doc_location.basename, .{}) |
| 281 | else | 281 | else |
| 282 | try self.module.zig_cache_artifact_directory.handle.openDir(self.doc_location.basename, .{}); | 282 | try self.comp_module.zig_cache_artifact_directory.handle.openDir(self.doc_location.basename, .{}); |
| 283 | 283 | ||
| 284 | { | 284 | { |
| 285 | const data_js_f = try output_dir.createFile("data.js", .{}); | 285 | const data_js_f = try output_dir.createFile("data.js", .{}); |
| ... | @@ -316,8 +316,8 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -316,8 +316,8 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 316 | 316 | ||
| 317 | while (files_iterator.next()) |entry| { | 317 | while (files_iterator.next()) |entry| { |
| 318 | const sub_file_path = entry.key_ptr.*.sub_file_path; | 318 | const sub_file_path = entry.key_ptr.*.sub_file_path; |
| 319 | const file_package = entry.key_ptr.*.pkg; | 319 | const file_module = entry.key_ptr.*.pkg; |
| 320 | const package_name = (self.packages.get(file_package) orelse continue).name; | 320 | const module_name = (self.modules.get(file_module) orelse continue).name; |
| 321 | 321 | ||
| 322 | const file_path = std.fs.path.dirname(sub_file_path) orelse ""; | 322 | const file_path = std.fs.path.dirname(sub_file_path) orelse ""; |
| 323 | const file_name = if (file_path.len > 0) sub_file_path[file_path.len + 1 ..] else sub_file_path; | 323 | const file_name = if (file_path.len > 0) sub_file_path[file_path.len + 1 ..] else sub_file_path; |
| ... | @@ -325,7 +325,7 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -325,7 +325,7 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 325 | const html_file_name = try std.mem.concat(self.arena, u8, &.{ file_name, ".html" }); | 325 | const html_file_name = try std.mem.concat(self.arena, u8, &.{ file_name, ".html" }); |
| 326 | defer self.arena.free(html_file_name); | 326 | defer self.arena.free(html_file_name); |
| 327 | 327 | ||
| 328 | const dir_name = try std.fs.path.join(self.arena, &.{ package_name, file_path }); | 328 | const dir_name = try std.fs.path.join(self.arena, &.{ module_name, file_path }); |
| 329 | defer self.arena.free(dir_name); | 329 | defer self.arena.free(dir_name); |
| 330 | 330 | ||
| 331 | var dir = try html_dir.makeOpenPath(dir_name, .{}); | 331 | var dir = try html_dir.makeOpenPath(dir_name, .{}); |
| ... | @@ -340,13 +340,13 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -340,13 +340,13 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 340 | 340 | ||
| 341 | const out = buffer.writer(); | 341 | const out = buffer.writer(); |
| 342 | 342 | ||
| 343 | try Docgen.genHtml(self.module.gpa, entry.key_ptr.*, out); | 343 | try renderer.genHtml(self.comp_module.gpa, entry.key_ptr.*, out); |
| 344 | try buffer.flush(); | 344 | try buffer.flush(); |
| 345 | } | 345 | } |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | // copy main.js, index.html | 348 | // copy main.js, index.html |
| 349 | var docs_dir = try self.module.comp.zig_lib_directory.handle.openDir("docs", .{}); | 349 | var docs_dir = try self.comp_module.comp.zig_lib_directory.handle.openDir("docs", .{}); |
| 350 | defer docs_dir.close(); | 350 | defer docs_dir.close(); |
| 351 | try docs_dir.copyFile("main.js", output_dir, "main.js", .{}); | 351 | try docs_dir.copyFile("main.js", output_dir, "main.js", .{}); |
| 352 | try docs_dir.copyFile("index.html", output_dir, "index.html", .{}); | 352 | try docs_dir.copyFile("index.html", output_dir, "index.html", .{}); |
| ... | @@ -407,7 +407,7 @@ const Scope = struct { | ... | @@ -407,7 +407,7 @@ const Scope = struct { |
| 407 | /// The output of our analysis process. | 407 | /// The output of our analysis process. |
| 408 | const DocData = struct { | 408 | const DocData = struct { |
| 409 | typeKinds: []const []const u8 = std.meta.fieldNames(DocTypeKinds), | 409 | typeKinds: []const []const u8 = std.meta.fieldNames(DocTypeKinds), |
| 410 | rootPkg: u32 = 0, | 410 | rootMod: u32 = 0, |
| 411 | params: struct { | 411 | params: struct { |
| 412 | zigId: []const u8 = "arst", | 412 | zigId: []const u8 = "arst", |
| 413 | zigVersion: []const u8 = build_options.version, | 413 | zigVersion: []const u8 = build_options.version, |
| ... | @@ -416,7 +416,7 @@ const DocData = struct { | ... | @@ -416,7 +416,7 @@ const DocData = struct { |
| 416 | .{ .target = "arst" }, | 416 | .{ .target = "arst" }, |
| 417 | }, | 417 | }, |
| 418 | }, | 418 | }, |
| 419 | packages: std.AutoArrayHashMapUnmanaged(*Package, DocPackage), | 419 | modules: std.AutoArrayHashMapUnmanaged(*Module, DocModule), |
| 420 | errors: []struct {} = &.{}, | 420 | errors: []struct {} = &.{}, |
| 421 | 421 | ||
| 422 | // non-hardcoded stuff | 422 | // non-hardcoded stuff |
| ... | @@ -448,10 +448,10 @@ const DocData = struct { | ... | @@ -448,10 +448,10 @@ const DocData = struct { |
| 448 | const f_name = @tagName(f); | 448 | const f_name = @tagName(f); |
| 449 | try jsw.objectField(f_name); | 449 | try jsw.objectField(f_name); |
| 450 | switch (f) { | 450 | switch (f) { |
| 451 | .files => try writeFileTableToJson(self.files, self.packages, &jsw), | 451 | .files => try writeFileTableToJson(self.files, self.modules, &jsw), |
| 452 | .guide_sections => try writeGuidesToJson(self.guide_sections, &jsw), | 452 | .guide_sections => try writeGuidesToJson(self.guide_sections, &jsw), |
| 453 | .packages => { | 453 | .modules => { |
| 454 | try std.json.stringify(self.packages.values(), opts, w); | 454 | try std.json.stringify(self.modules.values(), opts, w); |
| 455 | jsw.state_index -= 1; | 455 | jsw.state_index -= 1; |
| 456 | }, | 456 | }, |
| 457 | else => { | 457 | else => { |
| ... | @@ -477,18 +477,18 @@ const DocData = struct { | ... | @@ -477,18 +477,18 @@ const DocData = struct { |
| 477 | const ComptimeExpr = struct { | 477 | const ComptimeExpr = struct { |
| 478 | code: []const u8, | 478 | code: []const u8, |
| 479 | }; | 479 | }; |
| 480 | const DocPackage = struct { | 480 | const DocModule = struct { |
| 481 | name: []const u8 = "(root)", | 481 | name: []const u8 = "(root)", |
| 482 | file: usize = 0, // index into `files` | 482 | file: usize = 0, // index into `files` |
| 483 | main: usize = 0, // index into `types` | 483 | main: usize = 0, // index into `types` |
| 484 | table: std.AutoHashMapUnmanaged(*Package, TableEntry), | 484 | table: std.AutoHashMapUnmanaged(*Module, TableEntry), |
| 485 | pub const TableEntry = struct { | 485 | pub const TableEntry = struct { |
| 486 | name: []const u8, | 486 | name: []const u8, |
| 487 | value: usize, | 487 | value: usize, |
| 488 | }; | 488 | }; |
| 489 | 489 | ||
| 490 | pub fn jsonStringify( | 490 | pub fn jsonStringify( |
| 491 | self: DocPackage, | 491 | self: DocModule, |
| 492 | opts: std.json.StringifyOptions, | 492 | opts: std.json.StringifyOptions, |
| 493 | w: anytype, | 493 | w: anytype, |
| 494 | ) !void { | 494 | ) !void { |
| ... | @@ -496,11 +496,11 @@ const DocData = struct { | ... | @@ -496,11 +496,11 @@ const DocData = struct { |
| 496 | if (opts.whitespace) |ws| jsw.whitespace = ws; | 496 | if (opts.whitespace) |ws| jsw.whitespace = ws; |
| 497 | 497 | ||
| 498 | try jsw.beginObject(); | 498 | try jsw.beginObject(); |
| 499 | inline for (comptime std.meta.tags(std.meta.FieldEnum(DocPackage))) |f| { | 499 | inline for (comptime std.meta.tags(std.meta.FieldEnum(DocModule))) |f| { |
| 500 | const f_name = @tagName(f); | 500 | const f_name = @tagName(f); |
| 501 | try jsw.objectField(f_name); | 501 | try jsw.objectField(f_name); |
| 502 | switch (f) { | 502 | switch (f) { |
| 503 | .table => try writePackageTableToJson(self.table, &jsw), | 503 | .table => try writeModuleTableToJson(self.table, &jsw), |
| 504 | else => { | 504 | else => { |
| 505 | try std.json.stringify(@field(self, f_name), opts, w); | 505 | try std.json.stringify(@field(self, f_name), opts, w); |
| 506 | jsw.state_index -= 1; | 506 | jsw.state_index -= 1; |
| ... | @@ -917,23 +917,23 @@ fn walkInstruction( | ... | @@ -917,23 +917,23 @@ fn walkInstruction( |
| 917 | 917 | ||
| 918 | // importFile cannot error out since all files | 918 | // importFile cannot error out since all files |
| 919 | // are already loaded at this point | 919 | // are already loaded at this point |
| 920 | if (file.pkg.table.get(path)) |other_package| { | 920 | if (file.pkg.table.get(path)) |other_module| { |
| 921 | const result = try self.packages.getOrPut(self.arena, other_package); | 921 | const result = try self.modules.getOrPut(self.arena, other_module); |
| 922 | 922 | ||
| 923 | // Immediately add this package to the import table of our | 923 | // Immediately add this module to the import table of our |
| 924 | // current package, regardless of wether it's new or not. | 924 | // current module, regardless of wether it's new or not. |
| 925 | if (self.packages.getPtr(file.pkg)) |current_package| { | 925 | if (self.modules.getPtr(file.pkg)) |current_module| { |
| 926 | // TODO: apparently, in the stdlib a file gets analized before | 926 | // TODO: apparently, in the stdlib a file gets analized before |
| 927 | // its package gets added. I guess we're importing a file | 927 | // its module gets added. I guess we're importing a file |
| 928 | // that belongs to another package through its file path? | 928 | // that belongs to another module through its file path? |
| 929 | // (ie not through its package name). | 929 | // (ie not through its module name). |
| 930 | // We're bailing for now, but maybe we shouldn't? | 930 | // We're bailing for now, but maybe we shouldn't? |
| 931 | _ = try current_package.table.getOrPutValue( | 931 | _ = try current_module.table.getOrPutValue( |
| 932 | self.arena, | 932 | self.arena, |
| 933 | other_package, | 933 | other_module, |
| 934 | .{ | 934 | .{ |
| 935 | .name = path, | 935 | .name = path, |
| 936 | .value = self.packages.getIndex(other_package).?, | 936 | .value = self.modules.getIndex(other_module).?, |
| 937 | }, | 937 | }, |
| 938 | ); | 938 | ); |
| 939 | } | 939 | } |
| ... | @@ -945,7 +945,7 @@ fn walkInstruction( | ... | @@ -945,7 +945,7 @@ fn walkInstruction( |
| 945 | }; | 945 | }; |
| 946 | } | 946 | } |
| 947 | 947 | ||
| 948 | // create a new package entry | 948 | // create a new module entry |
| 949 | const main_type_index = self.types.items.len; | 949 | const main_type_index = self.types.items.len; |
| 950 | result.value_ptr.* = .{ | 950 | result.value_ptr.* = .{ |
| 951 | .name = path, | 951 | .name = path, |
| ... | @@ -953,18 +953,18 @@ fn walkInstruction( | ... | @@ -953,18 +953,18 @@ fn walkInstruction( |
| 953 | .table = .{}, | 953 | .table = .{}, |
| 954 | }; | 954 | }; |
| 955 | 955 | ||
| 956 | // TODO: Add this package as a dependency to the current package | 956 | // TODO: Add this module as a dependency to the current module |
| 957 | // TODO: this seems something that could be done in bulk | 957 | // TODO: this seems something that could be done in bulk |
| 958 | // at the beginning or the end, or something. | 958 | // at the beginning or the end, or something. |
| 959 | const root_src_dir = other_package.root_src_directory; | 959 | const root_src_dir = other_module.root_src_directory; |
| 960 | const root_src_path = other_package.root_src_path; | 960 | const root_src_path = other_module.root_src_path; |
| 961 | const joined_src_path = try root_src_dir.join(self.arena, &.{root_src_path}); | 961 | const joined_src_path = try root_src_dir.join(self.arena, &.{root_src_path}); |
| 962 | defer self.arena.free(joined_src_path); | 962 | defer self.arena.free(joined_src_path); |
| 963 | 963 | ||
| 964 | const abs_root_src_path = try std.fs.path.resolve(self.arena, &.{ ".", joined_src_path }); | 964 | const abs_root_src_path = try std.fs.path.resolve(self.arena, &.{ ".", joined_src_path }); |
| 965 | defer self.arena.free(abs_root_src_path); | 965 | defer self.arena.free(abs_root_src_path); |
| 966 | 966 | ||
| 967 | const new_file = self.module.import_table.get(abs_root_src_path).?; | 967 | const new_file = self.comp_module.import_table.get(abs_root_src_path).?; |
| 968 | 968 | ||
| 969 | var root_scope = Scope{ | 969 | var root_scope = Scope{ |
| 970 | .parent = null, | 970 | .parent = null, |
| ... | @@ -985,7 +985,7 @@ fn walkInstruction( | ... | @@ -985,7 +985,7 @@ fn walkInstruction( |
| 985 | ); | 985 | ); |
| 986 | } | 986 | } |
| 987 | 987 | ||
| 988 | const new_file = self.module.importFile(file, path) catch unreachable; | 988 | const new_file = self.comp_module.importFile(file, path) catch unreachable; |
| 989 | const result = try self.files.getOrPut(self.arena, new_file.file); | 989 | const result = try self.files.getOrPut(self.arena, new_file.file); |
| 990 | if (result.found_existing) { | 990 | if (result.found_existing) { |
| 991 | return DocData.WalkResult{ | 991 | return DocData.WalkResult{ |
| ... | @@ -3189,7 +3189,7 @@ fn analyzeDecl( | ... | @@ -3189,7 +3189,7 @@ fn analyzeDecl( |
| 3189 | 3189 | ||
| 3190 | // const pl_node = data[Zir.refToIndex(func_index).?].pl_node; | 3190 | // const pl_node = data[Zir.refToIndex(func_index).?].pl_node; |
| 3191 | // const fn_src = try self.srcLocInfo(file, pl_node.src_node, decl_src); | 3191 | // const fn_src = try self.srcLocInfo(file, pl_node.src_node, decl_src); |
| 3192 | // const tree = try file.getTree(self.module.gpa); | 3192 | // const tree = try file.getTree(self.comp_module.gpa); |
| 3193 | // const test_source_code = tree.getNodeSource(fn_src.src_node); | 3193 | // const test_source_code = tree.getNodeSource(fn_src.src_node); |
| 3194 | 3194 | ||
| 3195 | // const ast_node_index = self.ast_nodes.items.len; | 3195 | // const ast_node_index = self.ast_nodes.items.len; |
| ... | @@ -4638,7 +4638,7 @@ fn cteTodo(self: *Autodoc, msg: []const u8) error{OutOfMemory}!DocData.WalkResul | ... | @@ -4638,7 +4638,7 @@ fn cteTodo(self: *Autodoc, msg: []const u8) error{OutOfMemory}!DocData.WalkResul |
| 4638 | 4638 | ||
| 4639 | fn writeFileTableToJson( | 4639 | fn writeFileTableToJson( |
| 4640 | map: std.AutoArrayHashMapUnmanaged(*File, usize), | 4640 | map: std.AutoArrayHashMapUnmanaged(*File, usize), |
| 4641 | pkgs: std.AutoArrayHashMapUnmanaged(*Package, DocData.DocPackage), | 4641 | mods: std.AutoArrayHashMapUnmanaged(*Module, DocData.DocModule), |
| 4642 | jsw: anytype, | 4642 | jsw: anytype, |
| 4643 | ) !void { | 4643 | ) !void { |
| 4644 | try jsw.beginArray(); | 4644 | try jsw.beginArray(); |
| ... | @@ -4649,7 +4649,7 @@ fn writeFileTableToJson( | ... | @@ -4649,7 +4649,7 @@ fn writeFileTableToJson( |
| 4649 | try jsw.arrayElem(); | 4649 | try jsw.arrayElem(); |
| 4650 | try jsw.emitString(entry.key_ptr.*.sub_file_path); | 4650 | try jsw.emitString(entry.key_ptr.*.sub_file_path); |
| 4651 | try jsw.arrayElem(); | 4651 | try jsw.arrayElem(); |
| 4652 | try jsw.emitNumber(pkgs.getIndex(entry.key_ptr.*.pkg) orelse 0); | 4652 | try jsw.emitNumber(mods.getIndex(entry.key_ptr.*.pkg) orelse 0); |
| 4653 | try jsw.endArray(); | 4653 | try jsw.endArray(); |
| 4654 | } | 4654 | } |
| 4655 | try jsw.endArray(); | 4655 | try jsw.endArray(); |
| ... | @@ -4690,8 +4690,8 @@ fn writeGuidesToJson(sections: std.ArrayListUnmanaged(Section), jsw: anytype) !v | ... | @@ -4690,8 +4690,8 @@ fn writeGuidesToJson(sections: std.ArrayListUnmanaged(Section), jsw: anytype) !v |
| 4690 | try jsw.endArray(); | 4690 | try jsw.endArray(); |
| 4691 | } | 4691 | } |
| 4692 | 4692 | ||
| 4693 | fn writePackageTableToJson( | 4693 | fn writeModuleTableToJson( |
| 4694 | map: std.AutoHashMapUnmanaged(*Package, DocData.DocPackage.TableEntry), | 4694 | map: std.AutoHashMapUnmanaged(*Module, DocData.DocModule.TableEntry), |
| 4695 | jsw: anytype, | 4695 | jsw: anytype, |
| 4696 | ) !void { | 4696 | ) !void { |
| 4697 | try jsw.beginObject(); | 4697 | try jsw.beginObject(); |
| ... | @@ -4710,7 +4710,7 @@ fn srcLocInfo( | ... | @@ -4710,7 +4710,7 @@ fn srcLocInfo( |
| 4710 | parent_src: SrcLocInfo, | 4710 | parent_src: SrcLocInfo, |
| 4711 | ) !SrcLocInfo { | 4711 | ) !SrcLocInfo { |
| 4712 | const sn = @intCast(u32, @intCast(i32, parent_src.src_node) + src_node); | 4712 | const sn = @intCast(u32, @intCast(i32, parent_src.src_node) + src_node); |
| 4713 | const tree = try file.getTree(self.module.gpa); | 4713 | const tree = try file.getTree(self.comp_module.gpa); |
| 4714 | const node_idx = @bitCast(Ast.Node.Index, sn); | 4714 | const node_idx = @bitCast(Ast.Node.Index, sn); |
| 4715 | const tokens = tree.nodes.items(.main_token); | 4715 | const tokens = tree.nodes.items(.main_token); |
| 4716 | 4716 | ||
| ... | @@ -4731,7 +4731,7 @@ fn declIsVar( | ... | @@ -4731,7 +4731,7 @@ fn declIsVar( |
| 4731 | parent_src: SrcLocInfo, | 4731 | parent_src: SrcLocInfo, |
| 4732 | ) !bool { | 4732 | ) !bool { |
| 4733 | const sn = @intCast(u32, @intCast(i32, parent_src.src_node) + src_node); | 4733 | const sn = @intCast(u32, @intCast(i32, parent_src.src_node) + src_node); |
| 4734 | const tree = try file.getTree(self.module.gpa); | 4734 | const tree = try file.getTree(self.comp_module.gpa); |
| 4735 | const node_idx = @bitCast(Ast.Node.Index, sn); | 4735 | const node_idx = @bitCast(Ast.Node.Index, sn); |
| 4736 | const tokens = tree.nodes.items(.main_token); | 4736 | const tokens = tree.nodes.items(.main_token); |
| 4737 | const tags = tree.tokens.items(.tag); | 4737 | const tags = tree.tokens.items(.tag); |
| ... | @@ -4743,7 +4743,7 @@ fn declIsVar( | ... | @@ -4743,7 +4743,7 @@ fn declIsVar( |
| 4743 | } | 4743 | } |
| 4744 | 4744 | ||
| 4745 | fn getTLDocComment(self: *Autodoc, file: *File) ![]const u8 { | 4745 | fn getTLDocComment(self: *Autodoc, file: *File) ![]const u8 { |
| 4746 | const source = (try file.getSource(self.module.gpa)).bytes; | 4746 | const source = (try file.getSource(self.comp_module.gpa)).bytes; |
| 4747 | var tokenizer = Tokenizer.init(source); | 4747 | var tokenizer = Tokenizer.init(source); |
| 4748 | var tok = tokenizer.next(); | 4748 | var tok = tokenizer.next(); |
| 4749 | var comment = std.ArrayList(u8).init(self.arena); | 4749 | var comment = std.ArrayList(u8).init(self.arena); |
| ... | @@ -4782,9 +4782,9 @@ fn findGuidePaths(self: *Autodoc, file: *File, str: []const u8) !void { | ... | @@ -4782,9 +4782,9 @@ fn findGuidePaths(self: *Autodoc, file: *File, str: []const u8) !void { |
| 4782 | fn addGuide(self: *Autodoc, file: *File, guide_path: []const u8, section: *Section) !void { | 4782 | fn addGuide(self: *Autodoc, file: *File, guide_path: []const u8, section: *Section) !void { |
| 4783 | if (guide_path.len == 0) return error.MissingAutodocGuideName; | 4783 | if (guide_path.len == 0) return error.MissingAutodocGuideName; |
| 4784 | 4784 | ||
| 4785 | const cur_pkg_dir_path = file.pkg.root_src_directory.path orelse "."; | 4785 | const cur_mod_dir_path = file.pkg.root_src_directory.path orelse "."; |
| 4786 | const resolved_path = try std.fs.path.resolve(self.arena, &[_][]const u8{ | 4786 | const resolved_path = try std.fs.path.resolve(self.arena, &[_][]const u8{ |
| 4787 | cur_pkg_dir_path, file.sub_file_path, "..", guide_path, | 4787 | cur_mod_dir_path, file.sub_file_path, "..", guide_path, |
| 4788 | }); | 4788 | }); |
| 4789 | 4789 | ||
| 4790 | var guide_file = try file.pkg.root_src_directory.handle.openFile(resolved_path, .{}); | 4790 | var guide_file = try file.pkg.root_src_directory.handle.openFile(resolved_path, .{}); |