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

A few HTML feature requests... #21

Closed
femtomc opened this issue May 2, 2024 · 3 comments
Closed

A few HTML feature requests... #21

femtomc opened this issue May 2, 2024 · 3 comments
Labels
feature-request New feature or request

Comments

@femtomc
Copy link

femtomc commented May 2, 2024

Hi! I've started to play around with using penzai to render objects to HTML, which I think embed in my documentation via markdown-exec.

From this experience, I've found a few features (specific to the HTML rendering, I believe) which might be useful to consider. Alternatively, perhaps these are already options! I just haven't determined how to use them!

By default, when folded, hide nested fields

When rendering now, the whole structure is sort of splatted into the HTML. I think replacing the nested innards with ... (or something equivalent) would be quite helpful here. Here's a picture to indicate what I mean:
image

In this image, the thing I mean is that each structure would not print any of its inside fields until unfolded -- hidden with e.g. ...

Remove selector and path renderings
Outside of an interactive environment, it's not useful to see what the selectors will be for inner fields. Additionally, it's not useful to see where things are defined. I'm wondering if it is possible to turn these off (as part of render_to_html).

@danieldjohnson
Copy link
Collaborator

Interesting ideas, thanks!

For the ... rendering, I've so far avoided doing that in order to preserve round-trippability (similar to ordinary repr or pprint). It's also sometimes useful to see many nesting levels at once, especially if you have a lot of small objects (e.g. a list of lists of integers), so it seems like just "always replace nested objects with ..." might be less useful in some cases. I'll have to think about what an appropriate summarization strategy should be, and when to enable it.

In the long run maybe there should be configuration options for these that you can use when setting up treescope. (The render_to_html function is currently used internally for some interactive rendering, so I don't think it would make sense to change its default behavior.)

@danieldjohnson danieldjohnson added the feature-request New feature or request label May 2, 2024
@femtomc
Copy link
Author

femtomc commented May 3, 2024

Re — I was able to turn off the buttons and path renderings by writing my own handler (the handler overloading was quite easy to get the hang of! Neat system). I wasn’t able to figure out the folded (…) idea, but may try again if I have time tomorrow.

@femtomc
Copy link
Author

femtomc commented May 16, 2024

Closing, as I've solved this issue on my end.

@femtomc femtomc closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants