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

Using deprecated export method #30

Open
shimwell opened this issue May 16, 2021 · 3 comments
Open

Using deprecated export method #30

shimwell opened this issue May 16, 2021 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed

Comments

@shimwell
Copy link
Contributor

The method currently used to export the TJS file is the toString method
https://github.com/Peque/sphinxcadquery/blob/0b7050c0204b8b2c6f7e6912eaee97ca02b9e776/sphinxcadquery/sphinxcadquery.py#L111

toString appears to be deprecated
https://github.com/CadQuery/cadquery/blob/05e42a75e157ed911aeef84cd7a4a864c59a5750/cadquery/occ_impl/exporters/__init__.py#L114-L118

However CadQuery offers a new method
https://github.com/CadQuery/cadquery/blob/05e42a75e157ed911aeef84cd7a4a864c59a5750/cadquery/occ_impl/exporters/__init__.py#L34-L82

That works like this...

from cadquery import exporters
exporters.export(result, 'result.tjs', exportType='TJS')

This is not a problem quite yet but might become a problem if toString is removed in the future.

While I'm here I was wondering why the file is saved with a sha256 of the string as the file name, is this to make sure it has a unique filename?

@Peque Peque added enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed labels May 16, 2021
@Peque
Copy link
Collaborator

Peque commented May 16, 2021

@shimwell Yeah, one of the reasons was to have unique filenames. That can be achieved with uuid too, but then it is not repeatable/stable.

In example, if you generate the docs locally, you would have a different file name for the same part than me, even if we were at the same commit. Also, if you wanted to share a link to the specific part that you found on a documentation online, you could do that, but the link would break the next time the documentation is generated, even if the part was not altered (imagine a pipeline trigger after a simple typo fix in some paragraph).

I think that was the reasoning behind that decision. But I did this some time ago, so I may have forgotten something... 😂

Maybe stuff about Sphinx cache? 🤷

@Peque
Copy link
Collaborator

Peque commented May 16, 2021

PS: if you want to update the export procedure, you can still use the hashing on the generated file (instead of on the string on memory). 😊

@shimwell
Copy link
Contributor Author

Thanks for the info, I can put this on my todo list, perhaps not straight away as I have a few other things to thinker with first.

Good to know there is a solution that updates the export method and keeps the unique filenames. This will be handy when that deprecate happens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants