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

EaseFunction svg graphs in doc #17461

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SpecificProtagonist
Copy link
Contributor

@SpecificProtagonist SpecificProtagonist commented Jan 21, 2025

Objective

The docs of EaseFunction don't visualize the different functions, requiring you to check out the Bevy repo and running the easing_function example.

Solution

  • Add tool to generate suitable svg graphs. This only needs to be re-run when adding new ease functions.
  • works with all themes
  • also add missing easing functions to example.

Showcase

Graphs

@SpecificProtagonist SpecificProtagonist added C-Docs An addition or correction to our documentation A-Math Fundamental domain-agnostic mathematical operations S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 21, 2025
@alice-i-cecile alice-i-cecile added the X-Contentious There are nontrivial implications that should be thought through label Jan 21, 2025
@BenjaminBrienen BenjaminBrienen added the D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes label Jan 21, 2025
Copy link
Contributor

@bushrat011899 bushrat011899 left a comment

Choose a reason for hiding this comment

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

I think this is a good idea. The documentation becomes massively more approachable when it's more than just type definitions; examples, tables, figures, all make it much nicer.

I do have a concern around needing to maintain this tool separately to bevy_math. Perhaps it would be worth trying to refactor this into a proc-macro? Especially considering we're using the doc attribute to just include the SVG string in the documentation anyway.

@SpecificProtagonist
Copy link
Contributor Author

Perhaps it would be worth trying to refactor this into a proc-macro?

I like this idea, my only concern would be whether this would affect build time.

@bushrat011899
Copy link
Contributor

bushrat011899 commented Jan 21, 2025

I like this idea, my only concern would be whether this would affect build time.

Could use cfg_attr(doc, ...) to make the macro only run when building documentation?

@SpecificProtagonist
Copy link
Contributor Author

Will do! I'm assuming the doc would be a feature enabled on docs.rs? Or is there a way to find out if it's getting build by rustdoc?

@bushrat011899
Copy link
Contributor

Will do! I'm assuming the doc would be a feature enabled on docs.rs? Or is there a way to find out if it's getting build by rustdoc?

https://doc.rust-lang.org/rustdoc/advanced-features.html

doc is a built-in config set by rust-doc when it builds documentation. So if you do:

#[cfg_attr(doc, my_special_macro(...))]

It'll only include my_specual_macro when building documentation.

@bushrat011899
Copy link
Contributor

After some experimentation, I don't think it'll be possible to use a proc-macro to generate the graphs. It'd require a cyclic dependency between the macro crate and bevy_math, which is forbidden outside of dev-dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Docs An addition or correction to our documentation D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Contentious There are nontrivial implications that should be thought through
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants