config.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. import { createRequire } from 'module'
  2. import { defineAdditionalConfig, type DefaultTheme } from 'vitepress'
  3. import { builtinModulesApiSidebarItems, extensionModulesApiSidebarItems } from './sidebar'
  4. const require = createRequire(import.meta.url)
  5. const pkg = require('vitepress/package.json')
  6. export default defineAdditionalConfig({
  7. lang: 'en-US',
  8. description: "A cross-platform build utility based on Lua",
  9. themeConfig: {
  10. nav: nav(),
  11. sidebar: {
  12. '/guide/': { base: '/guide/', items: guideSidebar() },
  13. '/api/description/': { base: '/api/description/', items: descriptionApiSidebar() },
  14. '/api/scripts/': { base: '/api/scripts/', items: scriptsApiSidebar() },
  15. '/examples/': { base: '/examples/', items: examplesSidebar() },
  16. },
  17. editLink: {
  18. pattern: 'https://github.com/xmake-io/xmake-docs/edit/master/docs/:path',
  19. text: 'Edit this page on GitHub'
  20. }
  21. }
  22. })
  23. function nav(): DefaultTheme.NavItem[] {
  24. return [
  25. {
  26. text: 'Docs',
  27. activeMatch: `^/(guide|style-guide|cookbook|examples)/`,
  28. items: [
  29. { text: 'Guide', link: '/guide/introduction', activeMatch: '/guide/' },
  30. { text: 'Quick Start', link: '/guide/quick-start' },
  31. { text: 'Examples', link: '/examples/cpp/basic', activeMatch: '/examples/' },
  32. { text: 'API Reference', link: '/api/description/specification', activeMatch: '/api/' }
  33. ]
  34. },
  35. {
  36. text: 'Ecosystem',
  37. items: [
  38. {
  39. text: 'Resources',
  40. items: [
  41. { text: 'Xmake Packages', link: 'https://xmake.microblock.cc/' }
  42. ]
  43. },
  44. {
  45. text: 'Help',
  46. items: [
  47. { text: 'Community', link: '/about/contact' },
  48. { text: 'Feedback', link: 'https://github.com/xmake-io/xmake/issues' },
  49. { text: 'Who is using Xmake?', link: '/about/who_is_using_xmake' }
  50. ]
  51. }
  52. ]
  53. },
  54. { text: 'Sponsor', link: '/about/sponsor' }
  55. ]
  56. }
  57. function guideSidebar(): DefaultTheme.SidebarItem[] {
  58. return [
  59. {
  60. text: 'Getting Started',
  61. collapsed: false,
  62. items: [
  63. { text: 'Introduction', link: 'introduction' },
  64. { text: 'Quick Start', link: 'quick-start' },
  65. ]
  66. },
  67. {
  68. text: 'Basic Commands',
  69. collapsed: false,
  70. items: [
  71. { text: 'Create Project', link: 'basic-commands/create-project' },
  72. { text: 'Build Configuration', link: 'basic-commands/build-configuration' },
  73. { text: 'Build Targets', link: 'basic-commands/build-targets' },
  74. { text: 'Run Targets', link: 'basic-commands/run-targets' },
  75. { text: 'Cross Compilation', link: 'basic-commands/cross-compilation' },
  76. { text: 'Switch Toolchains', link: 'basic-commands/switch-toolchains' },
  77. ]
  78. },
  79. {
  80. text: 'Project Configuration',
  81. collapsed: false,
  82. items: [
  83. { text: 'Syntax Description', link: 'project-configuration/syntax-description' },
  84. { text: 'Multi-level Directories', link: 'project-configuration/multi-level-directories' },
  85. { text: 'Toolchain Configuration', link: 'project-configuration/toolchain-configuration' },
  86. ]
  87. },
  88. {
  89. text: 'Package Management',
  90. collapsed: false,
  91. items: [
  92. {
  93. text: 'Using Remote Packages',
  94. collapsed: true,
  95. items: [
  96. { text: 'Using Official Packages', link: 'package-management/using-official-packages' },
  97. { text: 'Using Third-party Packages', link: 'package-management/using-third-party-packages' },
  98. { text: 'Using Packages in CMake', link: 'package-management/using-packages-in-cmake' },
  99. { text: 'Package Distribution', link: 'package-management/package-distribution' },
  100. ]
  101. },
  102. { text: 'Using Local Packages', link: 'package-management/using-local-packages' },
  103. { text: 'Using System Packages', link: 'package-management/using-system-packages' },
  104. { text: 'Using Sourcecode Packages', link: 'package-management/using-source-code-packages' },
  105. { text: 'Network Optimization', link: 'package-management/network-optimization' },
  106. {
  107. text: 'CLI',
  108. collapsed: true,
  109. items: [
  110. { text: 'Package Management in Project', link: 'package-management/package-management-in-project' },
  111. { text: 'Repository Management', link: 'package-management/repository-management' },
  112. { text: 'Xrepo CLI', link: 'package-management/xrepo-cli' },
  113. ]
  114. },
  115. ]
  116. },
  117. {
  118. text: 'Extensions',
  119. collapsed: false,
  120. items: [
  121. { text: 'Plugin Development', link: 'extensions/plugin-development' },
  122. { text: 'Builtin Plugins', link: 'extensions/builtin-plugins' },
  123. { text: 'IDE Integration Plugins', link: 'extensions/ide-integration-plugins' },
  124. { text: 'Theme Style', link: 'extensions/theme-style' },
  125. ]
  126. },
  127. {
  128. text: 'Best Practices',
  129. collapsed: false,
  130. items: [
  131. { text: 'FAQ', link: 'best-practices/faq' },
  132. { text: 'Performance', link: 'best-practices/performance' },
  133. ]
  134. },
  135. {
  136. text: 'Extra Topics',
  137. collapsed: false,
  138. items: [
  139. { text: 'Remote Compilation', link: 'extras/remote-compilation' },
  140. { text: 'Distributed Compilation', link: 'extras/distributed-compilation' },
  141. { text: 'Build Cache Acceleration', link: 'extras/build-cache' },
  142. { text: 'Unity Build Acceleration', link: 'extras/unity-build' },
  143. { text: 'Auto-scan Sourcecode', link: 'extras/autoscan-sourcecode' },
  144. { text: 'Try Build 3rd Sourcecode', link: 'extras/trybuild-3rd-sourcecode' },
  145. { text: 'Envirnoment Variables', link: 'extras/environment-variables' },
  146. ]
  147. },
  148. {
  149. text: 'Next Steps',
  150. collapsed: false,
  151. items: [
  152. { text: 'API Reference', link: '../api/description/specification' },
  153. { text: 'Examples', link: '../examples/cpp/basic' },
  154. ]
  155. }
  156. ]
  157. }
  158. function descriptionApiSidebar(): DefaultTheme.SidebarItem[] {
  159. return [
  160. {
  161. text: 'Description API',
  162. collapsed: false,
  163. items: [
  164. { text: 'Specification', link: 'specification' },
  165. { text: 'Conditions', link: 'conditions' },
  166. { text: 'Global Interfaces', link: 'global-interfaces' },
  167. { text: 'Helper Interfaces', link: 'helper-interfaces' },
  168. { text: 'Project Targets', link: 'project-target' },
  169. { text: 'Configuration Option', link: 'configuration-option' },
  170. { text: 'Plugin and Task', link: 'plugin-and-task' },
  171. { text: 'Custom Rule', link: 'custom-rule' },
  172. { text: 'Custom Toolchain', link: 'custom-toolchain' },
  173. { text: 'Package Dependencies', link: 'package-dependencies' },
  174. { text: 'Builtin Variables', link: 'builtin-variables' },
  175. { text: 'Builtin Rules', link: 'builtin-rules' },
  176. { text: 'Builtin Policies', link: 'builtin-policies' },
  177. { text: 'XPack Interfaces', link: 'xpack-interfaces' },
  178. { text: 'XPack Component Interfaces', link: 'xpack-component-interfaces' },
  179. ]
  180. },
  181. {
  182. text: 'Next Steps',
  183. collapsed: false,
  184. items: [
  185. { text: 'Scripts API', link: '../scripts/target-instance' },
  186. { text: 'Guide', link: '../../guide/introduction' },
  187. { text: 'Examples', link: '../../examples/cpp/basic' },
  188. ]
  189. }
  190. ]
  191. }
  192. function scriptsApiSidebar(): DefaultTheme.SidebarItem[] {
  193. return [
  194. {
  195. text: 'Scripts API',
  196. collapsed: false,
  197. items: [
  198. { text: 'Target Instance', link: 'target-instance' },
  199. { text: 'Option Instance', link: 'option-instance' },
  200. { text: 'Package Instance', link: 'package-instance' },
  201. ]
  202. },
  203. {
  204. text: 'Builtin Modules',
  205. collapsed: true,
  206. items: builtinModulesApiSidebarItems()
  207. },
  208. {
  209. text: 'Extension Modules',
  210. collapsed: false,
  211. items: extensionModulesApiSidebarItems()
  212. },
  213. { text: 'Native Modules', link: 'native-modules' },
  214. {
  215. text: 'Next Steps',
  216. collapsed: false,
  217. items: [
  218. { text: 'Description API', link: '../description/specification' },
  219. { text: 'Guide', link: '../../guide/introduction' },
  220. { text: 'Examples', link: '../../examples/cpp/basic' },
  221. ]
  222. }
  223. ]
  224. }
  225. function examplesSidebar(): DefaultTheme.SidebarItem[] {
  226. return [
  227. {
  228. text: 'C/C++',
  229. collapsed: false,
  230. items: [
  231. { text: 'Basic Programs', link: 'cpp/basic' },
  232. { text: 'C++ Modules', link: 'cpp/cxx-modules' },
  233. { text: 'Wasm Programs', link: 'cpp/wasm' },
  234. { text: 'Qt Programs', link: 'cpp/qt' },
  235. { text: 'WDK Programs', link: 'cpp/wdk' },
  236. { text: 'WinSDK Programs', link: 'cpp/winsdk' },
  237. { text: 'MFC Programs', link: 'cpp/mfc' },
  238. { text: 'Protobuf Programs', link: 'cpp/protobuf' },
  239. { text: 'OpenMP Programs', link: 'cpp/openmp' },
  240. { text: 'Linux Bpf Programs', link: 'cpp/linux-bpf' },
  241. { text: 'Linux Kernel Driver Module', link: 'cpp/linux-driver-module' },
  242. { text: 'ASN.1 Programs', link: 'cpp/asn1' },
  243. { text: 'CppFront Programs', link: 'cpp/cppfront' },
  244. { text: 'Cosmocc Programs', link: 'cpp/cosmocc' },
  245. { text: 'Merge Static Libraries', link: 'cpp/merge-static-libraries' },
  246. ]
  247. },
  248. {
  249. text: 'Bindings Programs',
  250. collapsed: false,
  251. items: [
  252. { text: 'Swig Modules', link: 'bindings/swig' },
  253. { text: 'Lua Modules', link: 'bindings/lua-module' },
  254. { text: 'Python Modules', link: 'bindings/python-module' },
  255. { text: 'NodeJS Modules', link: 'bindings/nodejs-module' },
  256. ]
  257. },
  258. {
  259. text: 'Embed Programs',
  260. collapsed: false,
  261. items: [
  262. { text: 'Keil/MDK Embed Programs', link: 'embed/keil-mdk' },
  263. { text: 'Keil/C51 Embed Programs', link: 'embed/keil-c51' },
  264. { text: 'Verilog Programs', link: 'embed/verilog' },
  265. ]
  266. },
  267. {
  268. text: 'Other Languages',
  269. collapsed: false,
  270. items: [
  271. { text: 'ObjC Programs', link: 'other-languages/objc' },
  272. { text: 'Cuda Programs', link: 'other-languages/cuda' },
  273. { text: 'Lex/Yacc Programs', link: 'other-languages/lex-yacc' },
  274. { text: 'Fortran Programs', link: 'other-languages/fortran' },
  275. { text: 'Golang Programs', link: 'other-languages/golang' },
  276. { text: 'Dlang Programs', link: 'other-languages/dlang' },
  277. { text: 'Rust Programs', link: 'other-languages/rust' },
  278. { text: 'Swift Programs', link: 'other-languages/swift' },
  279. { text: 'Zig Programs', link: 'other-languages/zig' },
  280. { text: 'Vala Programs', link: 'other-languages/vala' },
  281. { text: 'Pascal Programs', link: 'other-languages/pascal' },
  282. { text: 'Nim Programs', link: 'other-languages/nim' },
  283. { text: 'Verilog Programs', link: 'other-languages/verilog' },
  284. ]
  285. },
  286. {
  287. text: 'Next Steps',
  288. collapsed: false,
  289. items: [
  290. { text: 'API Reference', link: '../api/description/specification' },
  291. { text: 'Guide', link: '../guide/introduction' },
  292. ]
  293. }
  294. ]
  295. }