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

chore(docs): add docs footer customization #4169

Merged
merged 1 commit into from
Nov 11, 2022
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build:clients:generic": "lerna run --scope '@aws-sdk/aws-echo-service' --include-dependencies build",
"build:clients:since:release": "yarn build:packages && lerna run build $(lerna changed | grep -e '@aws-sdk/[client|lib]-*' | sed 's/^/ --scope /' | tr '\n' ' ')",
"build:crypto-dependencies": "lerna run --scope '@aws-sdk/{types,util-utf8-browser,util-locate-window,hash-node}' --include-dependencies build",
"build:docs": "typedoc",
"build:docs": "typedoc && node scripts/docs-custom-js",
"build:e2e": "yarn build:crypto-dependencies && lerna run --scope '@aws-sdk/{client-cloudformation,karma-credential-loader,client-s3-control,client-sts}' --include-dependencies build",
"build:packages": "lerna run build --ignore '@aws-sdk/client-*' --ignore '@aws-sdk/aws-*' --ignore '@aws-sdk/lib-*' --include-dependencies",
"build:protocols": "yarn build:crypto-dependencies && lerna run --scope '@aws-sdk/aws-protocoltests-*' --include-dependencies build",
Expand Down
27 changes: 27 additions & 0 deletions scripts/docs-custom-js/aws-footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
!(function () {
var guideName = document.createElement("meta");
(guideName.name = "guide-name"), (guideName.content = "API Reference");

var serviceName = document.createElement("meta");
(serviceName.name = "service-name"), (serviceName.content = "AWS SDK for JavaScript v3");

document.head.appendChild(guideName);
document.head.appendChild(serviceName);

var zone = document.createElement("div");
zone.className += "container";
zone.id = "awsdocs-legal-zone-copyright";
zone.style.padding = "2rem";

var footer = document.getElementsByTagName("footer");
if (footer && footer.length >= 1) {
footer[footer.length - 1].appendChild(zone);
} else {
document.body.appendChild(zone);
}

var boot = document.createElement("script");
boot.src = "/assets/js/awsdocs-boot.js";
boot.type = "text/javascript";
document.head.appendChild(boot);
})();
1 change: 1 addition & 0 deletions scripts/docs-custom-js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require("./prepend-script");
20 changes: 20 additions & 0 deletions scripts/docs-custom-js/prepend-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require("fs");
const path = require("path");

const root = path.join(__dirname, "..", "..");
const awsFooter = path.join(root, "scripts", "docs-custom-js", "aws-footer.js");
const docsMainScript = path.join(root, "docs", "assets", "js", "main.js");

if (!fs.existsSync(docsMainScript)) {
throw new Error(`docs main script not present at ${docsMainScript}`);
}

const fileContents = fs.readFileSync(docsMainScript, "utf-8");
const awsFooterContents = fs.readFileSync(awsFooter, "utf-8");

if (fileContents.indexOf(awsFooterContents) === -1) {
fs.writeFileSync(docsMainScript, awsFooterContents + "\n" + fileContents, "utf-8");
console.log("Modified docs script with AWS footer script.");
} else {
console.log("Docs main script already modified, exiting.");
}