denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98k stars 5.39k forks source link

`deno doc --html *.ts` produces broken `index.html` #26901

Open krlwlfrt opened 5 days ago

krlwlfrt commented 5 days ago

Version: Deno 2.0.6

deno doc produces broken paths in HTML output. Slashes are escaped and extraneous .. are added even though the files are in the same directory.

Command that produces the broken output:

deno doc --html game/**/*.ts browser/*.ts cli.ts
<!-- docs/index.html -->
<!DOCTYPE html>
<html>
<head>
  <title>. - documentation</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="doc-current-file" content="">
  <link rel="stylesheet" href="..&#x2F;styles.css">
  <link rel="stylesheet" href="..&#x2F;page.css">
  <link id="ddocResetStylesheet" rel="stylesheet" href="..&#x2F;reset.css">

    <script src="..&#x2F;search_index.js" defer></script>
    <script src="..&#x2F;script.js" defer></script>
    <script src="..&#x2F;fuse.js" defer></script>
    <script src="..&#x2F;search.js" defer></script>
</head>
...

See: https://krlwlfrt.gitlab.io/snake/

Example repo: https://gitlab.com/krlwlfrt/snake/

krlwlfrt commented 1 day ago

It happens whenever I specify more than one file to generate docs from. All of these examples produce the broken output:

deno doc --html *.ts
deno doc --html **/*.ts
deno doc --html mod.ts types.ts

If I specify only one file the output is fine:

deno doc --html mod.ts
deno doc --html types.ts
krlwlfrt commented 1 day ago

Only index.html is broken... All the other files are fine.

Seally commented 1 day ago

The issue I opened a while back is closely related: https://github.com/denoland/deno/issues/25069

Maybe posting on https://github.com/denoland/deno_doc (which is likely where the fix will happen anyway) will make it less likely for the issue to be buried. *shrugs*

krlwlfrt commented 20 hours ago

For anyone encountering the same problem: the following one-liner fixes the broken index.html for me.

sed -i -e 's/\.\.\&#x2F;//g' -e 's/\&#x2F;/\//g' -e 's/\.\.\/comrak\.css/comrak\.css/g' -e 's/\.\.\/prism/prism/g' docs/index.html
crowlKats commented 20 hours ago

I'll be looking into this tomorrow. @Seally apologies about missing #25069, i'll take a look at that as well