-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Spec] Download page index from tldr.sh #6
Comments
Could use collections for this for easier searching? I'm happy to work on this. 👍 |
I like collections, but i'm not sure exactly how it would help, because the format is [{"name":"7z","platform":["common"]},{"name":"hg","platform":["common"]}] which is not easy to work with. I would like to convert it into a map that like {"7z": {"platform":["common"]}, "hg": {"platform":["common"]}} This way, searching for items can be done in constant time. This new JSON structure can be persisted to disk as well instead of having to recreate it each time. We can even extend the structure to contain the relative paths to the markdown files. The entire thing will obviously be rebuilt when the cache is refreshed. |
I've done some tests locally with collections, because I was thinking it could check the local I got everything working with a test https://github.com/pxgamer/tldr-php/blob/feature/example-testing/src/Cache.php |
While that works, this part https://github.com/pxgamer/tldr-php/blob/feature/example-testing/src/Cache.php#L54-L56 is my issue. That operation can be potentially expensive. It's an O(n) search. |
Yeh, that's true. I'll have a look at the remapping like you specified. |
This will be nontrivial. The JSON file at
https://tldr.sh/assets/index.json
should be downloaded and stored in the.tldr
folder. This file will be the source of truth for finding commands instead of attempting to read a page by making a request or checking the cache. We can find the location of a page by searching through the JSON file. It would probably need to be converted to a format that is easier to query.The text was updated successfully, but these errors were encountered: