doc-gen icon indicating copy to clipboard operation
doc-gen copied to clipboard

Do not write json to stdout

Open eric-wieser opened this issue 3 years ago • 6 comments

Otherwise it can't be used with projects that emit diagnostics

eric-wieser avatar Nov 18 '20 20:11 eric-wieser

This worked fine in my own repository - any idea why it wouldn't be working fine here?

eric-wieser avatar Nov 19 '20 08:11 eric-wieser

This worked fine in my own repository - any idea why it wouldn't be working fine here?

Unfortunately, we cannot use this for mathlib since string.to_char_buffer is excruciatingly slow. The easiest fix would be to add an io function to lean that can write a string (instead of a char_buffer).

gebner avatar Nov 19 '20 08:11 gebner

So writing to stdout using a different mechanism to writing to a file handle? Edit: Ah, I get it now.

eric-wieser avatar Nov 19 '20 08:11 eric-wieser

Unfortunately, put_str also converts to char_buffer under the hood.

gebner avatar Nov 19 '20 09:11 gebner

Would chunking the conversion help here?

eric-wieser avatar Nov 19 '20 09:11 eric-wieser

I worked around this downstream by just calling tail -n 1 export.json, which does the job of separating lean diagnostics from json output. It's ugly, but far easier that digging around in the lean IO internals

eric-wieser avatar Nov 19 '20 16:11 eric-wieser