forked from DisnakeDev/disnake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(docs): split monolithic api reference into multiple files (D…
…isnakeDev#722) This PR splits up the monolithic API reference documentation into multiple files. Pages now load much faster, particularly on low-end devices, and sphinx can make better use of parallel builds, speeding those up as well. Old links to the `*/api.html` pages will be redirected accordingly with javascript. Co-authored-by: shiftinv <me@shiftinv.cc> Co-authored-by: Chromosomologist <55550164+Chromosomologist@users.noreply.github.com> Co-authored-by: Victor <67214928+Victorsitou@users.noreply.github.com> Co-authored-by: onerandomusername <me@arielle.codes>
- Loading branch information
1 parent
96df68b
commit 04266b4
Showing
79 changed files
with
9,152 additions
and
7,814 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Split the monolithic API Reference pages into multiple sub-references. | ||
- Main ``disnake`` API reference can now be found at :doc:`API Reference <api/index>`. | ||
- ``disnake.ext.commands`` API reference is now under :doc:`Commands API Reference <ext/commands/api/index>`. | ||
- Legacy ``api.html`` and ``ext/commands/api.html`` pages are deprecated. | ||
- - Links with pre-existing references (eg ``/api.html#disnake.AppInfo``) will be redirected to their appropriate page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
"use strict"; | ||
|
||
const redirects_map = {{ redirect_data }}; | ||
|
||
(() => { | ||
let url = new URL(document.location.href); | ||
|
||
if (!url.pathname.endsWith("/api.html")) return; | ||
|
||
// URL_ROOT is relative to `url`, and points to e.g. `<host>/en/latest/` | ||
const root = new URL(DOCUMENTATION_OPTIONS.URL_ROOT, url); | ||
if (!root.pathname.endsWith("/")) root.pathname += "/"; | ||
|
||
const targetPath = redirects_map[url.hash.slice(1)]; | ||
|
||
let newUrl = null; | ||
if (targetPath) { | ||
// Get current path relative to documentation root | ||
// `/en/latest/xyz/api.html` => `xyz/api/` | ||
let expectedPrefix = url.pathname.slice(root.pathname.length).replace(/\.html$/, "/"); | ||
|
||
// The target path (`xyz/api/events.html`) should start with `xyz/api/` | ||
if (targetPath.startsWith(expectedPrefix)) { | ||
newUrl = new URL(targetPath, root); | ||
newUrl.hash = url.hash; | ||
} | ||
} | ||
|
||
// If it's still unset, the #hash is unknown or the target doesn't match the current section; | ||
// in that case, just redirect to the relevant index page. | ||
if (newUrl === null) { | ||
newUrl = new URL(url); | ||
newUrl.pathname = newUrl.pathname.replace(/\/api.html$/, "/api/index.html"); | ||
newUrl.hash = ""; | ||
} | ||
|
||
console.log(`Redirecting to ${newUrl.href}`); | ||
window.location.replace(newUrl); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.