diff --git a/ci-build.sh b/ci-build.sh index ae0c7e4..9d7d6f4 100755 --- a/ci-build.sh +++ b/ci-build.sh @@ -6,17 +6,15 @@ set -e cd "$(dirname "$0")" 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 -cd "$REVANCED_DOCS_FOLDER" -cp README.md index.md -cd - +#git clone --recurse-submodules "$docs_git_repo" "_docs_src" # Copy assets from docs repo to here. -mkdir -p static/docs -cp -r "$REVANCED_DOCS_FOLDER"/assets static/docs/assets || true +# mkdir -p static/docs +# cp -r "$REVANCED_DOCS_FOLDER"/assets static/docs/assets || true npm run build diff --git a/src/lib/documentation.server.ts b/src/lib/documentation.server.ts index dd05ab5..76525dd 100644 --- a/src/lib/documentation.server.ts +++ b/src/lib/documentation.server.ts @@ -58,7 +58,7 @@ if (docs_folder === undefined) { docs_folder = "testing-docs"; } -const ignored_items = ["assets", "README.md"]; +const ignored_items = ["assets"]; /// Utility functions @@ -84,9 +84,9 @@ function get_slug_of_node(node: DocsTreeNode): string { // Get a document. Returns null if it does not exist. export function get(slug: string): Document|null { let target = path.join(docs_folder, slug); - // Handle index file for folder. + // Handle index (readme) file for folder. if (exists(target) && is_directory(target)) { - target += "/index"; + target += "/README"; } 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)) .split("/"); - // Remove `index` suffix if present. - const last_index = parts.length - 1; - if (parts[last_index] == "index") { + // Remove `README` suffix if present. + const last_part_index = parts.length - 1; + if (parts[last_part_index] == "README") { parts.pop(); } @@ -142,7 +142,7 @@ function process_file(fname: string): DocumentInfo { } // Returns a document tree. -function process_folder(dir: string): DocsTree { +function process_folder(dir: string): DocsTree|null { let tree: DocsTree = { index: null, nodes: [] @@ -168,13 +168,17 @@ function process_folder(dir: string): DocsTree { } for (const ext of supported_filetypes) { - if (item == `index.${ext}`) { + if (item == `README.${ext}`) { is_index_file = true; } } } 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) { tree.index = node; @@ -184,7 +188,7 @@ function process_folder(dir: string): DocsTree { } if (tree.index === null) { - throw Error(`${dir} has no index file.`); + return null; } // `numeric: true` because we want to be able to specify @@ -198,5 +202,9 @@ function process_folder(dir: string): DocsTree { // Returns the document tree. 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; } diff --git a/testing-docs/index.md b/testing-docs/README.md similarity index 100% rename from testing-docs/index.md rename to testing-docs/README.md diff --git a/testing-docs/deeply/index.md b/testing-docs/deeply/README.md similarity index 100% rename from testing-docs/deeply/index.md rename to testing-docs/deeply/README.md diff --git a/testing-docs/deeply/nested/index.md b/testing-docs/deeply/nested/README.md similarity index 100% rename from testing-docs/deeply/nested/index.md rename to testing-docs/deeply/nested/README.md diff --git a/testing-docs/deeply/nested/content/index.md b/testing-docs/deeply/nested/content/README.md similarity index 100% rename from testing-docs/deeply/nested/content/index.md rename to testing-docs/deeply/nested/content/README.md