mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-30 06:34:35 +02:00
feat(docs): update ci build script and use README instead of index
This commit is contained in:
parent
dcf0413af7
commit
27dd5a5184
14
ci-build.sh
14
ci-build.sh
@ -6,17 +6,15 @@ set -e
|
|||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
docs_git_repo="${REVANCED_DOCS_REPO:-https://github.com/revanced/revanced-documentation.git}"
|
docs_git_repo="${REVANCED_DOCS_REPO:-https://github.com/revanced/revanced-documentation.git}"
|
||||||
export REVANCED_DOCS_FOLDER="_docs_src"
|
|
||||||
|
|
||||||
git clone "$docs_git_repo" "$REVANCED_DOCS_FOLDER"
|
git clone "$docs_git_repo" "_docs_src"
|
||||||
|
# TODO: transform a tag links so this works properly...
|
||||||
|
#export REVANCED_DOCS_FOLDER="_docs_src/docs"
|
||||||
|
|
||||||
# Do this because the docs repo doesn't have any actual docs right now
|
#git clone --recurse-submodules "$docs_git_repo" "_docs_src"
|
||||||
cd "$REVANCED_DOCS_FOLDER"
|
|
||||||
cp README.md index.md
|
|
||||||
cd -
|
|
||||||
|
|
||||||
# Copy assets from docs repo to here.
|
# Copy assets from docs repo to here.
|
||||||
mkdir -p static/docs
|
# mkdir -p static/docs
|
||||||
cp -r "$REVANCED_DOCS_FOLDER"/assets static/docs/assets || true
|
# cp -r "$REVANCED_DOCS_FOLDER"/assets static/docs/assets || true
|
||||||
|
|
||||||
npm run build
|
npm run build
|
||||||
|
@ -58,7 +58,7 @@ if (docs_folder === undefined) {
|
|||||||
docs_folder = "testing-docs";
|
docs_folder = "testing-docs";
|
||||||
}
|
}
|
||||||
|
|
||||||
const ignored_items = ["assets", "README.md"];
|
const ignored_items = ["assets"];
|
||||||
|
|
||||||
/// Utility functions
|
/// Utility functions
|
||||||
|
|
||||||
@ -84,9 +84,9 @@ function get_slug_of_node(node: DocsTreeNode): string {
|
|||||||
// Get a document. Returns null if it does not exist.
|
// Get a document. Returns null if it does not exist.
|
||||||
export function get(slug: string): Document|null {
|
export function get(slug: string): Document|null {
|
||||||
let target = path.join(docs_folder, slug);
|
let target = path.join(docs_folder, slug);
|
||||||
// Handle index file for folder.
|
// Handle index (readme) file for folder.
|
||||||
if (exists(target) && is_directory(target)) {
|
if (exists(target) && is_directory(target)) {
|
||||||
target += "/index";
|
target += "/README";
|
||||||
}
|
}
|
||||||
|
|
||||||
const dir = path.dirname(target);
|
const dir = path.dirname(target);
|
||||||
@ -129,9 +129,9 @@ function process_file(fname: string): DocumentInfo {
|
|||||||
.substring(`${docs_folder}/`.length, fname.length - (get_ext(fname).length + 1))
|
.substring(`${docs_folder}/`.length, fname.length - (get_ext(fname).length + 1))
|
||||||
.split("/");
|
.split("/");
|
||||||
|
|
||||||
// Remove `index` suffix if present.
|
// Remove `README` suffix if present.
|
||||||
const last_index = parts.length - 1;
|
const last_part_index = parts.length - 1;
|
||||||
if (parts[last_index] == "index") {
|
if (parts[last_part_index] == "README") {
|
||||||
parts.pop();
|
parts.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ function process_file(fname: string): DocumentInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a document tree.
|
// Returns a document tree.
|
||||||
function process_folder(dir: string): DocsTree {
|
function process_folder(dir: string): DocsTree|null {
|
||||||
let tree: DocsTree = {
|
let tree: DocsTree = {
|
||||||
index: null,
|
index: null,
|
||||||
nodes: []
|
nodes: []
|
||||||
@ -168,13 +168,17 @@ function process_folder(dir: string): DocsTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const ext of supported_filetypes) {
|
for (const ext of supported_filetypes) {
|
||||||
if (item == `index.${ext}`) {
|
if (item == `README.${ext}`) {
|
||||||
is_index_file = true;
|
is_index_file = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const node = is_dir ? process_folder(itemPath) : process_file(itemPath);
|
const node = is_dir ? process_folder(itemPath) : process_file(itemPath);
|
||||||
|
if (node === null) {
|
||||||
|
console.error(`The ${itemPath} directory does not have a README/index file! ignoring...`)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_index_file) {
|
if (is_index_file) {
|
||||||
tree.index = node;
|
tree.index = node;
|
||||||
@ -184,7 +188,7 @@ function process_folder(dir: string): DocsTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tree.index === null) {
|
if (tree.index === null) {
|
||||||
throw Error(`${dir} has no index file.`);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// `numeric: true` because we want to be able to specify
|
// `numeric: true` because we want to be able to specify
|
||||||
@ -198,5 +202,9 @@ function process_folder(dir: string): DocsTree {
|
|||||||
|
|
||||||
// Returns the document tree.
|
// Returns the document tree.
|
||||||
export function index_content(): DocsTree {
|
export function index_content(): DocsTree {
|
||||||
return process_folder(docs_folder);
|
const tree = process_folder(docs_folder);
|
||||||
|
if (tree === null) {
|
||||||
|
throw new Error("Root must have index (README) file.")
|
||||||
|
}
|
||||||
|
return tree;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user