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

javascript error when using documentation in old browsers #353

Closed
abubelinha opened this issue Feb 18, 2022 · 4 comments
Closed

javascript error when using documentation in old browsers #353

abubelinha opened this issue Feb 18, 2022 · 4 comments
Labels

Comments

@abubelinha
Copy link

abubelinha commented Feb 18, 2022

Problem Description

Search bar is not working when browsing documentation in old computers.

  • If I use google Chrome (49.0.2623.112 m) inspector console, I see this error message:
    Uncaught SyntaxError: Unexpected token function

    The error happens on this line, in every .html document:

async function initialize() {  /* *************** HERE IS THE ERROR ************ */
 ... 
}
  • If I use Mozilla Firefox (52.9.0 32bit) inspector console, I see this error message:
    TypeError: doc.modulename.replaceAll is not a function [Know more]

    Now the error happens on this line:

function onInput() {
  ...
  ...
  ...
  for (let result of results.slice(0, 10)) {
      let doc = result.doc;
      let url = `${doc.modulename.replaceAll(".", "/")}.html`;  /* *************** HERE IS THE ERROR ************ */
      if (doc.qualname) {
          url += `#${doc.qualname}`;
      }

Not sure if these are related or not to search bar functionality, but I have no way to update that computer OS or browsers.
I guess this might happen to many users of old machines which are still perfectly suitable for running Python up to v.3.4 (plenty of them in my institution).
So it would be a shame they cannot use pdoc documentation.

Would it be possible to make pdoc backwards compatible in old browsers?
Browsing elasticlunr.js documentation, I saw this sentence:

Browsers that do not support ES5 will require a JavaScript shim for Elasticlunr.js to work. You can either use Augment.js, ES5-Shim or any library that patches old browsers to provide an ES5 compatible JavaScript environment.

I hope that gives a chance to make docs work in old browsers.

But if not, would it be possible to at least detect old-browsers and avoid that error message, so further javascript code is not affected?

On my to-do list, I was planning to add some javascript with a custom template (trying to sort items shown in left index) ... but with this error I guess that would be impossible.

Steps to reproduce the behavior:

  1. Open pdoc documentation in Chrome version 49.0.2623.112 m

System Information (machine generating documentation)

pdoc: 8.3.0 & 10.0.1 (same result)
Python: 3.8.7
Platform: Windows-7-6.1.7601-SP1

System Information (machine reading documentation)

Platform: Windows-XP-SP3
Google Chrome version 49.0.2623.112 m
Mozilla Firefox version 52.9.0 32bit

@abubelinha abubelinha added the bug label Feb 18, 2022
@mhils
Copy link
Member

mhils commented Feb 18, 2022

Would it be possible to make pdoc backwards compatible in old browsers?

No, sorry. pdoc only supports recent browser versions, i.e. the latest Chrome, Firefox, Edge, and Safari. It's not viable for us to support Windows XP or a six year old Chrome version. The maintenance burden is too high.

@mhils mhils closed this as completed Feb 18, 2022
@abubelinha
Copy link
Author

abubelinha commented Feb 19, 2022

Thanks @mhils
I proposed two options. What about this?

But if not, would it be possible to at least detect old-browsers and avoid that error message, so further javascript code is not affected?

Of course, I was assuming that those javascript problems are related to search tool. Is this assumption correct?
(so perhaps a prior javascript code could detect old browsers and prevent the search tool from running in them)

As I final option, what are my chances to handle this problem using pdoc configuration options?

  • I used pdoc.render.configure(search=False), expecting the search bar would be gone. But it is still there (see #354)
  • Is it possible to modify the javascript code myself by using templates? Where is the relevant stuff?

Thanks again!

@mhils
Copy link
Member

mhils commented Feb 19, 2022

But if not, would it be possible to at least detect old-browsers and avoid that error message, so further javascript code is not affected?

Again, old browsers are completely unsupported to reduce my maintenance load. This includes any workarounds, error detection, etc. It's a hard and definite no, sorry. I also won't accept pull requests that restore support for Windows XP or Chrome 49, simply based on the premise that I don't want to create the impression that they would be supported in any way.

Of course, I was assuming that those javascript problems are related to search tool. Is this assumption correct?

The search functionality is the only part in pdoc that requires JavaScript, so yes.

expecting the search bar would be gone. But it is still there

pdoc --no-search pdoc works as expected for me. If you believe there is a bug, please reduce provide a minimal reproducible example.

Is it possible to modify the javascript code myself by using templates? Where is the relevant stuff?

Yes. The relevant stuff is in the templates directory. I'm sorry, but I don't have the capacity to answer additional questions on what could be done here.

@abubelinha
Copy link
Author

pdoc --no-search pdoc works as expected for me

I didn't mention --no-search.
I said pdoc.render.configure(search=False)

The example is linked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants