DOC: Validate versions.json before building docs #61573
Adds a JSON validity check for `versions.json` directly inside `pandas_web` during context generation. This ensures malformed JSON (e.g., trailing commas) is caught early, preventing issues like the broken version dropdown in #61572

- [x] Closes #61573
> Can you move this check to main, and just open the file and load it as json, with a comment about what's for.

Thanks for the review @datapythonista, just to confirm: when you say "move this check to main", do you mean the `main()` function itself, or the` __main__` block. My assumption is the `__main__` block, so we catch the error before any file system operations, just want to double check!

Added the trailing comma to `versions.json` to test the failure. Leaving the `sys.exit(1)` in place for now. Once we see the CI result, happy to adjust that if we want to just warn instead of fail
 Better inside the `main` function. The idea is that the `if __name__ == "__main__":` block is only executed when the script is called. If for whatever reason I want to import the script from another file to generate the website, that block won't execute, but I still want to validate the file.

We don't want to warn. What I'm saying is that when you do `json.load()` this will already raise an exception, show an error message and crash the script. So, catching the exception to show an error and crash the script is probably not needed, since it'll already happen, and the code is significantly simpler, just two lines.

If the default error message is not great, then I'm happy with your approach. But instead of `sys.exit` I think it's better to raise a new exception from the previous one (Python can chain exceptions).

Btw, when this is done, if you are interested, it'd be nice to open a new PR to use `pathlib` instead of `os.path` in the whole script. For this PR is better to use `os.path` for consistency. Thanks for such a detailed clarification. Have pushed the updated changes.

> Btw, when this is done, if you are interested, it'd be nice to open a new PR to use `pathlib` instead of `os.path` in the whole script

happy to follow up with a separate PR for the `pathlib` changes once this one is in

 Thanks for the update. I think catching the exception as you did was indeed better, the error message here is not helpful enough. But personally, I would just raise a RuntimeError with the good error message from the original one.

Feel free to remove the comma, after those changes I think we can get this merged. Thanks! Raising `RuntimeError` now as suggested. Thank you so much for your help in this
