Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add script to post process docs #4838

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/generate_docs.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

brimoor marked this conversation as resolved.
Show resolved Hide resolved
echo "**** Documentation complete ****"
printf "To view the docs, open:\n\ndocs/build/html/index.html\n\n"
39 changes: 39 additions & 0 deletions docs/scripts/post-process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const fs = require("fs");
const path = require("path");

const buildPath = path.resolve(__dirname, "../build");

const htmlFiles = findHTMLFiles(buildPath);

const substitutions = {
__SUB_NEW__:
'<strong style="color: hsl(25, 100%, 51%); font-size: 0.85em; vertical-align: top">NEW</strong>',
};

for (const file of htmlFiles) {
let content = fs.readFileSync(file, "utf8");
if (content.includes("__SUB_")) {
for (const [key, value] of Object.entries(substitutions)) {
content = content.replaceAll(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;
}
4 changes: 2 additions & 2 deletions docs/source/dataset_zoo/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------
Remotely-sourced datasets __SUB_NEW__
-------------------------------------

The Dataset Zoo also supports loading datasets whose download/preparation
methods are provided via GitHub repositories or URLs.
Expand Down
6 changes: 3 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,15 @@ us at support@voxel51.com.
:hidden:

Overview <self>
FiftyOne Teams 🚀<teams/index>
FiftyOne Teams 🚀 <teams/index>
Installation <getting_started/install>
Environments <environments/index>
Tutorials <tutorials/index>
Recipes <recipes/index>
Cheat Sheets <cheat_sheets/index>
User Guide <user_guide/index>
Dataset Zoo <dataset_zoo/index>
Model Zoo <model_zoo/index>
Dataset Zoo __SUB_NEW__ <dataset_zoo/index>
Model Zoo __SUB_NEW__ <model_zoo/index>
FiftyOne Brain <brain>
Integrations <integrations/index>
Plugins <plugins/index>
Expand Down
4 changes: 2 additions & 2 deletions docs/source/model_zoo/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ you can apply to your datasets with a few simple commands.
:meth:`apply_model() <fiftyone.core.collections.SampleCollection.apply_model>`
and :meth:`compute_embeddings() <fiftyone.core.collections.SampleCollection.compute_embeddings>`!

Remotely-sourced models
-----------------------
Remotely-sourced models __SUB_NEW__
-----------------------------------

The Model Zoo also supports downloading and applying models whose definitions
are provided via GitHub repositories or URLs.
Expand Down
Loading