TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.76k stars 701 forks source link

Support for custom output directory structure #2111

Open NullVoxPopuli opened 1 year ago

NullVoxPopuli commented 1 year ago

Search terms

Cloudflare pages

Expected Behavior

Visiting a link for a function works

Actual Behavior

Cloudflare pages reverts to the /index.html because /functions is used for Cloudflare-specific stuff.

Steps to reproduce the bug

  1. Deploy any typedoc output to Cloudflare pages.
  2. Click any function on any of the docs pages.

Example:

I have this output:

Permissions Size User          Date Modified Name
.rw-rw-r--   143 nullvoxpopuli  8 Dec 13:23  .nojekyll
drwxrwxr-x     - nullvoxpopuli  8 Dec 13:23  assets
drwxrwxr-x     - nullvoxpopuli  8 Dec 13:23  classes
drwxrwxr-x     - nullvoxpopuli  8 Dec 13:23  functions
.rw-rw-r--   23k nullvoxpopuli  8 Dec 13:23  index.html
drwxrwxr-x     - nullvoxpopuli  8 Dec 13:23  interfaces
drwxrwxr-x     - nullvoxpopuli  8 Dec 13:23  modules
.rw-rw-r--  9.1k nullvoxpopuli  8 Dec 13:23  modules.html
drwxrwxr-x     - nullvoxpopuli  8 Dec 13:23  types
drwxrwxr-x     - nullvoxpopuli  8 Dec 13:23  variables

Which is deployed to: ember-resources.pages.dev/ On any page, such as: https://ember-resources.pages.dev/modules/util_cell I click the available functions, such as: https://ember-resources.pages.dev/functions/util_cell.cell.html, but I am redirected to a poorly rendered version of https://ember-resources.pages.dev

My config:

{
  "tsconfig": "../ember-resources/tsconfig.json",
  "entryPoints": [
    "../ember-resources/src/index.ts",
    "../ember-resources/src/util/"
  ],
  "entryPointStrategy": "expand",
  "readme": "../README.md",
  "exclude": [],
  "json": "./docs.json",
  "out": "dist",
  "pretty": true,
  "excludePrivate": true,
  "excludeProtected": false,
  "excludeExternals": true,
  "disableSources": true,
  "searchInComments": true,
  "categorizeByGroup": false,
  "plugin": [
  ]
}

Environment

typedoc 0.23.14
typescript 4.8.3

❯ node -v
v16.15.1

❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:    22.04
Codename:   jammy

I guess, what I'd like to see is a way to have customization over the file/folder structure. Maybe functions can be nested under their modules?

Cherry commented 1 year ago

Looks like the same issue as in https://github.com/cloudflare/wrangler2/issues/2240

amochkin commented 1 year ago

Temporary solution: https://github.com/cloudflare/wrangler2/issues/2240#issuecomment-1343406897

Gerrit0 commented 1 year ago

Wow, cloudflare, talk about a terrible design decision...

mogelbrod commented 1 year ago

I encountered this today, and unfortunately it seems like the workaround is not working 😞

Temporary solution: cloudflare/workers-sdk#2240 (comment)

I adapted it to work specifically for typedoc:

typedoc && mv docs/functions docs/funcs && find docs -name '*.html' -exec sed -i '' -E 's:(href="[^"]*)functions:\1funcs:g' {} +

With the above in place it works fine when JS is disabled, but typedoc generates links via JS when enabled using the gzip encoded data in window.navigationData. This data isn't easily modified via sed, so I'm currently stuck without any viable workaround other than perhaps manually patching the typedoc codebase 😬

https://github.com/TypeStrong/typedoc/blob/f2d2abe054feca91b89c00c33e1d726bbda85dcb/src/lib/output/themes/default/assets/typedoc/Navigation.ts#L30-L34

NikolaRHristov commented 1 year ago

I made a custom theme that overrides the default mappings and outputs to different directories, you can see an example in:

https://github.com/PlayForm/Build/blob/2a55d65834e712df344957775701aa4248cb1e3f/Source/Class/TypeDoc/Theme.ts

And here is how it works: https://typescript-esbuild.nikolahristov.tech/Function/Build.Build

This is hosted on Cloudflare Pages, so no issues there. That's the output of the file structure:

image