mirror of
https://gitea.com/gitea/docs.git
synced 2026-11-06 01:50:30 +00:00
docs: drop the generated gt reference
The per-command reference made the pages long and repeated what gt <command> --help shows. Keep the guides and remove the generator, its workflow and the sidebar handling it needed. Signed-off-by: bircni <[email protected]>
This commit is contained in:
264 files changed
+11
-15121
No files matched your search
@@ -96,23 +96,14 @@ interface Tree {
|
||||
label(dir: string): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sidebar of a directory tree, ordered by `sidebar_position`. A directory
|
||||
* without `_category_.json` but with an `index` page, as the generated cli
|
||||
* reference has one per command, takes its label and position from that page,
|
||||
* which comes first in it.
|
||||
*/
|
||||
/** Sidebar of a directory tree, ordered by `sidebar_position`. */
|
||||
function treeOf(pages: SidebarPage[]): Tree {
|
||||
const categories = new Map<string, SidebarPage>();
|
||||
const indexes = new Map<string, SidebarPage>();
|
||||
for (const page of pages) {
|
||||
if (page.meta.category) {
|
||||
categories.set([page.meta.dir, page.meta.name].filter(Boolean).join('/'), page);
|
||||
} else if (page.meta.name === 'index' && page.meta.dir) {
|
||||
indexes.set(page.meta.dir, page);
|
||||
}
|
||||
if (!page.meta.category) continue;
|
||||
const dir = [page.meta.dir, page.meta.name].filter(Boolean).join('/');
|
||||
categories.set(dir, page);
|
||||
}
|
||||
const heading = (dir: string) => categories.get(dir) ?? indexes.get(dir);
|
||||
|
||||
const childDirs = (dir: string) => {
|
||||
const prefix = dir ? `${dir}/` : '';
|
||||
@@ -130,7 +121,7 @@ function treeOf(pages: SidebarPage[]): Tree {
|
||||
const entries: { sort: [number, number, string]; entry: SidebarEntry }[] = [];
|
||||
|
||||
for (const child of childDirs(dir)) {
|
||||
const category = heading(child);
|
||||
const category = categories.get(child);
|
||||
const label = category?.title ?? labelFromDirname(child.split('/').at(-1)!);
|
||||
entries.push({
|
||||
sort: [category?.meta.order ?? last, 0, label],
|
||||
@@ -140,8 +131,7 @@ function treeOf(pages: SidebarPage[]): Tree {
|
||||
|
||||
for (const page of pages) {
|
||||
if (page.meta.dir !== dir || page.meta.category || page.hidden) continue;
|
||||
const order = indexes.get(dir) === page ? -last : (page.meta.order ?? last);
|
||||
entries.push({ sort: [order, 1, page.title], entry: link(page) });
|
||||
entries.push({ sort: [page.meta.order ?? last, 1, page.title], entry: link(page) });
|
||||
}
|
||||
|
||||
return entries
|
||||
@@ -152,7 +142,8 @@ function treeOf(pages: SidebarPage[]): Tree {
|
||||
.map((item) => item.entry);
|
||||
};
|
||||
|
||||
const label = (dir: string) => heading(dir)?.title ?? labelFromDirname(dir.split('/').at(-1)!);
|
||||
const label = (dir: string) =>
|
||||
categories.get(dir)?.title ?? labelFromDirname(dir.split('/').at(-1)!);
|
||||
|
||||
return { build, label };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user