mipatterson / typedoc-plugin-pages

A TypeDoc plugin that lets you integrate your own pages into the documentation output
Apache License 2.0
37 stars 21 forks source link

Search is broken with typedoc 0.17.4 #8

Closed WilliamJns closed 4 years ago

WilliamJns commented 4 years ago

Thanks for this incredible library 👍

Search terms

Im using TypeDoc v0.17.3 with the latest version of the typedoc-plugin-pages in my project.

It seems that the typedoc-plugin-pages plugin is only compatible with TypeDoc v0.16.x and when version TypeDoc v0.17.x is used, due to a change in the structure of the search file by TypeDoc team, this library will encounter an error during build time.

/path/typedoc-plugin-pages/dist/plugin/search/search-manager.js:35
    throw new Error(`Failed to populate search index. ${e.message}`);
    ^
Error: Failed to populate search index. Failed to parse search index. Failed to read search.js file. ENOENT: no such file or directory, open '/Users/williamj/Works/Erpire/Erpire Panel Engine/docs/assets/js/search.js'
    at SearchManager.populateSearchIndex (/path/typedoc-plugin-pages/dist/plugin/search/search-manager.js:35:19)
    at PagesPlugin._renderEndEventHandler (/path/typedoc-plugin-pages/dist/plugin/plugin.js:98:29)
    at triggerEvents (/path/typedoc/dist/lib/utils/events.js:128:43)
    at triggerApi (/path/typedoc/dist/lib/utils/events.js:110:13)
    at eventsApi (/path/typedoc/dist/lib/utils/events.js:21:18)
    at Renderer.trigger (/path/typedoc/dist/lib/utils/events.js:264:13)
    at Renderer.render (/path/typedoc/dist/lib/output/renderer.js:39:18)
    at CliApplication.generateDocs (/path/typedoc/dist/lib/application.js:91:23)
    at CliApplication.bootstrap (/path/typedoc/dist/lib/cli.js:48:26)
    at Object.<anonymous> (/path/typedoc/bin/typedoc:5:

I will present the solution that I have found to solve this problem in a new pull request.

Expected Behavior

Handel both v0.16.x and v0.17.x by checking if search.json is founded on the docs/assets/js path.

Steps to reproduce the bug

  1. Install dependencies
npm install --save-dev typedoc@0.17.4 typedoc-plugin-pages@1.0.0 typedoc-plugin-external-module-name
  1. Config typedoc.json
{
  "name": "Compony name",
  "out": "docs",
  "target": "ES5",
  "mode": "file",
  "includeDeclarations": false,
  "ignoreCompilerErrors": true,
  "disableOutputCheck": true,
  "listInvalidSymbolLinks": false,
  "logger": "none",
  "hideGenerator": true,
  "inputFiles": ["./src"],
  "media": "guides/static",
  "readme": "guides/index.md",
  "theme": "node_modules/@compony/typedoc-theme/theme",
  "pages": "guides/pages.json"
}
  1. Config guides/pages.json
{
  "groups": [...],
  "listInvalidPageLinks": false,
  "output": "guides",
  "reflectionNavigationTitle": "Development API",
  "replaceGlobalsPage": true,
  "separatePluginNavigation": true,
  "source": "guides"
}
  1. Build using typedoc CLI
rm -rf docs && npm run typedoc

Environment

WilliamJns commented 4 years ago

Ref: https://github.com/TypeStrong/typedoc/blob/c73eaafbd6d07939a17f92b75519d362be1f3066/src/lib/output/plugins/JavascriptIndexPlugin.ts#L88

github-actions[bot] commented 4 years ago

:tada: This issue has been resolved in version 1.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

mipatterson commented 4 years ago

@WilliamJns, thanks for the PR. I ended up resolving this issue in a different way. I want to allow users to use this plugin with their own themes so instead of locking the plugin into the old way that TypeDoc generated search indexes (building them on the fly in the browser), I updated the plugin to dynamically detect the version of TypeDoc being used and use the new way (generating the index at doc build time) when the version is recent enough.

andrevmatos commented 3 years ago

Looks like search is broken again with current TypeDoc

Caperious commented 3 years ago

Can confirm, the issue occurs again with typedoc 0.20.36 and typedoc-plugin-pages 1.1.0