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

JsBindings: Add support for writing documents to files #1252

Merged
merged 3 commits into from
Jul 9, 2021

Conversation

frericp
Copy link
Collaborator

@frericp frericp commented Jun 29, 2021

This PR enables writing documents to files. In the browser, the file will be downloaded automatically.

Update #1184

@@ -451,5 +466,47 @@
return _readFromXmlString(doc, result.data, searchPath, readOptions, filesLoaded, result.filePath);
});
};

// Write a document to a file.
Module.writeToXmlFile = function(doc, fileName, writeOptions = null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This two functions are exactly the same except a word, can we rewrite it?
Maybe one function for checking the arguments

// Export inlining included content
const exportOptions = new mx.XmlExportOptions();
exportOptions.writeXIncludeEnable = false;
mx.writeToXmlFile(doc, filename, exportOptions);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be exportToXmlFile?


// Node only, because we cannot read from a downloaded file in the browser
it('Write XML to file', async () => {
const filename = '_build/testFile.mtlx';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests are exactly the same? why not run a loop or something? Maybe we dont need XmlExport.spec?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually just copied the test because I was too lazy to write a more specific one for it 😅
Replaced it with one that actually checks the specifics of the export function 👍

@frericp frericp merged commit cf64faa into adsk_contrib/dev Jul 9, 2021
@frericp frericp deleted the adsk_contrib/xml_writing branch July 9, 2021 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants