Skip to content

Commit

Permalink
Use typedoc-plugin-script-inject to add client side redirects
Browse files Browse the repository at this point in the history
The previous docs had all the exports on a single page and we make use
of #anchor links to link to the export.
  • Loading branch information
julienp committed Mar 14, 2024
1 parent adcfc98 commit 2ae4f61
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
68 changes: 68 additions & 0 deletions content/docs/reference/pkg/nodejs/pulumi/pulumi/redirects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
var pathname = location.pathname.replace(/\/$/, "")
if (pathname == "/docs/reference/pkg/nodejs/pulumi/pulumi") {

This comment has been minimized.

Copy link
@julienp

julienp Mar 14, 2024

Author Contributor

Unfortunately the file gets included on all the pages, so we check here that we are on the pu/pu page before trying to redirect.

var redirects = {
"#ComponentResource": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/ComponentResource.html",
"#getStack": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/getStack.html",
"#isSecret": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/isSecret.html",
"#ResourceTransformArgs": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/ResourceTransformArgs.html",
"#ResourceTransformationResult": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/ResourceTransformationResult.html",
"#version": "/docs/reference/pkg/nodejs/pulumi/pulumi/variables/version.html",
"#ResourceError": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/ResourceError.html",
"#concat": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/concat.html",
"#output": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/output.html",
"#allAliases": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/allAliases.html",
"#NumberConfigOptions": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/NumberConfigOptions.html",
"#jsonParse": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/jsonParse.html",
"#interpolate": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/interpolate.html",
"#unsecret": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/unsecret.html",
"#ComponentResourceOptions": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/ComponentResourceOptions.html",
"#StackReference": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/StackReference.html",
"#OutputInstance": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/OutputInstance.html",
"#Input": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/Input.html",
"#isUnknown": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/isUnknown.html",
"#StackReferenceArgs": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/StackReferenceArgs.html",
"#secret": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/secret.html",
"#ResourceTransformResult": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/ResourceTransformResult.html",
"#mergeOptions": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/mergeOptions.html",
"#InvokeOptions": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/InvokeOptions.html",
"#UnwrappedArray": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/UnwrappedArray.html",
"#rootStackResource": "/docs/reference/pkg/nodejs/pulumi/pulumi/variables/rootStackResource.html",
"#DependencyProviderResource": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/DependencyProviderResource.html",
"#Alias": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/Alias.html",
"#URN": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/URN.html",
"#Config": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/Config.html",
"#CustomResource": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/CustomResource.html",
"#Lifted": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/Lifted.html",
"#Output": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/Output.html",
"#ResourceOptions": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/ResourceOptions.html",
"#StringConfigOptions": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/StringConfigOptions.html",
"#getOrganization": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/getOrganization.html",
"#DependencyResource": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/DependencyResource.html",
"#createUrn": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/createUrn.html",
"#UnwrappedObject": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/UnwrappedObject.html",
"#containsUnknowns": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/containsUnknowns.html",
"#LiftedObject": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/LiftedObject.html",
"#ProviderResource": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/ProviderResource.html",
"#CustomResourceOptions": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/CustomResourceOptions.html",
"#Inputs": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/Inputs.html",
"#LiftedArray": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/LiftedArray.html",
"#ResourceTransformationArgs": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/ResourceTransformationArgs.html",
"#Resource": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/Resource.html",
"#CustomTimeouts": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/CustomTimeouts.html",
"#jsonStringify": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/jsonStringify.html",
"#ID": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/ID.html",
"#RunError": "/docs/reference/pkg/nodejs/pulumi/pulumi/classes/RunError.html",
"#Unwrap": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/Unwrap.html",
"#ResourceTransformation": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/ResourceTransformation.html",
"#getProject": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/getProject.html",
"#ResourceTransform": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/ResourceTransform.html",
"#UnwrapSimple": "/docs/reference/pkg/nodejs/pulumi/pulumi/types/UnwrapSimple.html",
"#StackReferenceOutputDetails": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/StackReferenceOutputDetails.html",
"#all": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/all.html",
"#isGrpcError": "/docs/reference/pkg/nodejs/pulumi/pulumi/functions/isGrpcError.html",
"#OutputConstructor": "/docs/reference/pkg/nodejs/pulumi/pulumi/interfaces/OutputConstructor.html",
}
if (redirects[location.hash]) {
location.href = redirects[location.hash];
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"postcss-cli": "^8.3.1",
"sitemapper": "^3.2.2",
"typedoc": "^0.25.11",
"typedoc-plugin-script-inject": "^1.0.0",
"typescript": "^4.9.5"
}
}
}
3 changes: 3 additions & 0 deletions scripts/run_typedoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set -o errexit -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

TOOL_TYPEDOC="$SCRIPT_DIR/../node_modules/.bin/typedoc"
TOOL_TYPEDOC_CONFIG="$SCRIPT_DIR/../typedoc.json"

OUTDIR="${SCRIPT_DIR}/../static-prebuilt/docs/reference/pkg/nodejs/pulumi"

Expand Down Expand Up @@ -61,6 +62,8 @@ generate_docs() {
--excludeInternal --excludeExternals --excludePrivate \
--cleanOutputDir \
--skipErrorChecking \
--plugin typedoc-plugin-script-inject \
--options "$TOOL_TYPEDOC_CONFIG" \
index.ts

popd
Expand Down
3 changes: 3 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"scriptSrc": "/docs/reference/pkg/nodejs/pulumi/pulumi/redirects.js"
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4591,6 +4591,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==

typedoc-plugin-script-inject@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/typedoc-plugin-script-inject/-/typedoc-plugin-script-inject-1.0.0.tgz#f0f62efaaa562f49c878370f603707caa075c41c"
integrity sha512-dxzZbuUzyJHhSxf5FGzPz6DW3Hys3pXppwgZCFW7Jne9k0cZ8g4Tll/J5FAbIJiqSgsk/Gs17JtzT2ZyriWfMw==

typedoc@^0.25.11:
version "0.25.11"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.11.tgz#75080c594c1e26b7676f90faebb367fb5a32dc8d"
Expand Down

0 comments on commit 2ae4f61

Please sign in to comment.