From cf879629aacdf050dfd77aa654f0538fc5ed42fb Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:53:41 +0200 Subject: [PATCH] Versioned docs (#289) * Versioned documentation Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> * Versioned docs Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> Co-authored-by: James Humphries * Reverted accidental changes Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> * Reverted accidental changes Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> * Reverted accidental changes Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> * Docusaurus config Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> * 1.7 split Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> * Symlink Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> * Versioned docs finalization Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --------- Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> Co-authored-by: James Humphries --- .gitmodules | 14 ++++- docs/index.mdx | 43 -------------- docusaurus.config.ts | 56 ++++++++++--------- opentofu-repo | 1 - opentofu-repo/main | 1 + opentofu-repo/v1.6 | 1 + opentofu-repo/v1.7 | 1 + sidebars.js | 26 --------- sidebars.json | 8 +++ src/theme/DocItem/Layout.tsx | 1 - versioned_docs/version-main | 1 + versioned_docs/version-v1.6 | 1 + versioned_docs/version-v1.7 | 1 + versioned_sidebars/version-main-sidebars.json | 8 +++ versioned_sidebars/version-v1.6-sidebars.json | 8 +++ versioned_sidebars/version-v1.7-sidebars.json | 8 +++ versions.json | 5 ++ 17 files changed, 85 insertions(+), 99 deletions(-) delete mode 100644 docs/index.mdx delete mode 160000 opentofu-repo create mode 160000 opentofu-repo/main create mode 160000 opentofu-repo/v1.6 create mode 160000 opentofu-repo/v1.7 delete mode 100644 sidebars.js create mode 100644 sidebars.json create mode 120000 versioned_docs/version-main create mode 120000 versioned_docs/version-v1.6 create mode 120000 versioned_docs/version-v1.7 create mode 100644 versioned_sidebars/version-main-sidebars.json create mode 100644 versioned_sidebars/version-v1.6-sidebars.json create mode 100644 versioned_sidebars/version-v1.7-sidebars.json create mode 100644 versions.json diff --git a/.gitmodules b/.gitmodules index faeec7d..b016450 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,12 @@ -[submodule "opentofu-repo"] - path = opentofu-repo +[submodule "opentofu-repo/main"] + path = opentofu-repo/main url = https://github.com/opentofu/opentofu - branch = v1.6 \ No newline at end of file + branch = main +[submodule "opentofu-repo/v1.6"] + path = opentofu-repo/v1.6 + url = https://github.com/opentofu/opentofu + branch = v1.6 +[submodule "opentofu-repo/v1.7"] + path = opentofu-repo/v1.7 + url = https://github.com/opentofu/opentofu + branch = v1.7 diff --git a/docs/index.mdx b/docs/index.mdx deleted file mode 100644 index a623a6a..0000000 --- a/docs/index.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: Documentation -hide_table_of_contents: true ---- - -import DocCardList from "@theme/DocCardList"; - -### Documentation - -The documentation is divided into four main sections, covering CLI-based workflows, internal processes, an introduction to the tool's capabilities, and guidance on using the OpenTofu configuration language for managing infrastructure. - - diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 5decda7..56d304c 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -101,23 +101,39 @@ const config: Config = { customCss: [require.resolve("./src/css/custom.css")], }, docs: { - sidebarPath: require.resolve("./sidebars.js"), - path: "opentofu-repo/website/docs", + includeCurrentVersion: false, + lastVersion: 'v1.6', + docVersionRootComponent: "@theme/DocVersionRoot", + versions: { + "v1.6": { + label: "1.6.x", + path: "" + }, + "v1.7": { + label: "1.7.x", + path: "next", + banner: "unreleased", + noIndex: true + }/*, + "main": { + label: "1.8.x", + path: "next", + banner: "unreleased", + noIndex: true + }*/ + }, routeBasePath: "/docs", - editUrl: ({ docPath }) => { + editUrl: ({ version, docPath }) => { // Remove the edit link from the documentation index page // TODO: remove after moving the page to the main OpenTofu repo if (docPath === "index.mdx") { - return `https://github.com/opentofu/opentofu.org/edit/main/docs/${docPath}`; + return `https://github.com/opentofu/opentofu.org/edit/${version}/docs/${docPath}`; } - return `https://github.com/opentofu/opentofu/edit/main/website/docs/${docPath}`; + return `https://github.com/opentofu/opentofu/edit/${version}/website/docs/${docPath}`; }, }, blog: false, - gtag: { - trackingID: "G-NKLFR0FNQZ", - }, } satisfies Preset.Options, ], ], @@ -183,6 +199,7 @@ const config: Config = { respectPrefersColorScheme: false, }, docs: { + versionPersistence: "none", sidebar: { autoCollapseCategories: true, }, @@ -190,7 +207,7 @@ const config: Config = { announcementBar: { id: "opentofu-ga", content: - 'OpenTofu 1.7.0-beta1 is now availabe — learn more.', + 'OpenTofu 1.7.0-rc1 is now availabe — learn more.', backgroundColor: "#ffda18", textColor: "#1b1d20", isCloseable: false, @@ -259,27 +276,16 @@ const config: Config = { position: "left", items: [ { - type: "doc", - label: "Introduction", - docId: "intro/index", + label: "v1.6.x (current)", + href: "/docs" }, { - type: "doc", - label: "CLI", - docId: "cli/index", - }, - { - type: "doc", - label: "Language", - docId: "language/index", - }, - { - type: "doc", - label: "Internals", - docId: "internals/index", + label: "v1.7.x (next)", + href: "/docs/next" }, ], }, + // TODO: This link is important but there's no design for it yet // { // type: "dropdown", diff --git a/opentofu-repo b/opentofu-repo deleted file mode 160000 index 4007b32..0000000 --- a/opentofu-repo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4007b3255321b0c534f448cc7f7b75cca5b8fda6 diff --git a/opentofu-repo/main b/opentofu-repo/main new file mode 160000 index 0000000..0e7ba71 --- /dev/null +++ b/opentofu-repo/main @@ -0,0 +1 @@ +Subproject commit 0e7ba7120a2f455384a819cf6e7eff4f71676266 diff --git a/opentofu-repo/v1.6 b/opentofu-repo/v1.6 new file mode 160000 index 0000000..32a3167 --- /dev/null +++ b/opentofu-repo/v1.6 @@ -0,0 +1 @@ +Subproject commit 32a3167aee3d8582cccb8838c751ee6fbd8ddc3a diff --git a/opentofu-repo/v1.7 b/opentofu-repo/v1.7 new file mode 160000 index 0000000..c7ae863 --- /dev/null +++ b/opentofu-repo/v1.7 @@ -0,0 +1 @@ +Subproject commit c7ae8635f956274f509872eecb4e483f30874020 diff --git a/sidebars.js b/sidebars.js deleted file mode 100644 index 85712c2..0000000 --- a/sidebars.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - cli: [ - { - type: "autogenerated", - dirName: "cli", - }, - ], - internals: [ - { - type: "autogenerated", - dirName: "internals", - }, - ], - intro: [ - { - type: "autogenerated", - dirName: "intro", - }, - ], - language: [ - { - type: "autogenerated", - dirName: "language", - }, - ], -}; diff --git a/sidebars.json b/sidebars.json new file mode 100644 index 0000000..2785463 --- /dev/null +++ b/sidebars.json @@ -0,0 +1,8 @@ +{ + "docs": [ + { + "type": "autogenerated", + "dirName": "." + } + ] +} \ No newline at end of file diff --git a/src/theme/DocItem/Layout.tsx b/src/theme/DocItem/Layout.tsx index 6321305..bc78314 100644 --- a/src/theme/DocItem/Layout.tsx +++ b/src/theme/DocItem/Layout.tsx @@ -29,7 +29,6 @@ export default function DocItemLayout({ children }: Props) {
- {canRenderTOC && } {children} diff --git a/versioned_docs/version-main b/versioned_docs/version-main new file mode 120000 index 0000000..a187e07 --- /dev/null +++ b/versioned_docs/version-main @@ -0,0 +1 @@ +../opentofu-repo/main/website/docs \ No newline at end of file diff --git a/versioned_docs/version-v1.6 b/versioned_docs/version-v1.6 new file mode 120000 index 0000000..f9b0759 --- /dev/null +++ b/versioned_docs/version-v1.6 @@ -0,0 +1 @@ +../opentofu-repo/v1.6/website/docs \ No newline at end of file diff --git a/versioned_docs/version-v1.7 b/versioned_docs/version-v1.7 new file mode 120000 index 0000000..9812fa5 --- /dev/null +++ b/versioned_docs/version-v1.7 @@ -0,0 +1 @@ +../opentofu-repo/v1.7/website/docs \ No newline at end of file diff --git a/versioned_sidebars/version-main-sidebars.json b/versioned_sidebars/version-main-sidebars.json new file mode 100644 index 0000000..2785463 --- /dev/null +++ b/versioned_sidebars/version-main-sidebars.json @@ -0,0 +1,8 @@ +{ + "docs": [ + { + "type": "autogenerated", + "dirName": "." + } + ] +} \ No newline at end of file diff --git a/versioned_sidebars/version-v1.6-sidebars.json b/versioned_sidebars/version-v1.6-sidebars.json new file mode 100644 index 0000000..2785463 --- /dev/null +++ b/versioned_sidebars/version-v1.6-sidebars.json @@ -0,0 +1,8 @@ +{ + "docs": [ + { + "type": "autogenerated", + "dirName": "." + } + ] +} \ No newline at end of file diff --git a/versioned_sidebars/version-v1.7-sidebars.json b/versioned_sidebars/version-v1.7-sidebars.json new file mode 100644 index 0000000..2785463 --- /dev/null +++ b/versioned_sidebars/version-v1.7-sidebars.json @@ -0,0 +1,8 @@ +{ + "docs": [ + { + "type": "autogenerated", + "dirName": "." + } + ] +} \ No newline at end of file diff --git a/versions.json b/versions.json new file mode 100644 index 0000000..0650326 --- /dev/null +++ b/versions.json @@ -0,0 +1,5 @@ +[ + "v1.7", + "v1.6", + "main" +] \ No newline at end of file