From eceaa13e63ddc0bcec8ae6f7c7106f2c43be1e72 Mon Sep 17 00:00:00 2001 From: imanjra Date: Tue, 24 Sep 2024 17:45:26 -0400 Subject: [PATCH 1/5] add script to post process docs --- docs/generate_docs.bash | 3 +++ docs/scripts/post-process.js | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 docs/scripts/post-process.js diff --git a/docs/generate_docs.bash b/docs/generate_docs.bash index 058c58d14d..5c11b80dc4 100755 --- a/docs/generate_docs.bash +++ b/docs/generate_docs.bash @@ -133,5 +133,8 @@ if [[ -n "${PATH_TO_TEAMS}" ]]; then unlink "$PATH_TO_FIFTYONE_DIR/api" fi +echo "Post-processing docs" +node ./scripts/post-process.js + echo "**** Documentation complete ****" printf "To view the docs, open:\n\ndocs/build/html/index.html\n\n" diff --git a/docs/scripts/post-process.js b/docs/scripts/post-process.js new file mode 100644 index 0000000000..c8536335c6 --- /dev/null +++ b/docs/scripts/post-process.js @@ -0,0 +1,39 @@ +const fs = require("fs"); +const path = require("path"); + +const buildPath = path.resolve(__dirname, "../build"); + +const htmlFiles = findHTMLFiles(buildPath); + +const substitutions = { + __fo_doc_sub_new_badge__: + 'NEW', +}; + +for (const file of htmlFiles) { + let content = fs.readFileSync(file, "utf8"); + if (content.includes("__fo_doc_sub")) { + for (const [key, value] of Object.entries(substitutions)) { + content = content.replace(key, value); + } + fs.writeFileSync(file, content); + } +} + +function findHTMLFiles(dir) { + const files = fs.readdirSync(dir); + const htmlFiles = []; + + for (const file of files) { + const filePath = path.join(dir, file); + const stat = fs.lstatSync(filePath); + + if (stat.isDirectory()) { + htmlFiles.push(...findHTMLFiles(filePath)); + } else if (file.endsWith(".html")) { + htmlFiles.push(filePath); + } + } + + return htmlFiles; +} From a5795fef7590ea8348a39cf7d30f264db6e41a5d Mon Sep 17 00:00:00 2001 From: brimoor Date: Tue, 24 Sep 2024 18:23:08 -0400 Subject: [PATCH 2/5] updates --- docs/scripts/post-process.js | 7 +++---- docs/source/dataset_zoo/index.rst | 4 ++-- docs/source/index.rst | 6 +++--- docs/source/model_zoo/index.rst | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/scripts/post-process.js b/docs/scripts/post-process.js index c8536335c6..184509010d 100644 --- a/docs/scripts/post-process.js +++ b/docs/scripts/post-process.js @@ -6,15 +6,14 @@ const buildPath = path.resolve(__dirname, "../build"); const htmlFiles = findHTMLFiles(buildPath); const substitutions = { - __fo_doc_sub_new_badge__: - 'NEW', + __SUB_NEW__: 'NEW', }; for (const file of htmlFiles) { let content = fs.readFileSync(file, "utf8"); - if (content.includes("__fo_doc_sub")) { + if (content.includes("__SUB_")) { for (const [key, value] of Object.entries(substitutions)) { - content = content.replace(key, value); + content = content.replaceAll(key, value); } fs.writeFileSync(file, content); } diff --git a/docs/source/dataset_zoo/index.rst b/docs/source/dataset_zoo/index.rst index 3e97ae3eed..8d1c8ffa95 100644 --- a/docs/source/dataset_zoo/index.rst +++ b/docs/source/dataset_zoo/index.rst @@ -22,8 +22,8 @@ load into FiftyOne with a single command. :button_text: Explore the datasets in the zoo :button_link: datasets.html -Remotely-sourced datasets -------------------------- +__SUB_NEW__ Remotely-sourced datasets +------------------------------------- The Dataset Zoo also supports loading datasets whose download/preparation methods are provided via GitHub repositories or URLs. diff --git a/docs/source/index.rst b/docs/source/index.rst index d60c18bba9..aefd20e103 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -472,15 +472,15 @@ us at support@voxel51.com. :hidden: Overview - FiftyOne Teams 🚀 + FiftyOne Teams 🚀 Installation Environments Tutorials Recipes Cheat Sheets User Guide - Dataset Zoo - Model Zoo + Dataset Zoo __SUB_NEW__ + Model Zoo __SUB_NEW__ FiftyOne Brain Integrations Plugins diff --git a/docs/source/model_zoo/index.rst b/docs/source/model_zoo/index.rst index 6510a75130..828f7c9ce0 100644 --- a/docs/source/model_zoo/index.rst +++ b/docs/source/model_zoo/index.rst @@ -43,8 +43,8 @@ you can apply to your datasets with a few simple commands. :meth:`apply_model() ` and :meth:`compute_embeddings() `! -Remotely-sourced models ------------------------ +__SUB_NEW__ Remotely-sourced models +----------------------------------- The Model Zoo also supports downloading and applying models whose definitions are provided via GitHub repositories or URLs. From d4bc6bee548cdbc4006acb6352ae5188439ff0ab Mon Sep 17 00:00:00 2001 From: brimoor Date: Tue, 24 Sep 2024 19:28:26 -0400 Subject: [PATCH 3/5] on left, smaller --- docs/scripts/post-process.js | 3 ++- docs/source/dataset_zoo/index.rst | 2 +- docs/source/model_zoo/index.rst | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/scripts/post-process.js b/docs/scripts/post-process.js index 184509010d..9dbe932f17 100644 --- a/docs/scripts/post-process.js +++ b/docs/scripts/post-process.js @@ -6,7 +6,8 @@ const buildPath = path.resolve(__dirname, "../build"); const htmlFiles = findHTMLFiles(buildPath); const substitutions = { - __SUB_NEW__: 'NEW', + __SUB_NEW__: + 'NEW', }; for (const file of htmlFiles) { diff --git a/docs/source/dataset_zoo/index.rst b/docs/source/dataset_zoo/index.rst index 8d1c8ffa95..fa8fb2ac52 100644 --- a/docs/source/dataset_zoo/index.rst +++ b/docs/source/dataset_zoo/index.rst @@ -22,7 +22,7 @@ load into FiftyOne with a single command. :button_text: Explore the datasets in the zoo :button_link: datasets.html -__SUB_NEW__ Remotely-sourced datasets +Remotely-sourced datasets __SUB_NEW__ ------------------------------------- The Dataset Zoo also supports loading datasets whose download/preparation diff --git a/docs/source/model_zoo/index.rst b/docs/source/model_zoo/index.rst index 828f7c9ce0..893a2813c8 100644 --- a/docs/source/model_zoo/index.rst +++ b/docs/source/model_zoo/index.rst @@ -43,7 +43,7 @@ you can apply to your datasets with a few simple commands. :meth:`apply_model() ` and :meth:`compute_embeddings() `! -__SUB_NEW__ Remotely-sourced models +Remotely-sourced models __SUB_NEW__ ----------------------------------- The Model Zoo also supports downloading and applying models whose definitions From 125ff937143fc87043a27f160882332fe9a8f4df Mon Sep 17 00:00:00 2001 From: imanjra Date: Wed, 25 Sep 2024 01:09:41 -0400 Subject: [PATCH 4/5] update font size for new tag --- docs/scripts/post-process.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/scripts/post-process.js b/docs/scripts/post-process.js index 9dbe932f17..98710fffad 100644 --- a/docs/scripts/post-process.js +++ b/docs/scripts/post-process.js @@ -7,7 +7,7 @@ const htmlFiles = findHTMLFiles(buildPath); const substitutions = { __SUB_NEW__: - 'NEW', + 'NEW', }; for (const file of htmlFiles) { From b3ec6d3f86b3a31ce4ae24cb6bdf79a657582775 Mon Sep 17 00:00:00 2001 From: brimoor Date: Wed, 25 Sep 2024 01:33:00 -0400 Subject: [PATCH 5/5] em and alignment --- docs/scripts/post-process.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/scripts/post-process.js b/docs/scripts/post-process.js index 98710fffad..3e239d5446 100644 --- a/docs/scripts/post-process.js +++ b/docs/scripts/post-process.js @@ -7,7 +7,7 @@ const htmlFiles = findHTMLFiles(buildPath); const substitutions = { __SUB_NEW__: - 'NEW', + 'NEW', }; for (const file of htmlFiles) {